Skip to content

Commit

Permalink
Merge pull request #523 from DusanJovic-NOAA/no_arg_mismatch
Browse files Browse the repository at this point in the history
Add support to use mpi_f08 MPI module
  • Loading branch information
dustinswales authored Mar 19, 2024
2 parents 8dafc94 + 7384d92 commit 011db4f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)

project(ccpp_framework
VERSION 5.0.0
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/ccpp_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
!
module ccpp_types

use mpi_f08, only: MPI_Comm

!! \section arg_table_ccpp_types
!! \htmlinclude ccpp_types.html
!!
Expand All @@ -27,6 +29,7 @@ module ccpp_types

private
public :: ccpp_t, one
public :: MPI_Comm

!> @var Definition of constant one
integer, parameter :: one = 1
Expand Down
16 changes: 16 additions & 0 deletions src/ccpp_types.meta
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
12 changes: 10 additions & 2 deletions test_prebuild/test_blocked_data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions test_prebuild/test_chunked_data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test_prebuild/test_chunked_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
```

0 comments on commit 011db4f

Please sign in to comment.