Allow user to specify a PATH for finding MPI
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.
https://github.com/E3SM-Project/EKAT/blob/master/cmake/EkatMpiUtils.cmake#L28
Should that be !RESULT ?
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!
Great, thanks so much
I think this should already be doable via MPI_ROOT env/cmake variables.