-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test_prebuild/test_mpi_test (incomplete)
- Loading branch information
Showing
9 changed files
with
468 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#------------------------------------------------------------------------------ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
project(ccpp_mpi_test | ||
VERSION 1.0.0 | ||
LANGUAGES C Fortran) | ||
|
||
#------------------------------------------------------------------------------ | ||
# Request a static build | ||
option(BUILD_SHARED_LIBS "Build a shared library" OFF) | ||
|
||
#------------------------------------------------------------------------------ | ||
# Set MPI flags for C/C++/Fortran | ||
if (MPI_F90 OR MPI_F08) | ||
find_package(MPI REQUIRED C Fortran) | ||
if (MPI_F90) | ||
add_definitions(-DMPI_F90) | ||
elseif (MPI_F08) | ||
add_definitions(-DMPI_F08) | ||
endif (MPI_F90) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ | ||
# Pass debug/release flag to Fortran files for preprocessor | ||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
add_definitions(-DDEBUG) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------ | ||
# Set the sources: physics type definitions | ||
set(TYPEDEFS $ENV{CCPP_TYPEDEFS}) | ||
if(TYPEDEFS) | ||
message(STATUS "Got CCPP TYPEDEFS from environment variable: ${TYPEDEFS}") | ||
else(TYPEDEFS) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_TYPEDEFS.cmake) | ||
message(STATUS "Got CCPP TYPEDEFS from cmakefile include file: ${TYPEDEFS}") | ||
endif(TYPEDEFS) | ||
|
||
# Generate list of Fortran modules from the CCPP type | ||
# definitions that need need to be installed | ||
foreach(typedef_module ${TYPEDEFS}) | ||
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${typedef_module}) | ||
endforeach() | ||
|
||
#------------------------------------------------------------------------------ | ||
# Set the sources: physics schemes | ||
set(SCHEMES $ENV{CCPP_SCHEMES}) | ||
if(SCHEMES) | ||
message(STATUS "Got CCPP SCHEMES from environment variable: ${SCHEMES}") | ||
else(SCHEMES) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_SCHEMES.cmake) | ||
message(STATUS "Got CCPP SCHEMES from cmakefile include file: ${SCHEMES}") | ||
endif(SCHEMES) | ||
#target_link_libraries(SCHEMES PUBLIC MPI::MPI_Fortran MPI::MPI_C) | ||
|
||
# Set the sources: physics scheme caps | ||
set(CAPS $ENV{CCPP_CAPS}) | ||
if(CAPS) | ||
message(STATUS "Got CCPP CAPS from environment variable: ${CAPS}") | ||
else(CAPS) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_CAPS.cmake) | ||
message(STATUS "Got CCPP CAPS from cmakefile include file: ${CAPS}") | ||
endif(CAPS) | ||
|
||
# Set the sources: physics scheme caps | ||
set(API $ENV{CCPP_API}) | ||
if(API) | ||
message(STATUS "Got CCPP API from environment variable: ${API}") | ||
else(API) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/CCPP_API.cmake) | ||
message(STATUS "Got CCPP API from cmakefile include file: ${API}") | ||
endif(API) | ||
|
||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -ggdb -fbacktrace -ffree-line-length-none") | ||
|
||
#------------------------------------------------------------------------------ | ||
add_library(ccpp_mpi_test STATIC ${SCHEMES} ${CAPS} ${API}) | ||
if(MPI_F90 OR MPI_F08) | ||
target_link_libraries(ccpp_mpi_test PUBLIC MPI::MPI_Fortran MPI::MPI_C) | ||
endif(MPI_F90 OR MPI_F08) | ||
|
||
# Generate list of Fortran modules from defined sources | ||
foreach(source_f90 ${CAPS} ${API}) | ||
get_filename_component(tmp_source_f90 ${source_f90} NAME) | ||
string(REGEX REPLACE ".F90" ".mod" tmp_module_f90 ${tmp_source_f90}) | ||
string(TOLOWER ${tmp_module_f90} module_f90) | ||
list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90}) | ||
endforeach() | ||
|
||
set_target_properties(ccpp_mpi_test PROPERTIES VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR}) | ||
|
||
add_executable(test_mpi_test.x main.F90) | ||
add_dependencies(test_mpi_test.x ccpp_mpi_test) | ||
#target_link_libraries(test_mpi_test.x ccpp_mpi_test MPI::MPI_Fortran MPI::MPI_C) | ||
target_link_libraries(test_mpi_test.x ccpp_mpi_test) | ||
set_target_properties(test_mpi_test.x PROPERTIES LINKER_LANGUAGE Fortran) | ||
|
||
# Define where to install the library | ||
install(TARGETS ccpp_mpi_test | ||
EXPORT ccpp_mpi_test-targets | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION lib | ||
) | ||
# Export our configuration | ||
install(EXPORT ccpp_mpi_test-targets | ||
FILE ccpp_mpi_test-config.cmake | ||
DESTINATION lib/cmake | ||
) | ||
# Define where to install the C headers and Fortran modules | ||
#install(FILES ${HEADERS_C} DESTINATION include) | ||
install(FILES ${MODULES_F90} DESTINATION include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# How to build the blocked data test | ||
|
||
1. Set compiler environment as appropriate for your system | ||
2. Run the following commands: | ||
``` | ||
cd test_prebuild/test_mpi/ | ||
rm -fr build_no_mpi | ||
mkdir build_no_mpi | ||
../../scripts/ccpp_prebuild.py --config=ccpp_prebuild_config.py --builddir=build_no_mpi | ||
cd build_no_mpi | ||
cmake .. 2>&1 | tee log.cmake | ||
make 2>&1 | tee log.make | ||
./test_mpi_test.x | ||
cd .. | ||
rm -fr build_mpi_f90 | ||
mkdir build_mpi_f90 | ||
../../scripts/ccpp_prebuild.py --config=ccpp_prebuild_config.py --builddir=build_mpi_f90 | ||
cd build_mpi_f90 | ||
cmake -DMPI_F90=ON .. 2>&1 | tee log.cmake | ||
make 2>&1 | tee log.make | ||
./test_mpi_test.x | ||
cd .. | ||
rm -fr build_mpi_f90 | ||
mkdir build_mpi_f90 | ||
../../scripts/ccpp_prebuild.py --config=ccpp_prebuild_config.py --builddir=build_mpi_f08 | ||
cd build_mpi_f08 | ||
cmake -DMPI_F08=ON .. 2>&1 | tee log.cmake | ||
make 2>&1 | tee log.make | ||
./test_mpi_test.x | ||
cd .. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env python | ||
|
||
# CCPP prebuild config for GFDL Finite-Volume Cubed-Sphere Model (FV3) | ||
|
||
############################################################################### | ||
# Definitions # | ||
############################################################################### | ||
|
||
HOST_MODEL_IDENTIFIER = "FV3" | ||
|
||
# Add all files with metadata tables on the host model side and in CCPP, | ||
# relative to basedir = top-level directory of host model. This includes | ||
# kind and type definitions used in CCPP physics. Also add any internal | ||
# dependencies of these files to the list. | ||
VARIABLE_DEFINITION_FILES = [ | ||
# actual variable definition files | ||
'../../src/ccpp_types.F90', | ||
'data.F90', | ||
] | ||
|
||
TYPEDEFS_NEW_METADATA = { | ||
'ccpp_types' : { | ||
'ccpp_t' : 'ccpp_data', | ||
'ccpp_mpi_comm_t' : 'mpi_comm', | ||
'ccpp_types' : '', | ||
}, | ||
'data' : { | ||
'data' : '', | ||
}, | ||
} | ||
|
||
# Add all physics scheme files relative to basedir | ||
SCHEME_FILES = [ | ||
'mpi_test_scheme.F90', | ||
] | ||
|
||
# Default build dir, relative to current working directory, | ||
# if not specified as command-line argument | ||
DEFAULT_BUILD_DIR = 'build' | ||
|
||
# Auto-generated makefile/cmakefile snippets that contain all type definitions | ||
TYPEDEFS_MAKEFILE = '{build_dir}/CCPP_TYPEDEFS.mk' | ||
TYPEDEFS_CMAKEFILE = '{build_dir}/CCPP_TYPEDEFS.cmake' | ||
TYPEDEFS_SOURCEFILE = '{build_dir}/CCPP_TYPEDEFS.sh' | ||
|
||
# Auto-generated makefile/cmakefile snippets that contain all schemes | ||
SCHEMES_MAKEFILE = '{build_dir}/CCPP_SCHEMES.mk' | ||
SCHEMES_CMAKEFILE = '{build_dir}/CCPP_SCHEMES.cmake' | ||
SCHEMES_SOURCEFILE = '{build_dir}/CCPP_SCHEMES.sh' | ||
|
||
# Auto-generated makefile/cmakefile snippets that contain all caps | ||
CAPS_MAKEFILE = '{build_dir}/CCPP_CAPS.mk' | ||
CAPS_CMAKEFILE = '{build_dir}/CCPP_CAPS.cmake' | ||
CAPS_SOURCEFILE = '{build_dir}/CCPP_CAPS.sh' | ||
|
||
# Directory where to put all auto-generated physics caps | ||
CAPS_DIR = '{build_dir}' | ||
|
||
# Directory where the suite definition files are stored | ||
SUITES_DIR = '.' | ||
|
||
# Optional arguments - only required for schemes that use | ||
# optional arguments. ccpp_prebuild.py will throw an exception | ||
# if it encounters a scheme subroutine with optional arguments | ||
# if no entry is made here. Possible values are: 'all', 'none', | ||
# or a list of standard_names: [ 'var1', 'var3' ]. | ||
OPTIONAL_ARGUMENTS = {} | ||
|
||
# Directory where to write static API to | ||
STATIC_API_DIR = '{build_dir}' | ||
STATIC_API_CMAKEFILE = '{build_dir}/CCPP_API.cmake' | ||
STATIC_API_SOURCEFILE = '{build_dir}/CCPP_API.sh' | ||
|
||
# Directory for writing HTML pages generated from metadata files | ||
METADATA_HTML_OUTPUT_DIR = '{build_dir}' | ||
|
||
# HTML document containing the model-defined CCPP variables | ||
HTML_VARTABLE_FILE = '{build_dir}/CCPP_VARIABLES_MPI_TEST.html' | ||
|
||
# LaTeX document containing the provided vs requested CCPP variables | ||
LATEX_VARTABLE_FILE = '{build_dir}/CCPP_VARIABLES_MPI_TEST.tex' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module data | ||
|
||
!! \section arg_table_data Argument Table | ||
!! \htmlinclude data.html | ||
!! | ||
use ccpp_types, only: ccpp_t | ||
|
||
#if defined MPI_F08 | ||
#define ccpp_mpi_comm_type type(mpi_comm) | ||
#else | ||
#define ccpp_mpi_comm_type integer | ||
#endif | ||
|
||
#if defined MPI_F08 | ||
use mpi_f08 | ||
#elif defined MPI_F90 | ||
use mpi | ||
#endif | ||
|
||
implicit none | ||
|
||
private | ||
|
||
public ncols | ||
public ccpp_data | ||
public ccpp_mpi_comm | ||
|
||
integer, parameter :: ncols = 1 | ||
type(ccpp_t), target :: ccpp_data | ||
ccpp_mpi_comm_type :: ccpp_mpi_comm | ||
|
||
end module data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[ccpp-table-properties] | ||
name = data | ||
type = module | ||
dependencies = | ||
[ccpp-arg-table] | ||
name = data | ||
type = module | ||
[ccpp_data] | ||
standard_name = ccpp_t_instance | ||
long_name = instance of derived data type ccpp_t | ||
units = DDT | ||
dimensions = () | ||
type = ccpp_t | ||
[ncols] | ||
standard_name = horizontal_dimension | ||
long_name = horizontal dimension | ||
units = count | ||
dimensions = () | ||
type = integer | ||
[ccpp_mpi_comm] | ||
standard_name = ccpp_mpi_comm | ||
long_name = MPI communicator for use by CCPP | ||
units = 1 | ||
dimensions = () | ||
type = CCPP_MPI_COMM_TYPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
program test_mpi | ||
|
||
use, intrinsic :: iso_fortran_env, only: error_unit | ||
|
||
use ccpp_types, only: ccpp_t | ||
use data, only: ncols | ||
use data, only: ccpp_data, ccpp_mpi_comm | ||
|
||
use ccpp_static_api, only: ccpp_physics_init, & | ||
ccpp_physics_timestep_init, & | ||
ccpp_physics_run, & | ||
ccpp_physics_timestep_finalize, & | ||
ccpp_physics_finalize | ||
|
||
implicit none | ||
|
||
character(len=*), parameter :: ccpp_suite = 'mpi_test_suite' | ||
integer :: ib, ierr | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
! CCPP init step ! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
! Block and thread number are not used; set to safe values | ||
ccpp_data%blk_no = 1 | ||
ccpp_data%thrd_no = 1 | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
! CCPP physics init step ! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
call ccpp_physics_init(ccpp_data, suite_name=trim(ccpp_suite), ierr=ierr) | ||
if (ierr/=0) then | ||
write(error_unit,'(a)') "An error occurred in ccpp_physics_init:" | ||
write(error_unit,'(a)') trim(ccpp_data%errmsg) | ||
stop 1 | ||
end if | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
! CCPP physics timestep init step ! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
call ccpp_physics_timestep_init(ccpp_data, suite_name=trim(ccpp_suite), ierr=ierr) | ||
if (ierr/=0) then | ||
write(error_unit,'(a)') "An error occurred in ccpp_physics_timestep_init:" | ||
write(error_unit,'(a)') trim(ccpp_data%errmsg) | ||
stop 1 | ||
end if | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
! CCPP physics run step ! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
call ccpp_physics_run(ccpp_data, suite_name=trim(ccpp_suite), ierr=ierr) | ||
if (ierr/=0) then | ||
write(error_unit,'(a)') "An error occurred in ccpp_physics_run:" | ||
write(error_unit,'(a)') trim(ccpp_data%errmsg) | ||
stop 1 | ||
end if | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
! CCPP physics timestep finalize step ! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
call ccpp_physics_timestep_finalize(ccpp_data, suite_name=trim(ccpp_suite), ierr=ierr) | ||
if (ierr/=0) then | ||
write(error_unit,'(a)') "An error occurred in ccpp_physics_timestep_finalize:" | ||
write(error_unit,'(a)') trim(ccpp_data%errmsg) | ||
stop 1 | ||
end if | ||
|
||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
! CCPP physics finalize step ! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
call ccpp_physics_finalize(ccpp_data, suite_name=trim(ccpp_suite), ierr=ierr) | ||
if (ierr/=0) then | ||
write(error_unit,'(a)') "An error occurred in ccpp_physics_finalize:" | ||
write(error_unit,'(a)') trim(ccpp_data%errmsg) | ||
stop 1 | ||
end if | ||
|
||
contains | ||
|
||
end program test_mpi |
Oops, something went wrong.