Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MPI Fortran module in ElmerSolver if possible. #549

Merged
merged 2 commits into from
Sep 2, 2024

Conversation

mmuetzel
Copy link
Contributor

@mmuetzel mmuetzel commented Aug 29, 2024

Define preprocessor macros that indicate if MPI Fortran modules are available with the detected MPI implementation.
If available prefer the Fortran module over the Fortran header. That improves compiler diagnostics and reduces the number of compiler warnings about supposedly mismatched types.

Also, fix errors that were identified by building with the MPI module.

If this change is acceptable something similar could probably also be done for ElmerIce (or parpack).

Define preprocessor macros that indicate if MPI Fortran modules are
available with the detected MPI implementation.
If available prefer the Fortran over the Fortran header. That improves
compiler diagnositics and reduces the number of compiler warnings about
supposed type mismatches.
Fix errors that were identified by building with the MPI module.
@mmuetzel
Copy link
Contributor Author

mmuetzel commented Sep 2, 2024

This change greatly reduces the number of (bogus) warnings from the Fortran compiler. That makes it more tangible to sift through the remaining compiler warnings and check for useful ones.

It shouldn't have any effect on functionality.

Could the changes from this PR be applied?

@juharu
Copy link
Contributor

juharu commented Sep 2, 2024 via email

@raback raback merged commit 567aacc into ElmerCSC:devel Sep 2, 2024
10 checks passed
@juharu
Copy link
Contributor

juharu commented Sep 3, 2024

Due to this (?) commit my cmake (3.17.5) fails with this:

CMake Error at CMakeLists.txt:217 (ADD_LIBRARY):
ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_Fortran" because target
"MPI::MPI_Fortran" is imported but not globally visible.

CMake Error at CMakeLists.txt:218 (ADD_LIBRARY):
ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_C" because target
"MPI::MPI_C" is imported but not globally visible.

CMake Error at CMakeLists.txt:219 (ADD_LIBRARY):
ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_CXX" because target
"MPI::MPI_CXX" is imported but not globally visible.

any idea ?

@mmuetzel
Copy link
Contributor Author

mmuetzel commented Sep 3, 2024

Due to this (?) commit my cmake (3.17.5) fails with this:

CMake Error at CMakeLists.txt:217 (ADD_LIBRARY): ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_Fortran" because target "MPI::MPI_Fortran" is imported but not globally visible.

CMake Error at CMakeLists.txt:218 (ADD_LIBRARY): ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_C" because target "MPI::MPI_C" is imported but not globally visible.

CMake Error at CMakeLists.txt:219 (ADD_LIBRARY): ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_CXX" because target "MPI::MPI_CXX" is imported but not globally visible.

any idea ?

Oof. Which version of CMake do you use? I've been testing with a pretty new version:

$ cmake --version
cmake version 3.30.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

An alternative to using ALIAS targets could be to create our own imported targets and link to the respective MPI:: targets instead.
I'll try to propose a change for that later.

In any case: Sorry for the inconvenience.

mmuetzel added a commit to mmuetzel/elmerfem that referenced this pull request Sep 3, 2024
This fixes a configuration issue with older versions of CMake.
See: ElmerCSC#549 (comment)
```
CMake Error at CMakeLists.txt:217 (ADD_LIBRARY):
ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_Fortran" because target
"MPI::MPI_Fortran" is imported but not globally visible.

CMake Error at CMakeLists.txt:218 (ADD_LIBRARY):
ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_C" because target
"MPI::MPI_C" is imported but not globally visible.

CMake Error at CMakeLists.txt:219 (ADD_LIBRARY):
ADD_LIBRARY cannot create ALIAS target "Elmer::MPI_CXX" because target
"MPI::MPI_CXX" is imported but not globally visible.
```
@mmuetzel
Copy link
Contributor Author

mmuetzel commented Sep 3, 2024

@juharu: I opened #560 that avoids aliasing an imported CMake target. Does that fix the configuration issue for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants