Skip to content

Commit dc2968f

Browse files
Wsm6 microphysics initial Fortran setup (erf-model#3101)
* add stubs for WSM6 moisture model * wire WSM6 moisture model selection and dispatch * add ERF-tracked WSM6 Fortran shim and isohelper bridge * update WSM6 handoff with tracked shim progress and compare plan * add phase1 WSM6 bridge compare map against physics_mmm * update WSM6 handoff with object-level verification status * wsm6: canonicalize init coefficient setup in ERF shim * wsm6: add transitional run scaffold in ERF Fortran shim * wsm6: port canonical warm-rain and melt tendency blocks * wsm6: add initial cold-collection tendencies in run shim * WSM6: fix C/Fortran bounds contract in bridge * WSM6: add generic Morrison-parity reproduction README * Make.ERF: clarify BL_NO_FORT default behavior * Docs: stop tracking wsm6 deep-dive handoff artifacts * WSM6 Fortran bridge: finalize contract fixes and parity docs * WSM6/Morrison debug + restart consistency instrumentation * Fill state ghosts before moisture Copy_State_to_Micro * WSM6: fix CI unused-function warnings and drop noisy restart fallbacks * WSM6: remove remaining microphysics debug print paths * Morrison: remove microphysics debug print paths --------- Co-authored-by: Ann Almgren <asalmgren@lbl.gov>
1 parent 9fc169d commit dc2968f

19 files changed

Lines changed: 3154 additions & 10 deletions

CMake/BuildERFExe.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ function(build_erf_lib erf_lib_name)
233233
target_compile_definitions(${erf_lib_name} PUBLIC ERF_USE_MORR_FORT)
234234
endif()
235235

236+
if(ERF_ENABLE_WSM6_FORT)
237+
target_sources(${erf_lib_name}
238+
PRIVATE
239+
${SRC_DIR}/Microphysics/WSM6/ERF_module_libmassv.F90
240+
${SRC_DIR}/Microphysics/WSM6/ERF_mp_radar.F90
241+
${SRC_DIR}/Microphysics/WSM6/ERF_module_mp_wsm6.F90
242+
${SRC_DIR}/Microphysics/WSM6/ERF_module_mp_wsm6_isohelper.F90
243+
)
244+
target_compile_definitions(${erf_lib_name} PUBLIC ERF_USE_WSM6_FORT)
245+
endif()
246+
236247
if(ERF_ENABLE_WINDFARM)
237248
target_sources(${erf_lib_name} PRIVATE
238249
${SRC_DIR}/Initialization/ERF_InitWindFarm.cpp
@@ -333,6 +344,9 @@ function(build_erf_lib erf_lib_name)
333344
${SRC_DIR}/Microphysics/Morrison/ERF_AdvanceMorrison.cpp
334345
${SRC_DIR}/Microphysics/Morrison/ERF_UpdateMorrison.cpp
335346
${SRC_DIR}/Microphysics/Morrison/ERF_Morrison_Plot.cpp
347+
${SRC_DIR}/Microphysics/WSM6/ERF_InitWSM6.cpp
348+
${SRC_DIR}/Microphysics/WSM6/ERF_AdvanceWSM6.cpp
349+
${SRC_DIR}/Microphysics/WSM6/ERF_UpdateWSM6.cpp
336350
${SRC_DIR}/Microphysics/SAM/ERF_InitSAM.cpp
337351
${SRC_DIR}/Microphysics/SAM/ERF_CloudSAM.cpp
338352
${SRC_DIR}/Microphysics/SAM/ERF_IceFall.cpp
@@ -436,7 +450,7 @@ function(build_erf_lib erf_lib_name)
436450

437451
if(ERF_ENABLE_MPI)
438452
target_link_libraries(${erf_lib_name} PUBLIC $<$<BOOL:${MPI_CXX_FOUND}>:MPI::MPI_CXX>)
439-
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_NOAHMP)
453+
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_WSM6_FORT OR ERF_ENABLE_NOAHMP)
440454
target_link_libraries(${erf_lib_name} PUBLIC $<$<BOOL:${MPI_CXX_FOUND}>:MPI::MPI_Fortran>)
441455
endif()
442456
endif()
@@ -466,6 +480,7 @@ function(build_erf_lib erf_lib_name)
466480
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/Microphysics/SAM>)
467481
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/Microphysics/Kessler>)
468482
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/Microphysics/Morrison>)
483+
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/Microphysics/WSM6>)
469484
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/Microphysics/SatAdj>)
470485
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/Microphysics/SuperDropletsMoist>)
471486
target_include_directories(${erf_lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/WindFarmParametrization>)

CMake/CrayCompilerDetection.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ else()
9696
endif()
9797

9898
# Find Cray Fortran compiler wrapper (if needed)
99-
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_NOAHMP)
99+
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_WSM6_FORT OR ERF_ENABLE_NOAHMP)
100100
find_program(ERF_CRAY_FC ftn)
101101
if(ERF_CRAY_FC)
102102
set(CMAKE_Fortran_COMPILER "${ERF_CRAY_FC}" CACHE FILEPATH "Fortran compiler")
@@ -351,4 +351,4 @@ if(DEFINED ENV{MPICH_GPU_SUPPORT_ENABLED} AND "$ENV{MPICH_GPU_SUPPORT_ENABLED}"
351351
message(STATUS " CMAKE_CXX_STANDARD_LIBRARIES: ${CMAKE_CXX_STANDARD_LIBRARIES}")
352352
else()
353353
message(STATUS " GPU-aware MPI not enabled")
354-
endif()
354+
endif()

CMake/SetAmrexOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if(ERF_ENABLE_TESTS OR ERF_ENABLE_FCOMPARE)
3030
else()
3131
set(AMReX_PLOTFILE_TOOLS OFF)
3232
endif()
33-
if(ERF_ENABLE_MORR_FORT)
33+
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_WSM6_FORT)
3434
set(AMReX_FORTRAN ON)
3535
endif()
3636
set(AMReX_EB ON)

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ list(APPEND CMAKE_MESSAGE_CONTEXT "ERF")
99
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
1010
include(CrayCompilerDetection)
1111

12-
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_NOAHMP)
12+
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_WSM6_FORT OR ERF_ENABLE_NOAHMP)
1313
project(ERF CXX C Fortran)
1414
else()
1515
project(ERF CXX C)
@@ -149,6 +149,7 @@ option(ERF_ENABLE_NOAHMP "Enable Noah-MP" OFF)
149149

150150
#Other parameterizations
151151
option(ERF_ENABLE_WINDFARM "Enable wind farm parameterizations" OFF)
152+
option(ERF_ENABLE_WSM6_FORT "Enable WSM6 Fortran bridge calls" OFF)
152153

153154
#Option to build tools
154155
option(ERF_ENABLE_TOOLS "Enable building of additional tools" OFF)
@@ -448,7 +449,7 @@ if(ERF_ENABLE_MPI)
448449
# Normal path: Use find_package with QUIET
449450
message(VERBOSE "Using find_package(MPI) for detection")
450451
set(_mpi_comps C CXX)
451-
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_NOAHMP)
452+
if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_WSM6_FORT OR ERF_ENABLE_NOAHMP)
452453
list(APPEND _mpi_comps Fortran)
453454
endif()
454455
message(DEBUG "MPI components: ${_mpi_comps}")

Exec/Make.ERF

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ AMREX_HOME ?= $(ERF_HOME)/Submodules/AMReX
22
EKAT_HOME ?= $(ERF_HOME)/Submodules/ekat/build/install
33
EAMXX_HOME ?= $(ERF_HOME)/external/E3SM/components/eamxx/src
44

5+
# Default is no Fortran build unless an explicit Fortran bridge/model is enabled.
6+
# Keep this TRUE when USE_MORR_FORT and USE_WSM6_FORT are both unset.
7+
BL_NO_FORT = TRUE
58
ifeq ($(USE_MORR_FORT), TRUE)
69
DEFINES += -DERF_USE_MORR_FORT
710
BL_NO_FORT = FALSE
8-
else
9-
BL_NO_FORT = TRUE
11+
endif
12+
ifeq ($(USE_WSM6_FORT), TRUE)
13+
DEFINES += -DERF_USE_WSM6_FORT
14+
BL_NO_FORT = FALSE
1015
endif
1116

1217
ifeq ($(USE_CUDA), TRUE)
@@ -143,6 +148,11 @@ include $(ERF_MOISTURE_MORRISON_DIR)/Make.package
143148
VPATH_LOCATIONS += $(ERF_MOISTURE_MORRISON_DIR)
144149
INCLUDE_LOCATIONS += $(ERF_MOISTURE_MORRISON_DIR)
145150

151+
ERF_MOISTURE_WSM6_DIR = $(ERF_SOURCE_DIR)/Microphysics/WSM6
152+
include $(ERF_MOISTURE_WSM6_DIR)/Make.package
153+
VPATH_LOCATIONS += $(ERF_MOISTURE_WSM6_DIR)
154+
INCLUDE_LOCATIONS += $(ERF_MOISTURE_WSM6_DIR)
155+
146156
ERF_MOISTURE_SATADJ_DIR = $(ERF_SOURCE_DIR)/Microphysics/SatAdj
147157
include $(ERF_MOISTURE_SATADJ_DIR)/Make.package
148158
VPATH_LOCATIONS += $(ERF_MOISTURE_SATADJ_DIR)

Source/DataStructs/ERF_DataStruct.H

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ AMREX_ENUM(MoistureModelType,
7070
);
7171

7272
AMREX_ENUM(MoistureType,
73-
SAM, SAM_NoIce, SAM_NoPrecip_NoIce, Kessler, Kessler_NoRain, SatAdj, Morrison, Morrison_NoIce, SuperDroplets, None
73+
SAM, SAM_NoIce, SAM_NoPrecip_NoIce, Kessler, Kessler_NoRain, SatAdj, Morrison, Morrison_NoIce, WSM6, SuperDroplets, None
7474
);
7575

7676
AMREX_ENUM(WindFarmType,
@@ -158,6 +158,7 @@ struct SolverChoice {
158158
}
159159
pp.query_enum_case_insensitive("moisture_model",moisture_type);
160160
if ( (moisture_type == MoistureType::Morrison) ||
161+
(moisture_type == MoistureType::WSM6) ||
161162
(moisture_type == MoistureType::SAM) ) {
162163
moisture_indices = MoistureComponentIndices(
163164
RhoQ1_comp, // water vapor
@@ -211,6 +212,7 @@ struct SolverChoice {
211212
moisture_type == MoistureType::SAM_NoPrecip_NoIce ||
212213
moisture_type == MoistureType::Morrison ||
213214
moisture_type == MoistureType::Morrison_NoIce ||
215+
moisture_type == MoistureType::WSM6 ||
214216
moisture_type == MoistureType::SatAdj) )
215217
{
216218
for (int i = 0; i <= max_level; ++i) {
@@ -906,6 +908,8 @@ struct SolverChoice {
906908
amrex::Print() << "Moisture Model: Morrison" << std::endl;
907909
} else if (moisture_type == MoistureType::Morrison_NoIce) {
908910
amrex::Print() << "Moisture Model: Morrison_NoIce" << std::endl;
911+
} else if (moisture_type == MoistureType::WSM6) {
912+
amrex::Print() << "Moisture Model: WSM6" << std::endl;
909913
} else if (moisture_type == MoistureType::Kessler) {
910914
amrex::Print() << "Moisture Model: Kessler" << std::endl;
911915
} else if (moisture_type == MoistureType::Kessler_NoRain) {

Source/ERF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,8 @@ ERF::InitData_post ()
18731873
void
18741874
ERF::Interp2DArrays (int lev, const BoxArray& my_ba2d, const DistributionMapping& my_dm)
18751875
{
1876+
if (lev == 0) { return; }
1877+
18761878
if (lon_m[lev-1] && !lon_m[lev]) {
18771879
auto ngv = lon_m[lev-1]->nGrowVect(); ngv[2] = 0;
18781880
lon_m[lev] = std::make_unique<MultiFab>(my_ba2d,my_dm,1,ngv);

Source/IO/ERF_Plotfile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,8 @@ ERF::Write3DPlotFile (int which, PlotFileType plotfile_type, Vector<std::string>
11971197
}
11981198
}
11991199
else if ( (solverChoice.moisture_type == MoistureType::SAM) ||
1200-
(solverChoice.moisture_type == MoistureType::Morrison) )
1200+
(solverChoice.moisture_type == MoistureType::Morrison) ||
1201+
(solverChoice.moisture_type == MoistureType::WSM6) )
12011202
{
12021203
int offset = (solverChoice.moisture_type == MoistureType::Morrison) ? 5 : 0;
12031204
if (containerHasElement(plot_var_names, "rain_accum"))

Source/Microphysics/ERF_EulerianMicrophysics.H

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "ERF_SAM.H"
1010
#include "ERF_Kessler.H"
1111
#include "ERF_Morrison.H"
12+
#include "ERF_WSM6.H"
1213
#include "ERF_SatAdj.H"
1314
#include "ERF_Microphysics.H"
1415

@@ -39,6 +40,8 @@ public:
3940
} else if (a_model_type == MoistureType::Morrison ||
4041
a_model_type == MoistureType::Morrison_NoIce) {
4142
SetModel<Morrison>();
43+
} else if (a_model_type == MoistureType::WSM6) {
44+
SetModel<WSM6>();
4245
} else if (a_model_type == MoistureType::SatAdj) {
4346
SetModel<SatAdj>();
4447
} else if (a_model_type == MoistureType::None) {

Source/Microphysics/ERF_Microphysics.H

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public:
103103
|| (a_moisture_type == MoistureType::SAM_NoPrecip_NoIce)
104104
|| (a_moisture_type == MoistureType::Morrison)
105105
|| (a_moisture_type == MoistureType::Morrison_NoIce)
106+
|| (a_moisture_type == MoistureType::WSM6)
106107
|| (a_moisture_type == MoistureType::Kessler)
107108
|| (a_moisture_type == MoistureType::Kessler_NoRain)
108109
|| (a_moisture_type == MoistureType::SatAdj)

0 commit comments

Comments
 (0)