EKAT icon indicating copy to clipboard operation
EKAT copied to clipboard

Allow user to specify a PATH for finding MPI

Open bartgol opened this issue 3 years ago • 3 comments

Currently, EKAT calls find_package(MPI REQUIRED), without allowing the user to specify a suggestion for a path where to look for mpi.

Ideally, the user should be able to specify a path where cmake should look for MPI. So the call to find_package should be modified to something like

if (MPI_PATH)
   find_package (MPI REQUIRED PATH ${MPI_PATH})
else()
   find_package (MPI REQUIRED)
endif()

Maybe the if is not needed, I just don't recall if cmake would issue a warning if MPI_PATH is not set or empty.

bartgol avatar Feb 16 '22 21:02 bartgol

https://github.com/E3SM-Project/EKAT/blob/master/cmake/EkatMpiUtils.cmake#L28

Should that be !RESULT ?

abagusetty avatar Mar 09 '22 19:03 abagusetty

Ah, good catch! Turns out that our compilation was failing, since in C you cannot have unnamed function parameter (in the function definition), so

int main (int, char**) {
...
}

is not valid C. So the compiler crapped out...but still printed the pragma message, so we were correctly detecting the MPI distribution name.

I think the reason I had it wrong is that, before using try_compile, I was using execute_process, in which a non-zero return code means failure.

I'll fix it right away.

Thanks!

bartgol avatar Mar 09 '22 21:03 bartgol

Great, thanks so much

abagusetty avatar Mar 09 '22 21:03 abagusetty

I think this should already be doable via MPI_ROOT env/cmake variables.

bartgol avatar Dec 02 '24 22:12 bartgol