From 03790c7eb7e199d6a04f7ff105bff0d28224c0d7 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Thu, 24 Mar 2022 14:38:40 +0000 Subject: [PATCH 1/8] Swtich to mpi_f08 module. Add MPI_Comm DDT The changes were made by Dom Heinzeller --- src/ccpp_types.F90 | 11 +++++++++++ src/ccpp_types.meta | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/ccpp_types.F90 b/src/ccpp_types.F90 index 992646bd..9329e00d 100644 --- a/src/ccpp_types.F90 +++ b/src/ccpp_types.F90 @@ -19,6 +19,10 @@ ! module ccpp_types +#ifdef MPI + use mpi_f08, only: MPI_Comm +#endif + !! \section arg_table_ccpp_types !! \htmlinclude ccpp_types.html !! @@ -27,6 +31,13 @@ module ccpp_types private public :: ccpp_t, one + public :: MPI_Comm + +#ifndef MPI + type :: MPI_Comm + integer, parameter :: dummy = 0 + end type MPI_Comm +#endif !> @var Definition of constant one integer, parameter :: one = 1 diff --git a/src/ccpp_types.meta b/src/ccpp_types.meta index 963762cc..13c8ad93 100644 --- a/src/ccpp_types.meta +++ b/src/ccpp_types.meta @@ -45,6 +45,16 @@ dimensions = () type = integer +######################################################################## +[ccpp-table-properties] + name = MPI_Comm + type = ddt + dependencies = + +[ccpp-arg-table] + name = MPI_Comm + type = ddt + ######################################################################## [ccpp-table-properties] @@ -67,3 +77,9 @@ units = 1 dimensions = () type = integer +[MPI_Comm] + standard_name = MPI_Comm + long_name = definition of type MPI_Comm + units = DDT + dimensions = () + type = MPI_Comm From 47a1e9c1c067dce54a446c1cc03254b938b57aa4 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Wed, 28 Sep 2022 15:24:08 +0000 Subject: [PATCH 2/8] Fix local MPI_Comm type --- src/ccpp_types.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ccpp_types.F90 b/src/ccpp_types.F90 index 9329e00d..c87bbf45 100644 --- a/src/ccpp_types.F90 +++ b/src/ccpp_types.F90 @@ -35,7 +35,7 @@ module ccpp_types #ifndef MPI type :: MPI_Comm - integer, parameter :: dummy = 0 + integer :: dummy = 0 end type MPI_Comm #endif From 1e089274becb585777b577fc27061f568e0eb2f2 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 7 Nov 2022 11:24:36 -0700 Subject: [PATCH 3/8] If MPI is used, find package --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4daf855b..8ec0afc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,12 @@ set(PACKAGE "ccpp-framework") set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Steve Goldhaber") string(TIMESTAMP YEAR "%Y") +#------------------------------------------------------------------------------ +# Set MPI flags for C/C++/Fortran +if (MPI) + find_package(MPI REQUIRED C Fortran) +endif (OPENMP) + #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran if (OPENMP) From c3c4c7c8117e38cd52285ca298b458c4fd3129ed Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Fri, 18 Nov 2022 20:58:09 +0000 Subject: [PATCH 4/8] Fixed cmake if/endif mismatch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ec0afc0..8b29b2b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ string(TIMESTAMP YEAR "%Y") # Set MPI flags for C/C++/Fortran if (MPI) find_package(MPI REQUIRED C Fortran) -endif (OPENMP) +endif (MPI) #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran From 2cee086e600ed7861f9bf0b91f9bafe276b9a377 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Fri, 23 Feb 2024 13:54:36 -0700 Subject: [PATCH 5/8] Make mpi_f08 a mandatory dependency of ccpp-framework --- CMakeLists.txt | 9 +++++---- src/ccpp_types.F90 | 8 -------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b29b2b3..f0e1ac1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,11 @@ set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Steve Goldhaber") string(TIMESTAMP YEAR "%Y") #------------------------------------------------------------------------------ -# Set MPI flags for C/C++/Fortran -if (MPI) - find_package(MPI REQUIRED C Fortran) -endif (MPI) +# Set MPI flags for C/C++/Fortran with MPI F08 interface +find_package(MPI REQUIRED C Fortran) +if(NOT MPI_Fortran_HAVE_F08_MODULE) + message(FATAL_ERROR "MPI implementation does not support the Fortran 2008 mpi_f08 interface") +endif() #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran diff --git a/src/ccpp_types.F90 b/src/ccpp_types.F90 index a9d44b84..12faa75c 100644 --- a/src/ccpp_types.F90 +++ b/src/ccpp_types.F90 @@ -19,9 +19,7 @@ ! module ccpp_types -#ifdef MPI use mpi_f08, only: MPI_Comm -#endif !! \section arg_table_ccpp_types !! \htmlinclude ccpp_types.html @@ -33,12 +31,6 @@ module ccpp_types public :: ccpp_t, one public :: MPI_Comm -#ifndef MPI - type :: MPI_Comm - integer :: dummy = 0 - end type MPI_Comm -#endif - !> @var Definition of constant one integer, parameter :: one = 1 From a4524b5314a142177d68d1a1e4ed96c98839d3ea Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Fri, 23 Feb 2024 13:55:45 -0700 Subject: [PATCH 6/8] Update test_prebuild/test_blocked_data test_prebuild/test_chunked_data now that mpi_f08 is a mandatory dependency --- test_prebuild/test_blocked_data/CMakeLists.txt | 10 +++++++++- test_prebuild/test_blocked_data/README.md | 3 +++ test_prebuild/test_chunked_data/CMakeLists.txt | 10 +++++++++- test_prebuild/test_chunked_data/README.md | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/test_prebuild/test_blocked_data/CMakeLists.txt b/test_prebuild/test_blocked_data/CMakeLists.txt index 921c87e6..a429e404 100644 --- a/test_prebuild/test_blocked_data/CMakeLists.txt +++ b/test_prebuild/test_blocked_data/CMakeLists.txt @@ -3,12 +3,19 @@ cmake_minimum_required(VERSION 3.0) project(ccpp_blocked_data VERSION 1.0.0 - LANGUAGES Fortran) + LANGUAGES C Fortran) #------------------------------------------------------------------------------ # Request a static build option(BUILD_SHARED_LIBS "Build a shared library" OFF) +#------------------------------------------------------------------------------ +# Set MPI flags for C/C++/Fortran with MPI F08 interface +find_package(MPI REQUIRED C Fortran) +if(NOT MPI_Fortran_HAVE_F08_MODULE) + message(FATAL_ERROR "MPI implementation does not support the Fortran 2008 mpi_f08 interface") +endif() + #------------------------------------------------------------------------------ # Set the sources: physics type definitions set(TYPEDEFS $ENV{CCPP_TYPEDEFS}) @@ -57,6 +64,7 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0 -fno-unsafe-math-optimizatio #------------------------------------------------------------------------------ add_library(ccpp_blocked_data STATIC ${SCHEMES} ${CAPS} ${API}) +target_link_libraries(ccpp_blocked_data PRIVATE MPI::MPI_Fortran) # Generate list of Fortran modules from defined sources foreach(source_f90 ${CAPS} ${API}) get_filename_component(tmp_source_f90 ${source_f90} NAME) diff --git a/test_prebuild/test_blocked_data/README.md b/test_prebuild/test_blocked_data/README.md index ad977913..ee7962e1 100644 --- a/test_prebuild/test_blocked_data/README.md +++ b/test_prebuild/test_blocked_data/README.md @@ -10,4 +10,7 @@ mkdir build cd build cmake .. 2>&1 | tee log.cmake make 2>&1 | tee log.make +./test_blocked_data.x +# On systems where linking against the MPI library requires a parallel launcher, +# use 'mpirun -np 1 ./test_blocked_data.x' or 'srun -n 1 ./test_blocked_data.x' etc. ``` diff --git a/test_prebuild/test_chunked_data/CMakeLists.txt b/test_prebuild/test_chunked_data/CMakeLists.txt index 0d055768..4d7456f1 100644 --- a/test_prebuild/test_chunked_data/CMakeLists.txt +++ b/test_prebuild/test_chunked_data/CMakeLists.txt @@ -3,12 +3,19 @@ cmake_minimum_required(VERSION 3.0) project(ccpp_chunked_data VERSION 1.0.0 - LANGUAGES Fortran) + LANGUAGES C Fortran) #------------------------------------------------------------------------------ # Request a static build option(BUILD_SHARED_LIBS "Build a shared library" OFF) +#------------------------------------------------------------------------------ +# Set MPI flags for C/C++/Fortran with MPI F08 interface +find_package(MPI REQUIRED C Fortran) +if(NOT MPI_Fortran_HAVE_F08_MODULE) + message(FATAL_ERROR "MPI implementation does not support the Fortran 2008 mpi_f08 interface") +endif() + #------------------------------------------------------------------------------ # Set the sources: physics type definitions set(TYPEDEFS $ENV{CCPP_TYPEDEFS}) @@ -57,6 +64,7 @@ set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0 -fno-unsafe-math-optimizatio #------------------------------------------------------------------------------ add_library(ccpp_chunked_data STATIC ${SCHEMES} ${CAPS} ${API}) +target_link_libraries(ccpp_chunked_data PRIVATE MPI::MPI_Fortran) # Generate list of Fortran modules from defined sources foreach(source_f90 ${CAPS} ${API}) get_filename_component(tmp_source_f90 ${source_f90} NAME) diff --git a/test_prebuild/test_chunked_data/README.md b/test_prebuild/test_chunked_data/README.md index 40812515..16db6fc5 100644 --- a/test_prebuild/test_chunked_data/README.md +++ b/test_prebuild/test_chunked_data/README.md @@ -10,4 +10,7 @@ mkdir build cd build cmake .. 2>&1 | tee log.cmake make 2>&1 | tee log.make +./test_chunked_data.x +# On systems where linking against the MPI library requires a parallel launcher, +# use 'mpirun -np 1 ./test_chunked_data.x' or 'srun -n 1 ./test_chunked_data.x' etc. ``` From 13ec1211058029d433eea2ab1fcc66b304f1fe0d Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Fri, 23 Feb 2024 14:04:59 -0700 Subject: [PATCH 7/8] Bump minimum cmake version required --- CMakeLists.txt | 2 +- test_prebuild/test_blocked_data/CMakeLists.txt | 2 +- test_prebuild/test_chunked_data/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0e1ac1e..6d9f56aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) project(ccpp_framework VERSION 5.0.0 diff --git a/test_prebuild/test_blocked_data/CMakeLists.txt b/test_prebuild/test_blocked_data/CMakeLists.txt index a429e404..fdd5f9af 100644 --- a/test_prebuild/test_blocked_data/CMakeLists.txt +++ b/test_prebuild/test_blocked_data/CMakeLists.txt @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) project(ccpp_blocked_data VERSION 1.0.0 diff --git a/test_prebuild/test_chunked_data/CMakeLists.txt b/test_prebuild/test_chunked_data/CMakeLists.txt index 4d7456f1..512a5a7e 100644 --- a/test_prebuild/test_chunked_data/CMakeLists.txt +++ b/test_prebuild/test_chunked_data/CMakeLists.txt @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) project(ccpp_chunked_data VERSION 1.0.0 From c911911cd4700a604f51d5e547a5999661918996 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Mon, 26 Feb 2024 23:59:00 +0000 Subject: [PATCH 8/8] Remove C from MPI find_package --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d9f56aa..4b7aff41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,8 @@ set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Steve Goldhaber") string(TIMESTAMP YEAR "%Y") #------------------------------------------------------------------------------ -# Set MPI flags for C/C++/Fortran with MPI F08 interface -find_package(MPI REQUIRED C Fortran) +# Set MPI flags for Fortran with MPI F08 interface +find_package(MPI REQUIRED Fortran) if(NOT MPI_Fortran_HAVE_F08_MODULE) message(FATAL_ERROR "MPI implementation does not support the Fortran 2008 mpi_f08 interface") endif()