diff --git a/CCPP_CAPS.mk b/CCPP_CAPS.mk deleted file mode 100644 index facd1d0a8..000000000 --- a/CCPP_CAPS.mk +++ /dev/null @@ -1,6 +0,0 @@ -# All CCPP caps are defined here. -# -# This file is auto-generated using ccpp_prebuild.py -# at compile time, do not edit manually. -# -CAPS_F90 = diff --git a/CCPP_SCHEMES.mk b/CCPP_SCHEMES.mk deleted file mode 100644 index 21cfc7645..000000000 --- a/CCPP_SCHEMES.mk +++ /dev/null @@ -1,12 +0,0 @@ -# All CCPP schemes are defined here. -# -# This file is auto-generated using ccpp_prebuild.py -# at compile time, do not edit manually. -# -SCHEMES_F = - -SCHEMES_F90 = - -SCHEMES_f = - -SCHEMES_f90 = diff --git a/CMakeLists.txt b/CMakeLists.txt index 86022d555..ffc5b4099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# Set default project to unknown +if(NOT PROJECT) + message(STATUS "Setting CCPP project to 'unknown' as none was specified.") + set(PROJECT "Unknown") +endif (NOT PROJECT) + #------------------------------------------------------------------------------ cmake_minimum_required(VERSION 2.8.11) @@ -6,27 +12,34 @@ set(CMAKE_MACOSX_RPATH 1) if(POLICY CMP0048) cmake_policy(SET CMP0048 NEW) - project(ccppphys VERSION 0.0.1) + project(ccppphys VERSION 1.0.0) else(POLICY CMP0048) project(ccppphys) - set(PROJECT_VERSION 0.0.1) - set(PROJECT_VERSION_MAJOR 0) + set(PROJECT_VERSION 1.0.0) + set(PROJECT_VERSION_MAJOR 1) set(PROJECT_VERSION_MINOR 0) - set(PROJECT_VERSION_PATCH 1) + set(PROJECT_VERSION_PATCH 0) endif(POLICY CMP0048) +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif(POLICY CMP0042) + #------------------------------------------------------------------------------ -set(PACKAGE "ccppphys") +set(PACKAGE "ccpp-physics") set(AUTHORS "Grant J. Firl" "Dom Heinzeller") #------------------------------------------------------------------------------ # Enable Fortran enable_language(Fortran) -#------------------------------------------------------------------------------ -# CMake Modules -# Set the CMake module path -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ccpp-framework/cmake") +# DH this should be a PROJECT == CCPP-SCM test +if (NOT PROJECT MATCHES "CCPP-FV3") + #------------------------------------------------------------------------------ + # CMake Modules + # Set the CMake module path + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ccpp-framework/cmake") +endif (NOT PROJECT MATCHES "CCPP-FV3") #------------------------------------------------------------------------------ # Set OpenMP flags for C/C++/Fortran @@ -61,8 +74,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" - "MinSizeRel" "RelWithDebInfo") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Coverage") endif() #------------------------------------------------------------------------------ @@ -84,95 +96,103 @@ list(APPEND LIBS "ccpp") ADD_DEFINITIONS(-DNEMS_GSM) #------------------------------------------------------------------------------ -# Set the sources -set(SOURCES - ./physics/machine.F - ./physics/physcons.f90 - ./physics/funcphys.f90 - ./GFS_layer/GFS_typedefs.F90 - ./physics/radlw_param.f - ./physics/physparam.f - ./physics/radsw_param.f - ./physics/radiation_aerosols.f - ./physics/iounitdef.f - ./physics/gfs_phy_tracer_config.f - ./physics/radiation_clouds.f - ./physics/module_bfmicrophysics.f - ./physics/radiation_gases.f - ./physics/ozne_def.f - ./physics/radiation_surface.f - ./physics//h2o_def.f - ./physics/sfcsub.F - ./physics/mersenne_twister.f - ./physics/rascnvv2.f - ./physics/GFDL_parse_tracers.F90 - ./physics/wam_f107_kp_mod.f90 - ./physics/num_parthds.F - ./physics/gocart_tracer_config_stub.f - ./GFS_layer/GFS_initialize_scm.F90 - ./GFS_layer/GFS_finalize_scm.F90 - ./physics/cldwat2m_micro.F - ./physics/wv_saturation.F - ./physics/aer_cloud.F - ./physics/rad_initialize.f - ./GFS_layer/GFS_radiation_driver.F90 - ./physics/radcons.f90 - ./physics/radiation_astronomy.f - ./physics/radsw_main.f - ./physics/radsw_datatb.f - ./physics/GFS_rrtmg_pre.F90 - ./physics/GFS_rrtmg_post.F90 - ./physics/rrtmg_sw_pre.F90 - ./physics/rrtmg_sw_post.F90 - ./physics/rrtmg_lw_pre.F90 - ./physics/rrtmg_lw_post.F90 - ./physics/radlw_main.f - ./physics/radlw_datatb.f - ./physics/set_soilveg.f - ./physics/namelist_soilveg.f - ./physics/GFS_phys_time_vary.scm.f90 - ./physics/ozinterp.f90 - ./physics/h2ointerp.f90 - ./physics/gcycle.f90 - ./physics/GFS_rad_time_vary.scm.f90 - ./physics/GFS_radupdate.f90 - ./physics/GFS_suite_interstitial.ccpp.f90 - ./physics/get_prs_fv3.f90 - ./physics/sfc_sice.f - ./physics/dcyc2.f - ./physics/GFS_surface_generic.f90 - ./physics/GFS_PBL_generic.f90 - ./physics/sfc_drv.f - ./physics/sflx.f - ./physics/sfc_diff.f - ./physics/GFS_surface_loop_control.f - ./physics/sfc_nst.f - ./physics/date_def.f - ./physics/module_nst_water_prop.f90 - ./physics/module_nst_parameters.f90 - ./physics/module_nst_model.f90 - ./physics/sfc_diag.f - ./physics/moninedmf.f - ./physics/mfpbl.f - ./physics/tridi.f - ./physics/gwdps.f - ./physics/rayleigh_damp.f - ./physics/ozphys.f - ./physics/GFS_DCNV_generic.f90 - ./physics/GFS_zhao_carr_pre.f90 - ./physics/mfdeepcnv.f - ./physics/gwdc.f - ./physics/GFS_SCNV_generic.f90 - ./physics/mfshalcnv.f - ./physics/cnvc90.f - ./physics/GFS_MP_generic_pre.f90 - ./physics/gscond.f - ./physics/precpd.f - ./physics/GFS_calpreciptype.f90 - ./physics/GFS_MP_generic_post.f90 -) +# Set the sources: physics schemes +if (PROJECT MATCHES "CCPP-FV3") + include(./CCPP_SCHEMES.cmake) +else (PROJECT MATCHES "CCPP-FV3") + set(SCHEMES + ./physics/machine.F + ./physics/physcons.f90 + ./physics/funcphys.f90 + ./GFS_layer/GFS_typedefs.F90 + ./physics/radlw_param.f + ./physics/physparam.f + ./physics/radsw_param.f + ./physics/radiation_aerosols.f + ./physics/iounitdef.f + ./physics/gfs_phy_tracer_config.f + ./physics/radiation_clouds.f + ./physics/module_bfmicrophysics.f + ./physics/radiation_gases.f + ./physics/ozne_def.f + ./physics/radiation_surface.f + ./physics//h2o_def.f + ./physics/sfcsub.F + ./physics/mersenne_twister.f + ./physics/rascnvv2.f + ./physics/GFDL_parse_tracers.F90 + ./physics/wam_f107_kp_mod.f90 + ./physics/num_parthds.F + ./physics/gocart_tracer_config_stub.f + ./GFS_layer/GFS_initialize_scm.F90 + ./GFS_layer/GFS_finalize_scm.F90 + ./physics/cldwat2m_micro.F + ./physics/wv_saturation.F + ./physics/aer_cloud.F + ./physics/rad_initialize.f + ./GFS_layer/GFS_radiation_driver.F90 + ./physics/radcons.f90 + ./physics/radiation_astronomy.f + ./physics/radsw_main.f + ./physics/radsw_datatb.f + ./physics/GFS_rrtmg_pre.F90 + ./physics/GFS_rrtmg_post.F90 + ./physics/rrtmg_sw_pre.F90 + ./physics/rrtmg_sw_post.F90 + ./physics/rrtmg_lw_pre.F90 + ./physics/rrtmg_lw_post.F90 + ./physics/radlw_main.f + ./physics/radlw_datatb.f + ./physics/set_soilveg.f + ./physics/namelist_soilveg.f + ./physics/GFS_phys_time_vary.scm.f90 + ./physics/ozinterp.f90 + ./physics/h2ointerp.f90 + ./physics/gcycle.f90 + ./physics/GFS_rad_time_vary.scm.f90 + ./physics/GFS_radupdate.f90 + ./physics/GFS_suite_interstitial.ccpp.f90 + ./physics/get_prs_fv3.f90 + ./physics/sfc_sice.f + ./physics/dcyc2.f + ./physics/GFS_surface_generic.f90 + ./physics/GFS_PBL_generic.f90 + ./physics/sfc_drv.f + ./physics/sflx.f + ./physics/sfc_diff.f + ./physics/GFS_surface_loop_control.f + ./physics/sfc_nst.f + ./physics/date_def.f + ./physics/module_nst_water_prop.f90 + ./physics/module_nst_parameters.f90 + ./physics/module_nst_model.f90 + ./physics/sfc_diag.f + ./physics/moninedmf.f + ./physics/mfpbl.f + ./physics/tridi.f + ./physics/gwdps.f + ./physics/rayleigh_damp.f + ./physics/ozphys.f + ./physics/GFS_DCNV_generic.f90 + ./physics/GFS_zhao_carr_pre.f90 + ./physics/mfdeepcnv.f + ./physics/gwdc.f + ./physics/GFS_SCNV_generic.f90 + ./physics/mfshalcnv.f + ./physics/cnvc90.f + ./physics/GFS_MP_generic_pre.f90 + ./physics/gscond.f + ./physics/precpd.f + ./physics/GFS_calpreciptype.f90 + ./physics/GFS_MP_generic_post.f90 + ) +endif (PROJECT MATCHES "CCPP-FV3") -set(CAPS +# Set the sources: physics scheme caps +if (PROJECT MATCHES "CCPP-FV3") + include(./CCPP_CAPS.cmake) +else (PROJECT MATCHES "CCPP-FV3") + set(CAPS ./physics/cnvc90_cap.F90 ./physics/lsm_noah_pre_cap.F90 ./physics/GFS_DCNV_generic_post_cap.F90 @@ -240,7 +260,8 @@ set(CAPS ./physics/GFS_rrtmg_post_cap.F90 ./physics/get_phi_fv3_cap.F90 ./physics/rrtmg_sw_pre_cap.F90 -) + ) +endif (PROJECT MATCHES "CCPP-FV3") if (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none") @@ -250,11 +271,27 @@ if (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-ffree-line-length-none -fdefault-real-8 -ffree-form") SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F PROPERTIES COMPILE_FLAGS "-fdefault-real-8 -fdefault-double-8") elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel") - SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.f ./physics/sflx.f ./physics/sfc_diff.f ./physics/sfc_diag.f PROPERTIES COMPILE_FLAGS -r8) - SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free") - SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -ftz") - SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-extend-source 132 -r8 -free") - SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F PROPERTIES COMPILE_FLAGS "-r8") + if (PROJECT MATCHES "CCPP-FV3") + SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f + ./physics/rascnvv2.f + ./physics/sflx.f + ./physics/sfc_diff.f + ./physics/sfc_diag.f + ./physics/module_nst_model.f90 + ./physics/GFS_calpreciptype.f90 + ./physics/mersenne_twister.f + ./physics/module_nst_water_prop.f90 + ./physics/aer_cloud.F + ./physics/wv_saturation.F + ./physics/cldwat2m_micro.F + PROPERTIES COMPILE_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -ftz") + else (PROJECT MATCHES "CCPP-FV3") + SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.f ./physics/sflx.f ./physics/sfc_diff.f ./physics/sfc_diag.f PROPERTIES COMPILE_FLAGS -r8) + SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -free") + SET_SOURCE_FILES_PROPERTIES(./physics/mersenne_twister.f PROPERTIES COMPILE_FLAGS "-r8 -ftz") + SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_water_prop.f90 PROPERTIES COMPILE_FLAGS "-extend-source 132 -r8 -free") + SET_SOURCE_FILES_PROPERTIES(./physics/aer_cloud.F ./physics/wv_saturation.F ./physics/cldwat2m_micro.F PROPERTIES COMPILE_FLAGS "-r8") + endif (PROJECT MATCHES "CCPP-FV3") elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") SET_SOURCE_FILES_PROPERTIES(./physics/module_bfmicrophysics.f ./physics/rascnvv2.f ./physics/sflx.f ./physics/sfc_diff.f ./physics/sfc_diag.f PROPERTIES COMPILE_FLAGS -r8) SET_SOURCE_FILES_PROPERTIES(./physics/module_nst_model.f90 ./physics/GFS_calpreciptype.f90 PROPERTIES COMPILE_FLAGS "-r8 -Mfree") @@ -270,36 +307,39 @@ endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU") #apply general fortran tags to all fortran source files if(${CMAKE_VERSION} LESS 3.3) string (REPLACE ";" " " f_flags_str "${f_flags}") - SET_PROPERTY(SOURCE ${SOURCES} ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " ${f_flags_str}") + SET_PROPERTY(SOURCE ${SCHEMES} ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " ${f_flags_str}") else(${CMAKE_VERSION} LESS 3.3) add_compile_options("$<$:${f_flags}>") endif (${CMAKE_VERSION} LESS 3.3) -SET(W3LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../external/w3nco/v2.0.6/src) -SET(BACIOLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../external/bacio/v2.0.1/src) -SET(SPLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../external/sp/v2.0.2/src) +if (PROJECT MATCHES "CCPP-FV3") + link_directories(${NCEPLIBS_DIR}/lib) +# DH this should be a PROJECT == CCPP-SCM and else undefined test (similar in other places) +else (PROJECT MATCHES "CCPP-FV3") + SET(W3LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../external/w3nco/v2.0.6/src) + SET(BACIOLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../external/bacio/v2.0.1/src) + SET(SPLIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../external/sp/v2.0.2/src) -#add "sibling" directories (must specify the build directory too) -ADD_SUBDIRECTORY(${W3LIB_SRC} ${CMAKE_BINARY_DIR}/w3nco) -ADD_SUBDIRECTORY(${BACIOLIB_SRC} ${CMAKE_BINARY_DIR}/bacio) -ADD_SUBDIRECTORY(${SPLIB_SRC} ${CMAKE_BINARY_DIR}/sp) + #add "sibling" directories (must specify the build directory too) + ADD_SUBDIRECTORY(${W3LIB_SRC} ${CMAKE_BINARY_DIR}/w3nco) + ADD_SUBDIRECTORY(${BACIOLIB_SRC} ${CMAKE_BINARY_DIR}/bacio) + ADD_SUBDIRECTORY(${SPLIB_SRC} ${CMAKE_BINARY_DIR}/sp) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/w3nco) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/sp) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/w3nco) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/sp) + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/bacio) + + INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/ccpp-framework/src) +endif (PROJECT MATCHES "CCPP-FV3") #------------------------------------------------------------------------------ -# Add the auto-generated caps -#add_custom_command( -# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scm_cap.f90 -# DEPENDS ${CCPP_MKCAP} -# COMMAND ${CCPP_MKCAP} -o ${CMAKE_CURRENT_BINARY_DIR}/scm_cap.f90 -# ${CMAKE_CURRENT_SOURCE_DIR}/scheme.xml -#) -#list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/scm_test1_cap.f90) -add_library(ccppphys ${SOURCES} ${CAPS}) -target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio) +add_library(ccppphys ${SCHEMES} ${CAPS}) +if (PROJECT MATCHES "CCPP-FV3") + target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} sp_v2.0.2_d bacio_4 w3nco_d) +else (PROJECT MATCHES "CCPP-FV3") + target_link_libraries(ccppphys LINK_PUBLIC ${LIBS} w3 sp bacio) +endif (PROJECT MATCHES "CCPP-FV3") set_target_properties(ccppphys PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} COMPILE_FLAGS "${CMAKE_Fortran_FLAGS}" @@ -319,3 +359,18 @@ add_custom_command(TARGET ccppphys COMMENT "Running pgifix_wrapper.py over all scheme caps") endif (${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI") # *DH end hack for PGI compiler + +if (PROJECT MATCHES "CCPP-FV3") + # Define where to install the library + install(TARGETS ccppphys + EXPORT ccppphys-targets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION lib + ) + # Export our configuration + install(EXPORT ccppphys-targets + FILE ccppphys-config.cmake + DESTINATION lib/cmake + ) +endif (PROJECT MATCHES "CCPP-FV3") diff --git a/makefile b/makefile index 378905f44..4b0c9ffc8 100644 --- a/makefile +++ b/makefile @@ -164,8 +164,7 @@ SRCS_f90 = \ ./physics/ozinterp.f90 \ ./physics/physcons.f90 \ ./physics/radcons.f90 \ - ./physics/wam_f107_kp_mod.f90 \ - ./physics/GFS_debug.f90 + ./physics/wam_f107_kp_mod.f90 SRCS_F = \ ./physics/aer_cloud.F \ @@ -187,6 +186,7 @@ SRCS_F90 = \ ./physics/rrtmg_sw_post.F90 \ ./physics/rrtmg_lw_pre.F90 \ ./physics/rrtmg_lw_post.F90 \ + ./physics/GFS_debug.F90 \ $(GFS_PHYSICS_DRIVER) \ $(GFS_RADIATION_DRIVER) \ ./GFS_layer/GFS_restart.F90 \ diff --git a/physics/FV3_test.F90 b/physics/FV3_test.F90 new file mode 100644 index 000000000..8201787f0 --- /dev/null +++ b/physics/FV3_test.F90 @@ -0,0 +1,94 @@ +!> \file FV3_test.F90 + + module FV3_test + + private + + public FV3_test_init, FV3_test_run, FV3_test_finalize + + contains + +!> \section arg_table_FV3_test_init Argument Table +!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional | +!! |------------|----------------------------|------------------------------------------------|-------|------|-----------|-----------|--------|----------| +!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F | +!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F | +!! + subroutine FV3_test_init (errmsg, errflg) + + implicit none + + !--- interface variables + character(len=*), intent(inout) :: errmsg + integer, intent( out) :: errflg + + ! Initialize CCPP error handling variables + errmsg = '' + errflg = 0 + + end subroutine FV3_test_init + +!> \section arg_table_FV3_test_finalize Argument Table +!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional | +!! |------------|----------------------------|------------------------------------------------|-------|------|-----------|-----------|--------|----------| +!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F | +!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F | +!! + subroutine FV3_test_finalize (errmsg, errflg) + + implicit none + + !--- interface variables + character(len=*), intent( out) :: errmsg + integer, intent( out) :: errflg + + ! Initialize CCPP error handling variables + errmsg = '' + errflg = 0 + + end subroutine FV3_test_finalize + +!> \section arg_table_FV3_test_run Argument Table +!! | local_name | standard_name | long_name | units | rank | type | kind | intent | optional | +!! |------------|----------------------------|------------------------------------------------|-------|------|-----------|-----------|--------|----------| +!! | mpirank | mpi_rank | current MPI-rank | index | 0 | integer | | in | F | +!! | dummy | FV3_ccpp_integration_dummy | dummy variable to test CCPP integration in FV3 | none | 0 | integer | | inout | F | +!! | errmsg | error_message | error message for error handling in CCPP | none | 0 | character | len=* | out | F | +!! | errflg | error_flag | error flag for error handling in CCPP | flag | 0 | integer | | out | F | +!! + subroutine FV3_test_run (mpirank, dummy, errmsg, errflg) + +#ifdef OPENMP + use omp_lib +#endif + + implicit none + + !--- interface variables + integer, intent(in) :: mpirank + integer, intent(inout) :: dummy + character(len=*), intent(inout) :: errmsg + integer, intent( out) :: errflg + + !--- local variables + integer :: ompthread + + ! Initialize CCPP error handling variables + errmsg = '' + errflg = 0 + +#ifdef OPENMP + ompthread = OMP_GET_THREAD_NUM() +#else + ompthread = 0 +#endif + + dummy = dummy + ((mpirank+1)*10) + (ompthread+1) + + if (mpirank==0 .and. ompthread==0) then + write(0,'(a,i0)') 'Called FV3_test_run and set dummy=', dummy + end if + + end subroutine FV3_test_run + + end module FV3_test diff --git a/physics/GFS_debug.f90 b/physics/GFS_debug.F90 similarity index 95% rename from physics/GFS_debug.f90 rename to physics/GFS_debug.F90 index c42802be0..7844e98ad 100644 --- a/physics/GFS_debug.f90 +++ b/physics/GFS_debug.F90 @@ -1,5 +1,4 @@ -!> \file GFS_debug.f90 -!! Contains code previously in GFS_diagtoscreen_driver. +!> \file GFS_debug.F90 module GFS_diagtoscreen @@ -50,8 +49,12 @@ subroutine GFS_diagtoscreen_run (Model, Statein, Stateout, Sfcprop, Coupling, & Grid, Tbd, Cldprop, Radtend, Diag, Interstitial, & errmsg, errflg) +#ifdef MPI use mpi +#endif +#ifdef OPENMP use omp_lib +#endif use machine, only: kind_phys use GFS_typedefs, only: GFS_control_type, GFS_statein_type, & GFS_stateout_type, GFS_sfcprop_type, & @@ -86,13 +89,27 @@ subroutine GFS_diagtoscreen_run (Model, Statein, Stateout, Sfcprop, Coupling, & errmsg = '' errflg = 0 +#ifdef MPI call MPI_COMM_RANK(MPI_COMM_WORLD, mpirank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, mpisize, ierr) +#else + mpirank = 0 + mpisize = 1 +#endif +#ifdef OPENMP omprank = OMP_GET_THREAD_NUM() ompsize = OMP_GET_NUM_THREADS() +#else + omprank = 0 + ompsize = 1 +#endif +#ifdef OPENMP !$OMP BARRIER +#endif +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif do impi=0,mpisize-1 do iomp=0,ompsize-1 @@ -121,13 +138,21 @@ subroutine GFS_diagtoscreen_run (Model, Statein, Stateout, Sfcprop, Coupling, & call print_var(mpirank,omprank,Tbd%blkno, 'Tbd%htsw0', Tbd%htsw0) call print_var(mpirank,omprank,Tbd%blkno, 'Model%sec', Model%sec) end if +#ifdef OPENMP !$OMP BARRIER +#endif end do - call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#ifdef MPI + call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif end do +#ifdef OPENMP !$OMP BARRIER +#endif +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif end subroutine GFS_diagtoscreen_run @@ -255,8 +280,12 @@ subroutine GFS_interstitialtoscreen_run (Model, Statein, Stateout, Sfcprop, Coup Grid, Tbd, Cldprop, Radtend, Diag, Interstitial, & errmsg, errflg) +#ifdef MPI use mpi +#endif +#ifdef OPENMP use omp_lib +#endif use machine, only: kind_phys use GFS_typedefs, only: GFS_control_type, GFS_statein_type, & GFS_stateout_type, GFS_sfcprop_type, & @@ -291,26 +320,48 @@ subroutine GFS_interstitialtoscreen_run (Model, Statein, Stateout, Sfcprop, Coup errmsg = '' errflg = 0 +#ifdef MPI call MPI_COMM_RANK(MPI_COMM_WORLD, mpirank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, mpisize, ierr) +#else + mpirank = 0 + mpisize = 1 +#endif +#ifdef OPENMP omprank = OMP_GET_THREAD_NUM() ompsize = OMP_GET_NUM_THREADS() +#else + omprank = 0 + ompsize = 1 +#endif +#ifdef OPENMP !$OMP BARRIER +#endif +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif do impi=0,mpisize-1 do iomp=0,ompsize-1 if (mpirank==impi .and. omprank==iomp) then call Interstitial%mprint(mpirank,omprank,Tbd%blkno) end if +#ifdef OPENMP !$OMP BARRIER +#endif end do - call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#ifdef MPI + call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif end do +#ifdef OPENMP !$OMP BARRIER +#endif +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif end subroutine GFS_interstitialtoscreen_run @@ -340,8 +391,12 @@ end subroutine GFS_barrier_finalize !! subroutine GFS_barrier_run (Model, errmsg, errflg) +#ifdef MPI use mpi +#endif +#ifdef OPENMP use omp_lib +#endif use machine, only: kind_phys use GFS_typedefs, only: GFS_control_type @@ -361,17 +416,32 @@ subroutine GFS_barrier_run (Model, errmsg, errflg) errmsg = '' errflg = 0 +#ifdef MPI call MPI_COMM_RANK(MPI_COMM_WORLD, mpirank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, mpisize, ierr) +#else + mpirank = 0 + mpisize = 1 +#endif +#ifdef OPENMP omprank = OMP_GET_THREAD_NUM() ompsize = OMP_GET_NUM_THREADS() +#else + omprank = 0 + ompsize = 1 +#endif +#ifdef OPENMP !$OMP BARRIER +#endif +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) +#endif ! Keep this for flushing output to disk call sleep(1) +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) -!$OMP BARRIER +#endif end subroutine GFS_barrier_run @@ -400,8 +470,12 @@ end subroutine GFS_abort_finalize !! subroutine GFS_abort_run (Model, errmsg, errflg) +#ifdef MPI use mpi +#endif +#ifdef OPENMP use omp_lib +#endif use machine, only: kind_phys use GFS_typedefs, only: GFS_control_type @@ -421,16 +495,30 @@ subroutine GFS_abort_run (Model, errmsg, errflg) errmsg = '' errflg = 0 +#ifdef MPI call MPI_COMM_RANK(MPI_COMM_WORLD, mpirank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, mpisize, ierr) +#else + mpirank = 0 + mpisize = 1 +#endif +#ifdef OPENMP omprank = OMP_GET_THREAD_NUM() ompsize = OMP_GET_NUM_THREADS() +#else + omprank = 0 + ompsize = 1 +#endif errflg = 1 errmsg = 'Abort requested by user in GFS_abort_run' + +#ifdef OPENMP !$OMP BARRIER +#endif +#ifdef MPI call MPI_BARRIER(MPI_COMM_WORLD,ierr) -!$OMP BARRIER +#endif end subroutine GFS_abort_run