Skip to content

Commit

Permalink
Try find_package(MPI REQUIRED) for MPI build
Browse files Browse the repository at this point in the history
The compiled MPI executable breaks binary equivalence.

The compiled serial executable preserves binary equivalence.

Shared object files between MPI and serial builds are identical, CMake
object libraries could be useful here.
  • Loading branch information
SeanBryan51 committed Jan 29, 2024
1 parent ecba2bb commit f4901b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ option(CABLE_MPI "Build the MPI executable" OFF)
# third party libs
find_package(PkgConfig REQUIRED)
pkg_check_modules(NETCDF REQUIRED IMPORTED_TARGET "netcdf-fortran")
if(CABLE_MPI)
find_package(MPI REQUIRED)
endif()

set(CABLE_INTEL_Fortran_FLAGS -fp-model precise)
set(CABLE_INTEL_Fortran_FLAGS_DEBUG -O0 -g -traceback -fpe0)
Expand Down Expand Up @@ -166,6 +169,7 @@ endif()
target_link_libraries(
cable
PkgConfig::NETCDF
"$<$<BOOL:${CABLE_MPI}>:MPI::MPI_Fortran>"
)

install(TARGETS cable RUNTIME)
2 changes: 1 addition & 1 deletion build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ else
fi
if [[ -n $mpi ]]; then
cmake_args+=(-DCABLE_MPI="ON")
cmake_args+=(-DCMAKE_Fortran_COMPILER="mpif90")
cmake_args+=(-DMPI_Fortran_COMPILER="mpif90")
fi

cmake_build_args=()
Expand Down

0 comments on commit f4901b2

Please sign in to comment.