Bare-Ground
- BareGroundFluxes
model
land_surface
clm
CLM bare-ground turbulent-flux component: the pointwise laws of BareGroundFluxes in src/biogeophys/BareGroundFluxesMod.F90 of CTSM ctsm5.4.063 (the CESM3.0 alpha-branch land model; F90 line numbers below refer to that tag) transcribed exactly, with the expression templates of ./clm_templates.esm imported by reference. The traced configuration (the lnd_in namelist of the I2000Clm60Sp reference case): z0param_method = 'Meier2022', use_z0m_snowmelt = .true. (so z0mg comes from the snowmelt-dependent branch of SetRoughnessLengthsAndForcHeightsNonLake, FrictionVelocityMod.F90:620-623), zetamaxstable = 2.0, soil_resis_method = 1 (the Swenson & Lawrence 2014 soil-resistance branch, inactive on the pinned rows because they are all dew rows with dqh > 0), do_soilevap_beta inactive, GSWP3 forcing heights 30 m, wind_min = 1.0 m/s and the Meier2022 constants of the ctsm60_params.c260518.nc parameter file. Structure, in the order of the Fortran: (a) the raw inputs (forc_t/forc_q/forc_u/forc_v/forc_pbot/forc_rho, thm, t_grnd, qg, the ground-layer temperatures t_soisno_top = t_soisno(c,snl+1)/t_soisno_soil = t_soisno(c,1)/t_h2osfc, the surface-humidity fields qg_snow/qg_soil/qg_h2osfc and dqgdT, thv, and the constants); (b) the derived inputs of F90:318-322 (ur = max(wind_min, |forc_u,forc_v|), dth, dqh, dthv, zldis = forc_hgt_u + z0mg) with forc_th = thv/(1 + 0.61*forc_q) recovered from the dumped virtual potential temperature (dthv = dth*(1 + 0.61*forc_q) + 0.61*forc_th*dqh of F90:328 then inverts to forc_th = thv/(1 + 0.61*forc_q)); (c) z0mg from the Meier2022 snowmelt template (the traced rows are all in the frac_sno_albedo > 0, snomelt_accum < 1e-5 branch, pinning z0mg = exp(-b1*pi/2 + b4)*1e-3 = 8.13402050576016129e-05; the bare-soil zlnd branch of the select case is included for completeness); (d) the MoninObukIni initialization of F90:331 (um_ini, rib, zeta_ini clamped to [0.01, 2.0], obu_ini = zldis/zeta_ini); (e) the stability iteration of F90:342-388. The esm has no loop construct, so the iteration is represented compositionally: the 17-equation update law is authored ONCE in the one-step model BareGroundStep of ./clm_bareground_step.esm (a single pass of the do-while: the FrictionVelocity profiles and friction velocity, the Meier2022 z0hg update, the stability-parameter clamp and the um/wc/obu update) and mounted three times by reference as top-level models step1..step3 (esm-spec section 4.7; top-level mounts are required because the Rust CLI silently drops couplings in the single-top-level-model build path, see README.md), with the chained inputs coupled by the 66 variable_map edges of the ./clm_bareground_steps_coupling.esm coupling library (imported by reference): um_ini/obu_ini/z0mg seed step1, each step's state feeds the next (um/obu/z0h), and the update-invariant pointwise fields (forc_hgt_u, forc_hgt_t, z0m = z0mg, ur, dth, dqh, forc_q, forc_th, thv, zii, beta, zetamaxstable and the constants vkc/grav/zetam/zetat/meier_param3/nu_param/beta_param) feed every step; the parent's zldis equals the step's own profile height zldis_u (z0mg is iteration-constant) and the Fortran's stale wc local is only read by the unstable um branch, so the zldis and wc couplings are dropped as dead. The parent keeps the external names of the Fortran locals: ustar/temp1/temp2/temp12m/temp22m/z0h/um = the step3 outputs (the exit state of the 3-iteration loop, which matches the traced run's niters = 3). The 2-m humidity profiles are the equality branches temp2 = temp1 and temp22m = temp12m (F90:997-998, 1051-1052) because forc_hgt_q_patch == forc_hgt_t_patch and z0qg == z0hg in the traced run. (f) the flux laws of F90:400-476: ram/rah/raw, raih = forc_rho*cpair/rah, the vapor pressure forc_e = max(forc_q*forc_pbot/(forc_q + 0.622), 0.01*forc_esat) with forc_esat from the QSat polynomial, the Magnus dewpoint forc_dewpoint of F90:548-578 (ice coefficients on all traced rows: t_grnd ~ 234-250 K < tfrz selects the ice branch), the raiw selection of F90:423-442 (the dqh > 0 dew branch with the t_grnd > forc_dewpoint no-dew gate, the sl14/beta branches of the dqh <= 0 side transcribed for completeness), ram1, cgrnds/cgrndl/cgrnd (cgrnd = cgrnds + htvp*cgrndl, F90:450, where htvp is the column latent heat chosen by BiogeophysPreFluxCalcsMod.F90:353-357: hsub = SHR_CONST_LATSUB = 2.8347e6 J/kg when the top layer snl+1 holds ice and no liquid, else hvap = 2.501e6 J/kg; every traced row has a dry snow top layer, so htvp = hsub), taux/tauy (the wind_stress_component law), the sensible heat partition eflx_sh_grnd/soil/snow/h2osfc and the evaporation qflx_evap_soi and qflx_ev_snow/soil/h2osfc (one law: the aerodynamic_surface_flux template, flux = -resistance*(atmosphere - surface); qg_h2osfc is not dumped, so qflx_ev_h2osfc is transcribed but unpinned), and the 2-m diagnostics t_ref2m/q_ref2m/rh_ref2m (the ref2m_profile law, with qsat_ref2m from the shared qsat_qs) and kbm1 = log(z0mg/z0h) (F90:478-495). The tests pin the reference dumps: a CESM3 / CTSM ctsm5.4.063 I2000Clm60Sp land-only run (GSWP3 forcing, dtime = 1800 s) instrumented with write statements at the BareGroundFluxes exit, recording the inputs and outputs of the first 16 bare, deep-snowpack patches over the first 12 steps in full double precision: five of the 192 dumped rows (one per step/column regime, see README.md), asserting every dumped output column plus z0mg and cgrnd (cgrnd from the ComputeGroundHeatFluxAndDeriv dump of the same run). Tested regime: every one of the 192 dumped rows is stable (dthv > 0; the iteration zeta clamped at zetamaxstable = 2.0, so the momentum/heat profiles take the zeta > 1 branch and the 2-m profiles the 0 < zeta <= 1 branch), in the dew branch (dqh > 0, raiw = forc_rho/raw), below freezing (ice dewpoint coefficients), fully snow covered (frac_sno_albedo = 1, snomelt_accum = 0) and has forc_u == forc_v. The unstable branches (zeta < 0 and zeta < -zetam/-zetat), the evaporating dqh <= 0 branches (sl14 soil resistance and soilbeta), the liquid dewpoint branch, the snowmelt/bare-soil z0mg branches and rh_ref2m/kbm1/qflx_ev_h2osfc are transcribed but NOT exercised by any test, because the reference run contains no such rows. Not transcribed (dead or undumped in this configuration): the human-stress indices, the www soil-wetness variable, the rssun/rssha photosynthesis resistances, the u10 diagnostics of FrictionVelocityMod, and the ZengWang2007 z0hg branch (the traced run is Meier2022). Reference: CTSM ctsm5.4.063, src/biogeophys/BareGroundFluxesMod.F90 and FrictionVelocityMod.F90.
- BareGroundStep
model
land_surface
clm
One-step update of the CLM bare-ground stability iteration: a single pass of the do-while of BareGroundFluxes in CTSM ctsm5.4.063 src/biogeophys/BareGroundFluxesMod.F90:342-388 (F90 line numbers below refer to that tag) (the FrictionVelocity call of :344-347 followed by the z0hg update, the stability-parameter update and the Obukhov-length update of :353-387), transcribed exactly and mounted three times by reference in clm_bareground.esm (top-level models.step1..step3, esm-spec section 4.7) so the 17-equation update law is authored once and the unrolled iteration is composed. Inputs are the update-invariant pointwise fields (the wind and temperature measurement heights forc_hgt_u/forc_hgt_t, the momentum roughness z0m = z0mg_patch which is constant across the iteration, the wind speed ur = max(wind_min, |forc_u,forc_v|), the temperature/humidity differences dth/dqh, the forcing specific/potential temperatures forc_q/forc_th, the virtual potential temperature thv, the convective velocity-scale inputs zii/beta, the zetamaxstable stability clamp and the physical constants vkc/grav/zetam/zetat/meier_param3/nu_param/beta_param) and the previous update's state (z0h_prev/obu_prev/um_prev). The iteration height is the step's own momentum profile height zldis_u = forc_hgt_u + z0m, which equals the parent's zldis = forc_hgt_u + z0mg (the redundant coupling is dropped), and the Fortran's stale wc local is computed unconditionally (only read by the unstable um branch; the dead wc threading is dropped). Outputs are the 17 update states (zldis_u = forc_hgt_u + z0m, zldis_t = forc_hgt_t + z0h_prev and zldis_2m = 2 + z0h_prev, the three profile heights of FrictionVelocityMod.F90:850-853, 946-949, 1022-1025; ustar from the four-branch momentum profile F90:857-871; temp1 from the four-branch scalar profile F90:956-970; temp2 = temp1 and temp22m = temp12m by the equality branch F90:997-998 and F90:1051-1052, which holds in the traced run because forc_hgt_q_patch == forc_hgt_t_patch and z0qg == z0hg; temp12m from the 2-m scalar profile F90:1022-1038; tstar = temp1*dth and qstar = temp2*dqh F90:354-355; z0h from the Meier2022 update F90:364; thvstar F90:375 (the virtual_potential_scale law shared with the parent's dthv); zeta_raw F90:376; the sign-preserving stability clamp zeta F90:378-386 (the clamp_zeta law shared with the MoninObukIni initialization); wc F90:383; obu = zldis/zeta F90:387). NaN safety: every branch of an ifelse may be evaluated eagerly by a backend, so the laws the Fortran evaluates only on one branch are written so their unselected branches stay finite - the wc base is clamped at zero (max(base, 0): on the unstable rows where wc is read the base is positive and the value is unchanged; on stable rows the Fortran never evaluates it), and the friction-velocity profile templates clamp the arguments of their unstable-branch logs, fractional powers and stability functions (clm_templates.esm). The expression templates of ./clm_templates.esm are imported by reference.