@@ -86,15 +86,14 @@ def get_coverage_dir(self) -> Path:
8686 """Get absolute path for code coverage analysis."""
8787 return (internal .CODECOV_DIR / f"R{ self .model_id } " ).absolute ()
8888
89- def _get_build_flags (self , mpi : bool , coverage : bool , compiler_id : str ) -> dict :
89+ def _get_build_flags (self , coverage : bool , compiler_id : str ) -> dict :
9090 """Get flags for CMake build."""
9191 # Supported compilers for code coverage
9292 codecov_compilers = ["ifort" , "ifx" ]
9393
9494 build_flags = {}
9595
9696 build_flags ["build_type" ] = "Debug" if coverage else "Release"
97- build_flags ["mpi" ] = "ON" if mpi else "OFF"
9897
9998 build_flags ["flags_init" ] = ""
10099
@@ -164,14 +163,13 @@ def build(self, modules: list[str], mpi: bool, coverage: bool):
164163 self .logger .debug (
165164 f"Getting environment variable for compiler $FC = { env_fc } "
166165 )
167- build_flags = self ._get_build_flags (mpi , coverage , env_fc )
166+ build_flags = self ._get_build_flags (coverage , env_fc )
168167 env_fc = None
169168
170169 with chdir (path_to_repo ):
171170 env = os .environ .copy ()
172171
173172 cmake_args = [
174- f"-DCABLE_MPI={ build_flags ['mpi' ]} " ,
175173 f"-DCMAKE_BUILD_TYPE={ build_flags ['build_type' ]} " ,
176174 f"-DCMAKE_Fortran_FLAGS_INIT={ build_flags ['flags_init' ]} " ,
177175 "-DCMAKE_VERBOSE_MAKEFILE=ON" ,
@@ -207,12 +205,20 @@ def build(self, modules: list[str], mpi: bool, coverage: bool):
207205 )
208206
209207 self .subprocess_handler .run_cmd (
210- "cmake -S . -B build " + " " .join (cmake_args ), env = env
208+ "cmake -S . -B build/serial -DCABLE_MPI=OFF " + " " .join (cmake_args ), env = env
211209 )
212- self .subprocess_handler .run_cmd ("cmake --build build " , env = env )
210+ self .subprocess_handler .run_cmd ("cmake --build build/serial " , env = env )
213211 self .subprocess_handler .run_cmd (
214- "cmake --install build --prefix ." , env = env
212+ "cmake --install build/serial --prefix ." , env = env
215213 )
214+ if mpi :
215+ self .subprocess_handler .run_cmd (
216+ "cmake -S . -B build/mpi -DCABLE_MPI=ON " + " " .join (cmake_args ), env = env
217+ )
218+ self .subprocess_handler .run_cmd ("cmake --build build/mpi" , env = env )
219+ self .subprocess_handler .run_cmd (
220+ "cmake --install build/mpi --prefix ." , env = env
221+ )
216222
217223
218224def remove_module_lines (file_path : Path ) -> None :
0 commit comments