Skip to content

Commit

Permalink
Remove IPD steps 3 and 5 (ufs-community#224)
Browse files Browse the repository at this point in the history
* Implementation of CCPP timestep_init and timestep_final phases in fv3atm; cleanup work in GFS_typedefs for o3 and h2o physics as a result of the changes to the time vary physics in CCPP
* Use proper index variable for surface wind enhancement due to convection in phy_f2d array in GFS_typedefs.{F90,meta}, move code to clear diagnostic buckets using GFS DDT bound procedures from atmos_model.F90 to CCPP_driver.F90
* First step of cleanup process: remove CCPP preprocessor directives, remove parts of unused IPD code, update cmake build system, Delete IPD source code, Replace IPD DDTs with GFS DDTs, Bugfix in atmos_model.F90; add missing call to GFS_externaldiag_populate, Move contents of gfsphysics/{CCPP_layer,GFS_layer} to ccpp/{data,driver}, entirely deleted IPD typedefs, Rename module GFS_driver to GFS_init
* Fix indentation in ccpp/data/CMakeLists.txt and ccpp/driver/CMakeLists.txt
* Add logic to set DYN32 depending on 32BIT setting
* Pass preprocessor directive GFS_TYPES to dycore to enable use of GFS data types
* Compile GFS_diagnostics.F90 without optimization, this leads to out of memory errors on wcoss_dell_p3
  • Loading branch information
climbfuji authored Jan 14, 2021
1 parent c697af2 commit e763de0
Show file tree
Hide file tree
Showing 27 changed files with 1,049 additions and 3,282 deletions.
114 changes: 51 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,28 @@
if(CCPP)

if(DEBUG)
set(_ccpp_debug_arg "--debug")
endif()
if(DEFINED CCPP_SUITES)
set(_ccpp_suites_arg "--suites=${CCPP_SUITES}")
message("Calling CCPP code generator (ccpp_prebuild.py) for suites ${_ccpp_suites_arg} ...")
else()
message("Calling CCPP code generator (ccpp_prebuild.py) for all available suites ...")
endif()
execute_process(COMMAND ${Python_EXECUTABLE}
"ccpp/framework/scripts/ccpp_prebuild.py"
"--config=ccpp/config/ccpp_prebuild_config.py"
"--builddir=${CMAKE_CURRENT_BINARY_DIR}" ${_ccpp_suites_arg} ${_ccpp_debug_arg}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.out
ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.err
RESULT_VARIABLE RC)
# Check return code from ccpp_prebuild.py
if(NOT RC EQUAL 0)
message(FATAL_ERROR "An error occured while running ccpp_prebuild.py, check ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.{out,err}")
endif()
# this should not be necessary; including CCPP_*.cmake here and passing
# SCHEMES, CAPS and TYPEDEFS via environment variables to CCPP build.
# CCPP should be able to directly include those three .cmake files.
include(${CMAKE_CURRENT_BINARY_DIR}/ccpp/physics/CCPP_SCHEMES.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/ccpp/physics/CCPP_CAPS.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/ccpp/physics/CCPP_TYPEDEFS.cmake)
set(ENV{CCPP_SCHEMES} "${SCHEMES}")
set(ENV{CCPP_CAPS} "${CAPS}")
set(ENV{CCPP_TYPEDEFS} "${TYPEDEFS}")

# Call to CCPP code generator
if(DEBUG)
set(_ccpp_debug_arg "--debug")
endif()
if(DEFINED CCPP_SUITES)
set(_ccpp_suites_arg "--suites=${CCPP_SUITES}")
message("Calling CCPP code generator (ccpp_prebuild.py) for suites ${_ccpp_suites_arg} ...")
else()
message("Calling CCPP code generator (ccpp_prebuild.py) for all available suites ...")
endif()
execute_process(COMMAND ${Python_EXECUTABLE}
"ccpp/framework/scripts/ccpp_prebuild.py"
"--config=ccpp/config/ccpp_prebuild_config.py"
"--builddir=${CMAKE_CURRENT_BINARY_DIR}" ${_ccpp_suites_arg} ${_ccpp_debug_arg}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.out
ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.err
RESULT_VARIABLE RC)
# Check return code from ccpp_prebuild.py
if(NOT RC EQUAL 0)
message(FATAL_ERROR "An error occured while running ccpp_prebuild.py, check ${CMAKE_CURRENT_BINARY_DIR}/ccpp_prebuild.{out,err}")
endif()

add_subdirectory(cpl)
add_subdirectory(gfsphysics)
add_subdirectory(ipd)
add_subdirectory(io)

###############################################################################
Expand Down Expand Up @@ -82,15 +69,12 @@ list(APPEND _fv3dycore_srcs
atmos_cubed_sphere/driver/fvGFS/fv_nggps_diag.F90
atmos_cubed_sphere/driver/fvGFS/atmosphere.F90)

if(NOT CCPP)
list(APPEND _fv3dycore_srcs atmos_cubed_sphere/model/fv_cmp.F90)
endif()

add_library(fv3dycore ${_fv3dycore_srcs})

list(APPEND _fv3dycore_defs_private SPMD
use_WRTCOMP
GFS_PHYS
GFS_TYPES
USE_GFSL63
MOIST_CAPPA
USE_COND)
Expand All @@ -100,13 +84,14 @@ if(MULTI_GASES)
endif()

if(32BIT)
set(DYN32 ON CACHE BOOL "Enable support for 32bit fast physics in CCPP")
list(APPEND _fv3dycore_defs_private OVERLOAD_R4
OVERLOAD_R8)
else()
set(DYN32 OFF CACHE BOOL "Disable support for 32bit fast physics in CCPP")
endif()

if(CCPP)
list(APPEND _fv3dycore_defs_private CCPP)
endif()
list(APPEND _fv3dycore_defs_private CCPP)

if(OpenMP_Fortran_FOUND)
list(APPEND _fv3dycore_defs_private OPENMP)
Expand All @@ -118,32 +103,35 @@ set_property(SOURCE atmos_cubed_sphere/model/fv_mapz.F90 APPEND_STRING PROPERTY
set_target_properties(fv3dycore PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)

target_compile_definitions(fv3dycore PRIVATE "${_fv3dycore_defs_private}")
target_include_directories(fv3dycore PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/atmos_cubed_sphere)
target_include_directories(fv3dycore PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/atmos_cubed_sphere
${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod)
target_include_directories(fv3dycore INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)

target_link_libraries(fv3dycore PUBLIC fms
gfsphysics
ipd
esmf)
if(OpenMP_Fortran_FOUND)
target_link_libraries(fv3dycore PUBLIC OpenMP::OpenMP_Fortran)
endif()

###############################################################################
### ccpp
### CCPP
###############################################################################
if(CCPP)
add_subdirectory(ccpp)
add_subdirectory(ccpp/driver)
add_dependencies(gfsphysics ccpp ccppphys)
add_dependencies(ccppdriver ccpp ccppphys)
add_dependencies(ccppphys ccpp)
target_include_directories(fv3dycore PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/framework/src
${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver)
target_link_libraries(ccppphys PUBLIC sp::sp_d
w3nco::w3nco_d)
endif()

add_subdirectory(ccpp)
add_subdirectory(ccpp/data)
add_subdirectory(ccpp/driver)
add_dependencies(ccppphys ccpp)
add_dependencies(gfsphysics ccpp ccppphys)
add_dependencies(ccppdata ccpp ccppphys gfsphysics)
add_dependencies(ccppdriver ccpp ccppphys ccppdata gfsphysics)
add_dependencies(fv3dycore ccppdriver ccpp ccppphys ccppdata gfsphysics)
target_include_directories(fv3dycore PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/framework/src
${CMAKE_CURRENT_BINARY_DIR}/ccpp/physics
${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver)
target_link_libraries(ccppphys PUBLIC sp::sp_d
w3nco::w3nco_d)

###############################################################################
### stochastic_physics
Expand All @@ -170,13 +158,13 @@ set_target_properties(fv3atm PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT
target_include_directories(fv3atm INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)

if(CCPP)
list(APPEND _fv3atm_defs_private CCPP)
target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod)
set(CCPP_LIBRARIES ccppdriver ccppphys ccpp)
add_dependencies(fv3atm ccppdriver ccppphys ccpp)
target_link_libraries(fv3atm PUBLIC ccppdriver ccppphys ccpp)
endif()
list(APPEND _fv3atm_defs_private CCPP)
target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/physics
${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod)
set(CCPP_LIBRARIES ccppdriver ccppdata ccppphys ccpp)
add_dependencies(fv3atm ccppdriver ccppdata ccppphys ccpp)
target_link_libraries(fv3atm PUBLIC ccppdriver ccppdata ccppphys ccpp)

target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics)
target_compile_definitions(fv3atm PRIVATE "${_fv3atm_defs_private}")

Expand Down Expand Up @@ -205,7 +193,7 @@ endif()
### Install
###############################################################################
install(
TARGETS fv3atm fv3dycore io ipd gfsphysics ${CCPP_LIBRARIES} cpl stochastic_physics stochastic_physics_wrapper
TARGETS fv3atm fv3dycore io gfsphysics ${CCPP_LIBRARIES} cpl stochastic_physics stochastic_physics_wrapper
EXPORT fv3atm-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
Expand Down
Loading

0 comments on commit e763de0

Please sign in to comment.