-
Notifications
You must be signed in to change notification settings - Fork 5
Reorganize code for MPAS dycore. Isolate FV3 and MPAS pieces. #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
eb63f9f
1301e07
2527c11
927261d
0495c19
587ea55
b4f6463
424e86b
8168a66
aa14843
66bded5
b56c486
64afb90
ee3378b
70b3065
40e014f
5dec7c2
1b2c665
a936459
1aba87c
afb09b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # This is the main CMake file for fv3atm. | ||
| # This is the main CMake file for ufsatm. | ||
| # | ||
| # Dusan Jovic, Alex Richert | ||
| cmake_minimum_required(VERSION 3.19) | ||
|
|
@@ -14,7 +14,12 @@ endif() | |
|
|
||
| # Enable CI build & unit testing: | ||
| if(BUILD_TESTING) | ||
| project(fv3atm VERSION 1.0 LANGUAGES C CXX Fortran) | ||
| if (FV3) | ||
| project(ufsatm_fv3 VERSION 1.0 LANGUAGES C CXX Fortran) | ||
| endif() | ||
| if (MPAS) | ||
| project(ufsatm_mpas VERSION 1.0 LANGUAGES C CXX Fortran) | ||
| endif() | ||
| include(ci/CMakeLists.txt) | ||
| endif() | ||
|
|
||
|
|
@@ -28,29 +33,61 @@ add_subdirectory(ccpp) | |
| ############################################################################### | ||
| ### fv3 dynamical core | ||
| ############################################################################### | ||
|
|
||
| # These ifdefs need to be turned ON in the dycore. | ||
| set(use_WRTCOMP ON) | ||
| set(GFS_PHYS ON) | ||
| set(GFS_TYPES ON) | ||
| set(USE_GFSL63 ON) | ||
| if(MOVING_NEST) | ||
| set(MOVING_NEST ON) | ||
| endif() | ||
| if(HYDRO) | ||
| set(HYDRO ON) | ||
| if (FV3) | ||
| set(DYCORE_TARGET ufsatm_fv3) | ||
| # These ifdefs need to be turned ON in the dycore. | ||
| set(use_WRTCOMP ON) | ||
| set(GFS_PHYS ON) | ||
| set(GFS_TYPES ON) | ||
| set(USE_GFSL63 ON) | ||
| if(MOVING_NEST) | ||
| set(MOVING_NEST ON) | ||
| endif() | ||
| if(HYDRO) | ||
| set(HYDRO ON) | ||
| endif() | ||
| add_subdirectory(fv3/atmos_cubed_sphere) | ||
| target_compile_definitions(fv3 PRIVATE BYPASS_BREED_SLP_INLINE) | ||
| endif() | ||
| add_subdirectory(atmos_cubed_sphere) | ||
| target_compile_definitions(fv3 PRIVATE BYPASS_BREED_SLP_INLINE) | ||
|
|
||
| ############################################################################### | ||
| ### fv3atm | ||
| ### mpas dynamical core | ||
| ############################################################################### | ||
| if (MPAS) | ||
| set(DYCORE_TARGET ufsatm_mpas) | ||
|
|
||
| # Include MPAS Cmake tools. | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/mpas/MPAS-Model/cmake/Functions/MPAS_Functions.cmake) | ||
|
|
||
| # Set any pre-processor directive needed in MPAS dycore. | ||
| get_mpas_version(MPAS_VERSION) | ||
| set(MPAS_ALL_CORES atmosphere) | ||
| set(MPAS_CORES atmosphere CACHE STRING "MPAS cores to build. Options: ${MPAS_ALL_CORES}") | ||
| if(MPAS_CORES MATCHES " ") #Convert strings separated with spaces to CMake list separated with ';' | ||
| string(REPLACE " " ";" MPAS_CORES ${MPAS_CORES}) | ||
| set(MPAS_CORES ${MPAS_CORES} CACHE STRING "MPAS cores to build. Options: ${MPAS_ALL_CORES}" FORCE) | ||
| endif() | ||
| set(DO_MPASDA OFF) | ||
| set(DO_PHYSICS FALSE) | ||
|
|
||
| # Source files for MPAS dynamical core drivers. | ||
| set(MPAS_MAIN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/mpas/ufs_mpas.F90) | ||
| set(MPAS_SUBDRIVER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/mpas/ufs_mpas_subdriver.F90) | ||
|
|
||
| # MPAS NUOPC cap. | ||
| set(MPAS_NUOPC_CAP ${CMAKE_CURRENT_SOURCE_DIR}/mpas/mpas_cap.F90) | ||
|
|
||
| # MPAS dynamical core | ||
| add_subdirectory(mpas) | ||
| endif() | ||
| ############################################################################### | ||
| ### ufsatm | ||
| ############################################################################### | ||
| if(INLINE_POST) | ||
| set(BUILD_POSTEXEC OFF) | ||
| add_subdirectory(upp) | ||
| set(POST_SRC io/post_nems_routines.F90 io/post_fv3.F90) | ||
| list(APPEND _fv3atm_defs_private INLINE_POST) | ||
| list(APPEND _ufsatm_defs_private INLINE_POST) | ||
| endif() | ||
|
|
||
| if(CCPP_32BIT) | ||
|
|
@@ -60,120 +97,140 @@ else() | |
| endif() | ||
|
|
||
| if(NOT PARALLEL_NETCDF) | ||
| list(APPEND _fv3atm_defs_private NO_PARALLEL_NETCDF) | ||
| list(APPEND _ufsatm_defs_private NO_PARALLEL_NETCDF) | ||
| endif() | ||
|
|
||
| if(MOVING_NEST) | ||
| list(APPEND _fv3atm_defs_private MOVING_NEST) | ||
| list(APPEND _ufsatm_defs_private MOVING_NEST) | ||
| if(NOT HYDRO) | ||
| list(APPEND _fv3atm_defs_private MOIST_CAPPA USE_COND) | ||
| list(APPEND _ufsatm_defs_private MOIST_CAPPA USE_COND) | ||
| endif() | ||
|
|
||
| if(DEBUG) | ||
| list(APPEND _fv3atm_defs_private DEBUG) | ||
| list(APPEND _ufsatm_defs_private DEBUG) | ||
| endif() | ||
| if(GFS_PHYS) | ||
| list(APPEND _fv3atm_defs_private GFS_PHYS) | ||
| list(APPEND _ufsatm_defs_private GFS_PHYS) | ||
| endif() | ||
| if(GFS_TYPES) | ||
| list(APPEND _fv3atm_defs_private GFS_TYPES) | ||
| list(APPEND _ufsatm_defs_private GFS_TYPES) | ||
| endif() | ||
| if(USE_GFSL63) | ||
| list(APPEND _fv3atm_defs_private USE_GFSL63) | ||
| list(APPEND _ufsatm_defs_private USE_GFSL63) | ||
| endif() | ||
| if(INTERNAL_FILE_NML) | ||
| list(APPEND _fv3atm_defs_private INTERNAL_FILE_NML) | ||
| list(APPEND _ufsatm_defs_private INTERNAL_FILE_NML) | ||
| endif() | ||
| if(ENABLE_QUAD_PRECISION) | ||
| list(APPEND _fv3atm_defs_private ENABLE_QUAD_PRECISION) | ||
| list(APPEND _ufsatm_defs_private ENABLE_QUAD_PRECISION) | ||
| endif() | ||
| if(32BIT) | ||
| list(APPEND _fv3atm_defs_private OVERLOAD_R4 OVERLOAD_R8) | ||
| list(APPEND _ufsatm_defs_private OVERLOAD_R4 OVERLOAD_R8) | ||
| endif() | ||
|
|
||
| list(APPEND moving_nest_srcs | ||
| moving_nest/bounding_box.F90 | ||
| moving_nest/fv_tracker.F90 | ||
| moving_nest/fv_moving_nest.F90 | ||
| moving_nest/fv_moving_nest_main.F90 | ||
| moving_nest/fv_moving_nest_physics.F90 | ||
| moving_nest/fv_moving_nest_types.F90 | ||
| moving_nest/fv_moving_nest_utils.F90 | ||
| fv3/moving_nest/bounding_box.F90 | ||
| fv3/moving_nest/fv_tracker.F90 | ||
| fv3/moving_nest/fv_moving_nest.F90 | ||
| fv3/moving_nest/fv_moving_nest_main.F90 | ||
| fv3/moving_nest/fv_moving_nest_physics.F90 | ||
| fv3/moving_nest/fv_moving_nest_types.F90 | ||
| fv3/moving_nest/fv_moving_nest_utils.F90 | ||
| ) | ||
|
dustinswales marked this conversation as resolved.
Outdated
|
||
| else() | ||
| list(APPEND moving_nest_srcs "") | ||
| endif() | ||
|
|
||
| add_library(fv3atm | ||
| atmos_model.F90 | ||
| fv3_cap.F90 | ||
| module_fv3_config.F90 | ||
| module_fcst_grid_comp.F90 | ||
| stochastic_physics/stochastic_physics_wrapper.F90 | ||
| cpl/module_block_data.F90 | ||
| cpl/module_cplfields.F90 | ||
| cpl/module_cap_cpl.F90 | ||
| cpl/module_cplscalars.F90 | ||
| io/fv3atm_common_io.F90 | ||
| io/fv3atm_clm_lake_io.F90 | ||
| io/fv3atm_rrfs_sd_io.F90 | ||
| io/fv3atm_sfc_io.F90 | ||
| io/fv3atm_oro_io.F90 | ||
| io/fv3atm_history_io.F90 | ||
| io/fv3atm_restart_io.F90 | ||
| io/module_write_netcdf.F90 | ||
| io/module_write_restart_netcdf.F90 | ||
| io/module_fv3_io_def.F90 | ||
| io/module_write_internal_state.F90 | ||
| io/module_wrt_grid_comp.F90 | ||
| ${moving_nest_srcs} | ||
| ${POST_SRC} | ||
| ) | ||
|
|
||
| add_dependencies(fv3atm fv3 fv3ccpp stochastic_physics) | ||
|
|
||
| list(APPEND _fv3atm_defs_private GFS_PHYS | ||
| if (FV3) | ||
| add_library(${DYCORE_TARGET} | ||
| fv3/atmos_model.F90 | ||
| fv3/fv3_cap.F90 | ||
| fv3/module_fv3_config.F90 | ||
| fv3/module_fcst_grid_comp.F90 | ||
| stochastic_physics/stochastic_physics_wrapper.F90 | ||
| cpl/module_block_data.F90 | ||
| cpl/module_cplfields.F90 | ||
| cpl/module_cap_cpl.F90 | ||
| cpl/module_cplscalars.F90 | ||
| io/fv3atm_common_io.F90 | ||
| io/fv3atm_clm_lake_io.F90 | ||
| io/fv3atm_rrfs_sd_io.F90 | ||
| io/fv3atm_sfc_io.F90 | ||
| io/fv3atm_oro_io.F90 | ||
| io/fv3atm_history_io.F90 | ||
| io/fv3atm_restart_io.F90 | ||
| io/module_write_netcdf.F90 | ||
| io/module_write_restart_netcdf.F90 | ||
| io/module_fv3_io_def.F90 | ||
| io/module_write_internal_state.F90 | ||
| io/module_wrt_grid_comp.F90 | ||
| ${moving_nest_srcs} | ||
| ${POST_SRC} | ||
| ) | ||
| add_dependencies(${DYCORE_TARGET} fv3 fv3ccpp stochastic_physics) | ||
| endif() | ||
|
|
||
| if (MPAS) | ||
| add_library(${DYCORE_TARGET} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming the add_library target
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great point. Giving them unique names will also keep the hope alive of "piggy backing" the other dycore in a diagnostic mode. I will make this change.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @scrasmussen I added new variables for each dycore target, but didn't go as far as implementing them. I need to think about this a bit more. |
||
| ${MPAS_MAIN_SRC} | ||
| ${MPAS_SUBDRIVER_SRC} | ||
| ${MPAS_NUOPC_CAP} | ||
| ) | ||
| add_dependencies(${DYCORE_TARGET} mpas) | ||
| endif() | ||
|
|
||
| list(APPEND _ufsatm_defs_private GFS_PHYS | ||
| INTERNAL_FILE_NML | ||
| use_WRTCOMP) | ||
|
|
||
| target_compile_definitions(fv3atm PRIVATE "${_fv3atm_defs_private}") | ||
|
|
||
| set_target_properties(fv3atm PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) | ||
| target_include_directories(fv3atm INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod> | ||
| $<INSTALL_INTERFACE:mod>) | ||
| target_compile_definitions(${DYCORE_TARGET} PRIVATE "${_ufsatm_defs_private}") | ||
|
|
||
| set_target_properties(${DYCORE_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) | ||
| target_include_directories(${DYCORE_TARGET} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod> | ||
| $<INSTALL_INTERFACE:mod>) | ||
|
|
||
| if(MULTI_GASES) | ||
| list(APPEND _fv3atm_defs_private MULTI_GASES) | ||
| list(APPEND _ufsatm_defs_private MULTI_GASES) | ||
| endif() | ||
|
|
||
| target_link_libraries(fv3atm PUBLIC fv3 | ||
| fv3ccpp | ||
| stochastic_physics | ||
| fms) | ||
| if (FV3) | ||
| target_link_libraries(${DYCORE_TARGET} PUBLIC fv3 | ||
| fv3ccpp | ||
| stochastic_physics | ||
| fms) | ||
| endif() | ||
|
|
||
| if (MPAS) | ||
| target_link_libraries(${DYCORE_TARGET} PUBLIC mpas) | ||
| # mpasccpp | ||
| # stochastic_physics | ||
| # fms) | ||
| endif() | ||
| target_link_libraries(${DYCORE_TARGET} PUBLIC w3emc::w3emc_d | ||
| sp::sp_d | ||
| bacio::bacio_4 | ||
| esmf) | ||
|
|
||
| target_link_libraries(fv3atm PUBLIC w3emc::w3emc_d | ||
| sp::sp_d | ||
| bacio::bacio_4 | ||
| esmf) | ||
|
|
||
| if(INLINE_POST) | ||
| target_link_libraries(fv3atm PUBLIC upp::upp) | ||
| target_link_libraries(${DYCORE_TARGET} PUBLIC upp::upp) | ||
| endif() | ||
|
|
||
| if(OPENMP) | ||
| target_link_libraries(fv3atm PUBLIC OpenMP::OpenMP_Fortran) | ||
| target_link_libraries(${DYCORE_TARGET} PUBLIC OpenMP::OpenMP_Fortran) | ||
| endif() | ||
|
|
||
| ############################################################################### | ||
| ### Install | ||
| ############################################################################### | ||
| install( | ||
| TARGETS fv3atm | ||
| EXPORT fv3atm-config | ||
| TARGETS ${DYCORE_TARGET} | ||
| EXPORT ufsatm-config | ||
| LIBRARY DESTINATION lib | ||
| ARCHIVE DESTINATION lib) | ||
|
|
||
| install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
|
|
||
| install(EXPORT fv3atm-config | ||
| install(EXPORT ufsatm-config | ||
| DESTINATION lib/cmake) | ||
Uh oh!
There was an error while loading. Please reload this page.