Skip to content

Commit f64bc23

Browse files
authored
Updates for Noahmp LSM (#2196)
* Add inital interface for NOAH-M * Update NOAH module and the corresponding FindNetCDF cmake recipe * Initial interface for NOAH LSM * Initial interface for NOAH-MP land surface model * Add linker options * Updates to cmake configuration to include NOAH * Update CMakeLists and move Fortran linkage to Noah-MP: * Update .gitmodules * Updates to NOAH-MP interface * Saving some interface work * udpate gitmodules * checkpoint changes for merge * Update Noah-MP submodules to resolve cmake errors * Resolve style errors * Update gmake interface for noahmp and add a dev test * Noah updates * Remove unnecessary header file use * fix whitespace errors * Update interface * Fix segfaults and make the interface concrete * Add documentation for NoahMP * Fix typo in docs * Fix white space errors * Fix AMReX bug * Updates to NOAH-MP build system * Update Noahmp module * Add more changes from Noahmp * Noahmp tweaks * Noahmp LLANDUSE updates * Checkpointing work on working NoahmpIO interfacE * finalizing interface for noahmp * Fuse NOAH Advance MFIter loops together * Update implementation for NOAH * fix call to NoahmpDriverMain * Fixing codespell errors in comments * Fix unused parameter errors in Nullsurf header * Another unused variable bug fix in NullSurf header * Add missing forcings * Some more updates and clean up * fix typo in comment * Noah-MP submodule tweaks * Updates to noahmp interface for reading multiple chunks * updates to make fortran side aware of parallel context * Bug fix * Add namelist and table file to WPS test * Fix codespell errors * remove noahmp input files from WPS_Test for now * Update Noah-MP submodule * Update NOAH-MP submodule again
1 parent 9bf2ede commit f64bc23

File tree

10 files changed

+368
-47
lines changed

10 files changed

+368
-47
lines changed

CMake/BuildERFExe.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function(build_erf_lib erf_lib_name)
5757
if(ERF_ENABLE_NOAH)
5858
target_include_directories(${erf_lib_name} PUBLIC
5959
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Source/LandSurfaceModel/NOAH>
60-
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Submodules/NOAH-MP/drivers/hrldas>)
60+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Submodules/NOAH-MP/drivers/erf>)
6161
target_sources(${erf_lib_name} PRIVATE
6262
${SRC_DIR}/LandSurfaceModel/NOAH/ERF_NOAH.cpp)
6363
target_compile_definitions(${erf_lib_name} PUBLIC ERF_USE_NOAH)

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ endif()
139139

140140
if(ERF_ENABLE_NOAH)
141141
if(ERF_ENABLE_NETCDF)
142-
set(NOAHMP_HOME ${CMAKE_SOURCE_DIR}/Submodules/NOAH-MP)
143-
set(NOAHMP_BIN ${CMAKE_BINARY_DIR}/Submodules/NOAH-MP)
142+
set(NOAHMP_HOME ${CMAKE_SOURCE_DIR}/Submodules/NOAH-MP/drivers/erf)
143+
set(NOAHMP_BIN ${CMAKE_BINARY_DIR}/Submodules/NOAH-MP/drivers/erf)
144144
add_subdirectory(${NOAHMP_HOME} ${NOAHMP_BIN})
145145
else()
146146
message(FATAL_ERROR "Noah-MP requires NetCDF be enabled")

Source/ERF.H

+3-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ public:
339339
const amrex::Real& time);
340340

341341
void advance_lsm (int lev,
342-
amrex::MultiFab& /*cons_in*/,
342+
amrex::MultiFab& cons_in,
343+
amrex::MultiFab& xvel_in,
344+
amrex::MultiFab& yvel_in,
343345
const amrex::Real& dt_advance);
344346

345347
#if defined(ERF_USE_RRTMGP)

Source/LandSurfaceModel/ERF_LandSurface.H

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define ERF_LANDSURFACE_H
33

44
#include <AMReX_PlotFileUtil.H>
5+
#include <AMReX_MultiFabUtil.H>
56

67
#include <ERF_NullSurf.H>
78
#include <ERF_SLM.H>
@@ -47,6 +48,19 @@ public:
4748
m_lsm_model[lev]->Init(cons_in, geom, dt_advance);
4849
}
4950

51+
void
52+
Advance (const int& lev,
53+
amrex::MultiFab& cons_in,
54+
amrex::MultiFab& xvel_in,
55+
amrex::MultiFab& yvel_in,
56+
amrex::MultiFab* hfx3_out,
57+
amrex::MultiFab* qfx3_out,
58+
const amrex::Real& dt_advance,
59+
const int& nstep)
60+
{
61+
m_lsm_model[lev]->Advance(lev, cons_in, xvel_in, yvel_in, hfx3_out, qfx3_out, dt_advance, nstep);
62+
}
63+
5064
void
5165
Advance (const int& lev, const amrex::Real& dt_advance)
5266
{

Source/LandSurfaceModel/NOAH/ERF_NOAH.H

+121-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <AMReX_FArrayBox.H>
99
#include <AMReX_Geometry.H>
1010
#include <AMReX_MultiFabUtil.H>
11+
#include <AMReX_Vector.H>
12+
#include <AMReX_MFIter.H>
1113

1214
#include <ERF_NullSurf.H>
1315
#include <ERF_Constants.H>
@@ -17,24 +19,141 @@
1719
// External include from the noahmp library
1820
#include <NoahmpIO.H>
1921

22+
namespace LsmVar_NOAH {
23+
enum {
24+
// independent variables
25+
theta = 0,
26+
NumVars
27+
};
28+
}
29+
2030
class NOAH : public NullSurf {
31+
32+
using FabPtr = std::shared_ptr<amrex::MultiFab>;
33+
2134
public:
2235
// Constructor
2336
NOAH () {}
2437

2538
// Destructor
2639
virtual ~NOAH () = default;
2740

41+
// Set thermo and grid properties
42+
void
43+
Define (SolverChoice& /*sc*/) override
44+
{
45+
// NOTE: We should parse things from sc here,
46+
// but they are hard coded because this
47+
// is a demonstration for now.
48+
}
49+
2850
// Initialize data structures
2951
void
3052
Init (const amrex::MultiFab& cons_in,
3153
const amrex::Geometry& geom,
3254
const amrex::Real& dt) override;
3355

56+
// Wrapper to do all the updating
57+
void
58+
Advance (const int& lev,
59+
amrex::MultiFab& cons_in,
60+
amrex::MultiFab& xvel_in,
61+
amrex::MultiFab& yvel_in,
62+
amrex::MultiFab* hfx3_out,
63+
amrex::MultiFab* qfx3_out,
64+
const amrex::Real& dt,
65+
const int& nstep) override;
66+
67+
// Get state vars from lsm class
68+
amrex::MultiFab*
69+
Lsm_Data_Ptr (const int& varIdx) override
70+
{
71+
int lsmIdx = LsmVarMap[varIdx];
72+
AMREX_ALWAYS_ASSERT(lsmIdx < NOAH::m_lsm_size && lsmIdx>=0);
73+
return lsm_fab_vars[lsmIdx].get();
74+
}
75+
76+
// Get flux vars from lsm class
77+
amrex::MultiFab*
78+
Lsm_Flux_Ptr (const int& varIdx) override
79+
{
80+
int lsmIdx = LsmVarMap[varIdx];
81+
AMREX_ALWAYS_ASSERT(lsmIdx < NOAH::m_lsm_size && lsmIdx>=0);
82+
return lsm_fab_flux[lsmIdx].get();
83+
}
84+
85+
// Get lsm geometry
86+
amrex::Geometry
87+
Lsm_Geom ( ) override { return m_lsm_geom; }
88+
89+
// Get number of vars lsm class contains
90+
int
91+
Lsm_Data_Size () override { return NOAH::m_lsm_size; }
92+
93+
// Get variable names
94+
std::string
95+
Lsm_VarName (const int& varIdx) override
96+
{
97+
int lsmIdx = LsmVarMap[varIdx];
98+
AMREX_ALWAYS_ASSERT(lsmIdx < NOAH::m_lsm_size && lsmIdx>=0);
99+
return LsmVarName[lsmIdx];
100+
}
101+
34102
private:
103+
// number of lsm variables (theta)
104+
int m_lsm_size = 1;
105+
106+
// LsmVar map (state indices -> LsmVar enum)
107+
amrex::Vector<int> LsmVarMap;
108+
109+
// Lsm varnames
110+
amrex::Vector<std::string> LsmVarName;
111+
112+
// geometry for atmosphere
113+
amrex::Geometry m_geom;
114+
115+
// geometry for lsm
116+
amrex::Geometry m_lsm_geom;
117+
118+
// timestep
119+
amrex::Real m_dt;
120+
121+
// domain klo-1 or lsm khi
122+
int khi_lsm;
123+
124+
// constants
125+
// amrex::Real m_fac_cond;
126+
// amrex::Real m_fac_fus;
127+
// amrex::Real m_fac_sub;
128+
// amrex::Real m_gOcp;
129+
130+
// independent variables
131+
amrex::Array<FabPtr, LsmVar_NOAH::NumVars> lsm_fab_vars;
132+
133+
// flux array for conjugate transfer
134+
amrex::Array<FabPtr, LsmVar_NOAH::NumVars> lsm_fab_flux;
135+
136+
// Vars that should be parsed
137+
// ==========================
138+
// Number of grid points in z
139+
int m_nz_lsm = 30;
140+
141+
// Size of grid spacing in z
142+
amrex::Real m_dz_lsm = 0.1; // 3 [m] below surface
143+
144+
// Specific heat
145+
amrex::Real m_cp_soil = 1.26e6; // [J/m^3 K]
146+
147+
// Conductivity
148+
amrex::Real m_k_soil = 0.2; // dry soil [W/m K]
149+
150+
// Theta Dirichlet value at lowest point below surface
151+
amrex::Real m_theta_dir = 400.0; // [K]
35152

36-
// C++ variable for NoahmpIO type
37-
NoahmpIO_type noahmpio;
153+
// Thermal diffusivity
154+
amrex::Real m_d_soil = m_k_soil / m_cp_soil; // [m^2/s]
38155

156+
// Vector to store NoahmpIO objects at a level
157+
amrex::Vector<NoahmpIO_type> noahmpio_vect;
39158
};
40159
#endif

0 commit comments

Comments
 (0)