diff --git a/CMakeLists.txt b/CMakeLists.txt index 41e163ff..90634bee 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 @@ -10,6 +10,13 @@ set(PACKAGE "ccpp-framework") set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Dustin Swales" "Courtney Peverley") string(TIMESTAMP YEAR "%Y") +#------------------------------------------------------------------------------ +# 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() + #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran if (OPENMP) diff --git a/src/ccpp_types.F90 b/src/ccpp_types.F90 index dafa7c80..12faa75c 100644 --- a/src/ccpp_types.F90 +++ b/src/ccpp_types.F90 @@ -19,6 +19,8 @@ ! module ccpp_types + use mpi_f08, only: MPI_Comm + !! \section arg_table_ccpp_types !! \htmlinclude ccpp_types.html !! @@ -27,6 +29,7 @@ module ccpp_types private public :: ccpp_t, one + public :: MPI_Comm !> @var Definition of constant one integer, parameter :: one = 1 diff --git a/src/ccpp_types.meta b/src/ccpp_types.meta index 41a01f52..7042d29b 100644 --- a/src/ccpp_types.meta +++ b/src/ccpp_types.meta @@ -57,6 +57,16 @@ dimensions = () type = integer +######################################################################## +[ccpp-table-properties] + name = MPI_Comm + type = ddt + dependencies = + +[ccpp-arg-table] + name = MPI_Comm + type = ddt + ######################################################################## [ccpp-table-properties] @@ -79,3 +89,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 diff --git a/test_prebuild/test_blocked_data/CMakeLists.txt b/test_prebuild/test_blocked_data/CMakeLists.txt index 921c87e6..fdd5f9af 100644 --- a/test_prebuild/test_blocked_data/CMakeLists.txt +++ b/test_prebuild/test_blocked_data/CMakeLists.txt @@ -1,14 +1,21 @@ #------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) 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_chunked_data/CMakeLists.txt b/test_prebuild/test_chunked_data/CMakeLists.txt index 0d055768..512a5a7e 100644 --- a/test_prebuild/test_chunked_data/CMakeLists.txt +++ b/test_prebuild/test_chunked_data/CMakeLists.txt @@ -1,14 +1,21 @@ #------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) 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. ```