From 324b6d67517478942436290b73b85dbcc7f46780 Mon Sep 17 00:00:00 2001 From: Cheng Li <69489965+chengcli@users.noreply.github.com> Date: Sun, 24 Mar 2024 17:23:07 -0400 Subject: [PATCH] Add RRTMG-SW (#135) - Bind RRTMG-SW to C --- CMakeLists.txt | 5 +- cmake/{ => examples}/bryan.cmake | 0 cmake/{ => examples}/cart3.cmake | 0 cmake/{ => examples}/dam.cmake | 0 cmake/{ => examples}/default.cmake | 0 cmake/{ => examples}/exo2.cmake | 0 cmake/{ => examples}/exo3.cmake | 0 cmake/{ => examples}/hjupiter.cmake | 0 cmake/{ => examples}/hywater.cmake | 0 cmake/{ => examples}/juno.cmake | 0 cmake/{ => examples}/jupiter_crm.cmake | 0 cmake/{ => examples}/ktable_earth.cmake | 0 cmake/{ => examples}/ktable_jup.cmake | 0 cmake/{ => examples}/mars_far_ir.cmake | 0 cmake/{ => examples}/polar3.cmake | 0 cmake/examples/rcemip.cmake | 9 ++ cmake/{ => examples}/robert.cmake | 0 cmake/{ => examples}/saturn_radio.cmake | 0 cmake/{ => examples}/straka.cmake | 0 cmake/{ => examples}/uranus_ir.cmake | 0 cmake/{ => examples}/uranus_mwr.cmake | 0 cmake/{ => examples}/vortex.cmake | 0 cmake/parameters.cmake | 12 +++ cmake/rrtmg.cmake | 29 ++++++ examples/2024-CLi-RCEMIP/CMakeLists.txt | 11 +++ examples/2024-CLi-RCEMIP/rce_large.inp | 0 examples/2024-CLi-RCEMIP/rce_small.inp | 107 +++++++++++++++++++++ examples/2024-CLi-RCEMIP/rcemip.cpp | 120 ++++++++++++++++++++++++ examples/2024-CLi-RCEMIP/rcemip.yaml | 9 ++ examples/CMakeLists.txt | 4 + src/outputs/output_utils.cpp | 89 ++++++++++++++++++ 31 files changed, 393 insertions(+), 2 deletions(-) rename cmake/{ => examples}/bryan.cmake (100%) rename cmake/{ => examples}/cart3.cmake (100%) rename cmake/{ => examples}/dam.cmake (100%) rename cmake/{ => examples}/default.cmake (100%) rename cmake/{ => examples}/exo2.cmake (100%) rename cmake/{ => examples}/exo3.cmake (100%) rename cmake/{ => examples}/hjupiter.cmake (100%) rename cmake/{ => examples}/hywater.cmake (100%) rename cmake/{ => examples}/juno.cmake (100%) rename cmake/{ => examples}/jupiter_crm.cmake (100%) rename cmake/{ => examples}/ktable_earth.cmake (100%) rename cmake/{ => examples}/ktable_jup.cmake (100%) rename cmake/{ => examples}/mars_far_ir.cmake (100%) rename cmake/{ => examples}/polar3.cmake (100%) create mode 100644 cmake/examples/rcemip.cmake rename cmake/{ => examples}/robert.cmake (100%) rename cmake/{ => examples}/saturn_radio.cmake (100%) rename cmake/{ => examples}/straka.cmake (100%) rename cmake/{ => examples}/uranus_ir.cmake (100%) rename cmake/{ => examples}/uranus_mwr.cmake (100%) rename cmake/{ => examples}/vortex.cmake (100%) create mode 100644 cmake/rrtmg.cmake create mode 100644 examples/2024-CLi-RCEMIP/CMakeLists.txt create mode 100644 examples/2024-CLi-RCEMIP/rce_large.inp create mode 100644 examples/2024-CLi-RCEMIP/rce_small.inp create mode 100644 examples/2024-CLi-RCEMIP/rcemip.cpp create mode 100644 examples/2024-CLi-RCEMIP/rcemip.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index ae5160f7..540f1bb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,10 +33,10 @@ message(STATUS "2. Set up project parameters ...") # load custom task message(STATUS "Load custom task = ${TASK}") if (NOT ${TASK} STREQUAL "") - if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TASK}.cmake) + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples/${TASK}.cmake) message(STATUS "Load custom setting - ${TASK} -") message(STATUS "Include ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TASK}.cmake") - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TASK}.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples/${TASK}.cmake) else() message(FATAL_ERROR "Cannot find custom file cmake/${TASK}.cmake") endif() @@ -59,6 +59,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/athena.cmake) include(${CMAKE_SOURCE_DIR}/cmake/application.cmake) include(${CMAKE_SOURCE_DIR}/cmake/rfm.cmake) include(${CMAKE_SOURCE_DIR}/cmake/disort.cmake) +include(${CMAKE_SOURCE_DIR}/cmake/rrtmg.cmake) include(${CMAKE_SOURCE_DIR}/cmake/pvfmm.cmake) include(${CMAKE_SOURCE_DIR}/cmake/pybind11.cmake) diff --git a/cmake/bryan.cmake b/cmake/examples/bryan.cmake similarity index 100% rename from cmake/bryan.cmake rename to cmake/examples/bryan.cmake diff --git a/cmake/cart3.cmake b/cmake/examples/cart3.cmake similarity index 100% rename from cmake/cart3.cmake rename to cmake/examples/cart3.cmake diff --git a/cmake/dam.cmake b/cmake/examples/dam.cmake similarity index 100% rename from cmake/dam.cmake rename to cmake/examples/dam.cmake diff --git a/cmake/default.cmake b/cmake/examples/default.cmake similarity index 100% rename from cmake/default.cmake rename to cmake/examples/default.cmake diff --git a/cmake/exo2.cmake b/cmake/examples/exo2.cmake similarity index 100% rename from cmake/exo2.cmake rename to cmake/examples/exo2.cmake diff --git a/cmake/exo3.cmake b/cmake/examples/exo3.cmake similarity index 100% rename from cmake/exo3.cmake rename to cmake/examples/exo3.cmake diff --git a/cmake/hjupiter.cmake b/cmake/examples/hjupiter.cmake similarity index 100% rename from cmake/hjupiter.cmake rename to cmake/examples/hjupiter.cmake diff --git a/cmake/hywater.cmake b/cmake/examples/hywater.cmake similarity index 100% rename from cmake/hywater.cmake rename to cmake/examples/hywater.cmake diff --git a/cmake/juno.cmake b/cmake/examples/juno.cmake similarity index 100% rename from cmake/juno.cmake rename to cmake/examples/juno.cmake diff --git a/cmake/jupiter_crm.cmake b/cmake/examples/jupiter_crm.cmake similarity index 100% rename from cmake/jupiter_crm.cmake rename to cmake/examples/jupiter_crm.cmake diff --git a/cmake/ktable_earth.cmake b/cmake/examples/ktable_earth.cmake similarity index 100% rename from cmake/ktable_earth.cmake rename to cmake/examples/ktable_earth.cmake diff --git a/cmake/ktable_jup.cmake b/cmake/examples/ktable_jup.cmake similarity index 100% rename from cmake/ktable_jup.cmake rename to cmake/examples/ktable_jup.cmake diff --git a/cmake/mars_far_ir.cmake b/cmake/examples/mars_far_ir.cmake similarity index 100% rename from cmake/mars_far_ir.cmake rename to cmake/examples/mars_far_ir.cmake diff --git a/cmake/polar3.cmake b/cmake/examples/polar3.cmake similarity index 100% rename from cmake/polar3.cmake rename to cmake/examples/polar3.cmake diff --git a/cmake/examples/rcemip.cmake b/cmake/examples/rcemip.cmake new file mode 100644 index 00000000..458d8f55 --- /dev/null +++ b/cmake/examples/rcemip.cmake @@ -0,0 +1,9 @@ +# configure RCEMIP case +set(NUMBER_GHOST_CELLS 3) +set(NVAPOR 1) +set(NCLOUD 2) +set(NETCDF ON) +set(PNETCDF ON) +set(MPI ON) +set(RRTMG_SW ON) +set(RSOLVER lmars) diff --git a/cmake/robert.cmake b/cmake/examples/robert.cmake similarity index 100% rename from cmake/robert.cmake rename to cmake/examples/robert.cmake diff --git a/cmake/saturn_radio.cmake b/cmake/examples/saturn_radio.cmake similarity index 100% rename from cmake/saturn_radio.cmake rename to cmake/examples/saturn_radio.cmake diff --git a/cmake/straka.cmake b/cmake/examples/straka.cmake similarity index 100% rename from cmake/straka.cmake rename to cmake/examples/straka.cmake diff --git a/cmake/uranus_ir.cmake b/cmake/examples/uranus_ir.cmake similarity index 100% rename from cmake/uranus_ir.cmake rename to cmake/examples/uranus_ir.cmake diff --git a/cmake/uranus_mwr.cmake b/cmake/examples/uranus_mwr.cmake similarity index 100% rename from cmake/uranus_mwr.cmake rename to cmake/examples/uranus_mwr.cmake diff --git a/cmake/vortex.cmake b/cmake/examples/vortex.cmake similarity index 100% rename from cmake/vortex.cmake rename to cmake/examples/vortex.cmake diff --git a/cmake/parameters.cmake b/cmake/parameters.cmake index 22ed030b..d41dad8a 100644 --- a/cmake/parameters.cmake +++ b/cmake/parameters.cmake @@ -95,6 +95,18 @@ else() set(DISORT_OPTION "RT_DISORT") endif() +if(NOT RRTMG_SW OR NOT DEFINED RRTMG_SW) + set(RRTMG_SW_OPTION "NOT_RT_RRTMG_SW") +else() + set(RRTMG_SW_OPTION "RT_RRTMG_SW") +endif() + +if(NOT RRTMG_LW OR NOT DEFINED RRTMG_LW) + set(RRTMG_LW_OPTION "NOT_RT_RRTMG_LW") +else() + set(RRTMG_LW_OPTION "RT_RRTMG_LW") +endif() + if(NOT PVFMM OR NOT DEFINED PVFMM) set(PVFMM_OPTION "DISABLE_PVFMM") else() diff --git a/cmake/rrtmg.cmake b/cmake/rrtmg.cmake new file mode 100644 index 00000000..737a23e0 --- /dev/null +++ b/cmake/rrtmg.cmake @@ -0,0 +1,29 @@ +include(FetchContent) + +set(FETCHCONTENT_QUIET FALSE) + +macro(set_if_empty _variable) + if("${${_variable}}" STREQUAL "") + set(${_variable} ${ARGN}) + endif() +endmacro() + +option(RRTMG_SW "Build RRTMG_SW" OFF) + +if(RRTMG_SW) + FetchContent_Declare( + RRTMG_SW + GIT_REPOSITORY https://github.com/chengcli/RRTMG_SW + GIT_TAG master) + FetchContent_MakeAvailable(RRTMG_SW) +endif() + +option(RRTMG_LW "Build RRTMG_LW" OFF) + +if(RRTMG_LW) + FetchContent_Declare( + RRTMG_LW + GIT_REPOSITORY https://github.com/chengcli/RRTMG_LW + GIT_TAG master) + FetchContent_MakeAvailable(RRTMG_LW) +endif() diff --git a/examples/2024-CLi-RCEMIP/CMakeLists.txt b/examples/2024-CLi-RCEMIP/CMakeLists.txt new file mode 100644 index 00000000..62e1fb22 --- /dev/null +++ b/examples/2024-CLi-RCEMIP/CMakeLists.txt @@ -0,0 +1,11 @@ + +# 1. Compile rcemip + +# 2. Compile hjupiter +setup_problem(rcemip) + +# 2. Copy input files to run directory +file(GLOB inputs *.py *.inp *.yaml) +foreach(input ${inputs}) + execute_process(COMMAND ln -sf ${input} ${CMAKE_BINARY_DIR}/bin/${inp}) +endforeach() diff --git a/examples/2024-CLi-RCEMIP/rce_large.inp b/examples/2024-CLi-RCEMIP/rce_large.inp new file mode 100644 index 00000000..e69de29b diff --git a/examples/2024-CLi-RCEMIP/rce_small.inp b/examples/2024-CLi-RCEMIP/rce_small.inp new file mode 100644 index 00000000..f66e5de3 --- /dev/null +++ b/examples/2024-CLi-RCEMIP/rce_small.inp @@ -0,0 +1,107 @@ + +problem = RCEMPI-1 Small Domain + + +problem_id = rce1_small # problem ID: basename of output filenames + + +file_type = rst +dt = 10.E5 + + +file_type = hst # History data dump +dt = 2.E4 # time increment between outputs + + +file_type = pnetcdf # Netcdf format output +variable = prim # variables to be output +dt = 1.E4 # time increment between outputs + + +file_type = pnetcdf # Netcdf format output +variable = uov # diagnostic variables +dt = 1.E4 # time increment + + +file_type = pnetcdf # Netcdf format output +variable = diag # diagnostic variables +dt = 1.E4 # time increment + +