Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 26 additions & 42 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,11 @@ sub process_namelist_inline_logic {
##################################
setup_logic_cropcal_streams($opts, $nl_flags, $definition, $defaults, $nl);

##################################
# namelist group: distparams_streams #
##################################
setup_logic_distparams_streams($opts, $nl_flags, $definition, $defaults, $nl);

##########################################
# namelist group: soil_moisture_streams #
##########################################
Expand Down Expand Up @@ -1893,11 +1898,6 @@ sub process_namelist_inline_logic {
#####################################
setup_logic_canopy($opts, $nl_flags, $definition, $defaults, $nl);

########################################
# namelist group: soilhydrology_inparm #
########################################
setup_logic_hydrology_params($opts, $nl_flags, $definition, $defaults, $nl);

#####################################
# namelist group: irrigation_inparm #
#####################################
Expand Down Expand Up @@ -3354,28 +3354,6 @@ sub setup_logic_supplemental_nitrogen {

#-------------------------------------------------------------------------------

sub setup_logic_hydrology_params {
#
# Logic for hydrology parameters
#
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

my $lower = $nl->get_value( 'lower_boundary_condition' );
my $var = "baseflow_scalar";
if ( $lower == 1 || $lower == 2 ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl,
$var, 'lower_boundary_condition' => $lower );
}
my $val = $nl->get_value( $var );
if ( defined($val) ) {
if ( $lower != 1 && $lower != 2 ) {
$log->fatal_error("baseflow_scalar is only used for lower_boundary_condition of flux or zero-flux");
}
}
}

#-------------------------------------------------------------------------------

sub setup_logic_irrigation_parameters {
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

Expand Down Expand Up @@ -4627,6 +4605,25 @@ sub setup_logic_cropcal_streams {

#-------------------------------------------------------------------------------

sub setup_logic_distparams_streams {
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_distributed_parameters');

# Add defaults if using any crop calendar input files
my $distparams_file = $nl->get_value('stream_fldFileName_distparams') ;
my $mesh_file = $nl->get_value('stream_meshfile_distparams') ;

# User provided an input file but set mesh file to empty
if ( !&string_is_undef_or_empty($distparams_file)) {
if ( &string_is_undef_or_empty($mesh_file) ) {
$log->fatal_error("If providing a spatially distributed parameter file, you must provide stream_meshfile_distparams" );
}
}
}

#-------------------------------------------------------------------------------

sub setup_logic_soilwater_movement {
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

Expand Down Expand Up @@ -4865,19 +4862,6 @@ sub setup_logic_atm_forcing {
}
}
}

foreach $var ("precip_repartition_glc_all_snow_t",
"precip_repartition_glc_all_rain_t",
"precip_repartition_nonglc_all_snow_t",
"precip_repartition_nonglc_all_rain_t") {
if ( &value_is_true($nl->get_value("repartition_rain_snow")) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var);
} else {
if (defined($nl->get_value($var))) {
$log->fatal_error("$var can only be set if repartition_rain_snow is true");
}
}
}
}

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -5427,11 +5411,11 @@ sub write_output_files {

@groups = qw(clm_inparm ndepdyn_nml popd_streams urbantv_streams light_streams
soil_moisture_streams lai_streams atm2lnd_inparm lnd2atm_inparm clm_canopyhydrology_inparm cnphenology
cropcal_streams megan_opts
cropcal_streams megan_opts distparams_streams
clm_soilhydrology_inparm dynamic_subgrid cnvegcarbonstate
finidat_consistency_checks dynpft_consistency_checks
clm_initinterp_inparm century_soilbgcdecompcascade
soilhydrology_inparm luna friction_velocity mineral_nitrogen_dynamics
luna friction_velocity mineral_nitrogen_dynamics
soilwater_movement_inparm rooting_profile_inparm
soil_resis_inparm bgc_shared canopyfluxes_inparm aerosol
clmu_inparm clm_soilstate_inparm clm_nitrogen clm_snowhydrology_inparm hillslope_hydrology_inparm hillslope_properties_inparm
Expand Down
33 changes: 10 additions & 23 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<soil_resis_method >1</soil_resis_method>
<soil_resis_method phys="clm4_5" >0</soil_resis_method>

<!-- Soil hydrology -->
<baseflow_scalar lower_boundary_condition="2">0.001d00</baseflow_scalar>
<baseflow_scalar lower_boundary_condition="1">1.d-2</baseflow_scalar>
<baseflow_scalar phys="clm4_5" lower_boundary_condition="2">1.d-2</baseflow_scalar>

<!-- Friction velocity -->
<zetamaxstable use_biomass_heat_storage=".true." >2.0d00</zetamaxstable>
<zetamaxstable phys="clm4_5" >2.0d00</zetamaxstable>
Expand Down Expand Up @@ -306,20 +301,6 @@ attributes from the config_cache.xml file (with keys converted to upper-case).

<longwave_downscaling_limit>0.5</longwave_downscaling_limit>

<precip_repartition_nonglc_all_snow_t>0.</precip_repartition_nonglc_all_snow_t>
<precip_repartition_nonglc_all_rain_t>2.</precip_repartition_nonglc_all_rain_t>
<!-- For CLM5 and following, we assume rain at somewhat cooler temperatures. The main
motivation is to increase glacier melt, which otherwise is too low in
CESM2. The physical justification is that the 0 - 2 C ramp used elsewhere
makes sense for typical atmospheric profiles; but over glaciers, inversions
are more common, so it is more reasonable to expect rain despite
below-freezing near-surface temperatures. -->
<precip_repartition_glc_all_snow_t >-2.</precip_repartition_glc_all_snow_t>
<precip_repartition_glc_all_rain_t >0.</precip_repartition_glc_all_rain_t>
<!-- For CLM45, we used the same rain-snow partitioning for glaciers as for other landunits -->
<precip_repartition_glc_all_snow_t phys="clm4_5" >0.</precip_repartition_glc_all_snow_t>
<precip_repartition_glc_all_rain_t phys="clm4_5" >2.</precip_repartition_glc_all_rain_t>

<!-- lnd2atm defaults -->
<melt_non_icesheet_ice_runoff >.true.</melt_non_icesheet_ice_runoff>
<melt_non_icesheet_ice_runoff phys="clm4_5" >.false.</melt_non_icesheet_ice_runoff>
Expand Down Expand Up @@ -623,10 +604,10 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- The default filenames are given relative to the root directory
for the CLM2 data in the CESM distribution -->
<!-- Plant function types (relative to {csmdata}) -->
<paramfile phys="clm6_0" >lnd/clm2/paramdata/ctsm60_params.c260204.no_nan_fill.nc</paramfile>
<paramfile phys="clm6_0" lnd_tuning_mode="clm6_0_cam7.0">ctsm60-cam70_params.c260204.nc</paramfile>
<paramfile phys="clm5_0" >lnd/clm2/paramdata/clm50_params.c250311.no_nan_fill.nc</paramfile>
<paramfile phys="clm4_5" >lnd/clm2/paramdata/clm45_params.c250311.no_nan_fill.nc</paramfile>
<paramfile phys="clm6_0" >lnd/clm2/paramdata/ctsm60_params.c260303.nc</paramfile>
<paramfile phys="clm6_0" lnd_tuning_mode="clm6_0_cam7.0">ctsm60-cam70_params.c260305.nc</paramfile>
<paramfile phys="clm5_0" >lnd/clm2/paramdata/clm50_params.c260305.nc</paramfile>
<paramfile phys="clm4_5" >lnd/clm2/paramdata/clm45_params.c260305.nc</paramfile>

<!-- ================================================================== -->
<!-- FATES default parameter file -->
Expand Down Expand Up @@ -2322,6 +2303,12 @@ lnd/clm2/surfdata_esmf/NEON/ctsm5.4.0/surfdata_1x1_NEON_TOOL_hist_2000_78pfts_c2
<stream_fldFileName_gdd20_season_end stream_gdd20_seasons=".true.">lnd/clm2/cropdata/calendars/processed/hdates_ggcmi_crop_calendar_phase3_v1.01_nninterp-hcru_hcru_mt13.2000-2000.20230728_165845.tweaked_latlons.no_nan_fill.nc</stream_fldFileName_gdd20_season_end>
<stream_meshfile_cropcal cropcals_rx_adapt=".true.">lnd/clm2/cropdata/calendars/processed/360x720_120830_ESMFmesh_c20210507_cdf5.tweaked_latlons.no_nan_fill.nc</stream_meshfile_cropcal>

<!-- spatially distributed parameters: default settings -->
<use_distributed_parameters>.false.</use_distributed_parameters>

<!-- spatially distributed parameters: default input files -->
<stream_fldFileName_distparams use_distributed_parameters=".true.">no_file_yet</stream_fldFileName_distparams>
<stream_meshfile_distparams use_distributed_parameters=".true.">no_file_yet</stream_meshfile_distparams>

<!-- lightning streams namelist defaults -->

Expand Down
50 changes: 20 additions & 30 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,6 @@ Max number of iterations used in subr. CanopyFluxes. For many years, 40 was the
If TRUE use clm5 equation for fraction of intercepted precipitation
</entry>

<entry id="baseflow_scalar" type="real" category="clm_physics"
group="soilhydrology_inparm" valid_values="" >
Scalar multiplier for base flow rate
(ONLY used if lower_boundary_condition is not aquifer or table)
</entry>

<entry id="soilwater_movement_method" type="integer" category="clm_physics"
group="soilwater_movement_inparm" valid_values="0,1" >
Index of solution method of Richards equation.
Expand Down Expand Up @@ -1728,30 +1722,6 @@ This parameter must be in the range [0,1]
Only relevant if glcmec_downscale_longwave is .true.
</entry>

<entry id="precip_repartition_glc_all_snow_t" type="real" category="clm_physics"
group="atm2lnd_inparm" valid_values="" >
Temperature below which all precipitation falls as snow, for glacier columns (deg C)
Only relevant if repartition_rain_snow is .true.
</entry>

<entry id="precip_repartition_glc_all_rain_t" type="real" category="clm_physics"
group="atm2lnd_inparm" valid_values="" >
Temperature above which all precipitation falls as rain, for glacier columns (deg C)
Only relevant if repartition_rain_snow is .true.
</entry>

<entry id="precip_repartition_nonglc_all_snow_t" type="real" category="clm_physics"
group="atm2lnd_inparm" valid_values="" >
Temperature below which all precipitation falls as snow, for non-glacier columns (deg C)
Only relevant if repartition_rain_snow is .true.
</entry>

<entry id="precip_repartition_nonglc_all_rain_t" type="real" category="clm_physics"
group="atm2lnd_inparm" valid_values="" >
Temperature above which all precipitation falls as rain, for non-glacier columns (deg C)
Only relevant if repartition_rain_snow is .true.
</entry>

<!-- ======================================================================================== -->
<!-- Namelist items controlling fields sent to atmosphere -->
<!-- ======================================================================================== -->
Expand Down Expand Up @@ -2189,6 +2159,26 @@ Filename of input stream data for date (day of year) of end of gdd20 accumulatio
Filename of input stream data for crop calendar inputs
</entry>

<!-- ======================================================================================== -->
<!-- distparams_streams streams Namelist -->
<!-- ======================================================================================== -->

<!-- Distributed parameters -->
<entry id="use_distributed_parameters" type="logical" category="datasets"
group="distparams_streams" valid_values="" >
Flag to enable spatially distributed parameters
</entry>

<entry id="stream_fldfilename_distparams" type="char*512(30)" category="datasets"
input_pathname="abs" group="distparams_streams" valid_values="" >
Filename of input stream data for spatially distributed parameters
</entry>

<entry id="stream_meshfile_distparams" type="char*512" category="datasets"
input_pathname="abs" group="distparams_streams" valid_values="" >
Filename of mesh data for spatially distributed parameters
</entry>

<!-- ======================================================================================== -->
<!-- light_streams streams Namelist (when CN an CLM4_5 is active) -->
<!-- ======================================================================================== -->
Expand Down
18 changes: 18 additions & 0 deletions cime_config/testdefs/testlist_clm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@
<option name="comment">Simple test to make sure adding obscure stream options works</option>
</options>
</test>
<test name="SMS_Ld5_PS" grid="f09_f09_mt232" compset="IHistClm60Sp" testmods="clm/f09_constant2DDistParams--clm-nofireesmis">
<machines>
<machine name="derecho" compiler="intel" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment">Test that distributed 2D stream parameters works (should be identical to the one with the default testmod)</option>
</options>
</test>
<test name="SMS_Ld5_PS" grid="f09_f09_mt232" compset="IHistClm60Sp" testmods="clm/default--clm-nofireesmis">
<machines>
<machine name="derecho" compiler="intel" category="aux_clm"/>
</machines>
<options>
<option name="wallclock">00:20:00</option>
<option name="comment">Default test to compare the above distributed stream test to</option>
</options>
</test>
<test name="ERI_D_Ld9" grid="f10_f10_mg37" compset="I2000Clm50BgcCru" testmods="clm/default">
<machines>
<machine name="derecho" compiler="gnu" category="aux_clm"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../default
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
! Turn on distributed parameters with values that are just copies of the 1D parameter file
! So tests with this and without distributed parameters should compare exactly
use_distributed_parameters = TRUE
! The distparam file MUST match the model resolution
stream_fldfilename_distparams = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_2Dparamdata_0.9x1.25_distparams_constant_ident2_ctsm60260303params_c260306.nc'
stream_meshfile_distparams = '$LND_DOMAIN_MESH'
5 changes: 3 additions & 2 deletions src/biogeophys/CanopyHydrologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ module CanopyHydrologyMod
use WaterStateBulkType , only : waterstatebulk_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type
use WaterTracerUtils , only : CalcTracerFromBulk
use ColumnType , only : col, column_type
use PatchType , only : patch, patch_type
use ColumnType , only : col, column_type
use PatchType , only : patch, patch_type

!
! !PUBLIC TYPES:
implicit none
Expand Down
9 changes: 6 additions & 3 deletions src/biogeophys/InfiltrationExcessRunoffMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ module InfiltrationExcessRunoffMod
use clm_varcon , only : spval
use SoilHydrologyType, only : soilhydrology_type
use SoilStateType , only : soilstate_type
use DistParamType , only : distparams => distributed_parameters
use SaturatedExcessRunoffMod, only : saturated_excess_runoff_type
use WaterFluxBulkType , only : waterfluxbulk_type
use WaterDiagnosticBulkType, only : waterdiagnosticbulk_type
use WaterFluxBulkType , only : waterfluxbulk_type
use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type

implicit none
save
Expand Down Expand Up @@ -267,6 +268,8 @@ subroutine ComputeQinmaxHksat(bounds, num_hydrologyc, filter_hydrologyc, &
soilhydrology_inst, soilstate_inst, &
qinmax_on_unsaturated_area)
!
! USES
use ColumnType , only : col
! !DESCRIPTION:
! Compute qinmax using a parameterization based on hksat
!
Expand Down Expand Up @@ -296,7 +299,7 @@ subroutine ComputeQinmaxHksat(bounds, num_hydrologyc, filter_hydrologyc, &

do fc = 1, num_hydrologyc
c = filter_hydrologyc(fc)
qinmax_on_unsaturated_area(c) = minval(10._r8**(-params_inst%e_ice*(icefrac(c,1:3)))*hksat(c,1:3))
qinmax_on_unsaturated_area(c) = minval(10._r8**(-distparams%e_ice%param_val(col%gridcell(c))*(icefrac(c,1:3)))*hksat(c,1:3))
end do

end associate
Expand Down
37 changes: 7 additions & 30 deletions src/biogeophys/SaturatedExcessRunoffMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ module SaturatedExcessRunoffMod
use clm_varcon , only : spval,ispval
use LandunitType , only : landunit_type
use landunit_varcon , only : istcrop
use ColumnType , only : column_type
use ColumnType , only : column_type
use DistParamType , only : distparams => distributed_parameters
use SoilHydrologyType, only : soilhydrology_type
use SoilStateType, only : soilstate_type
use SoilStateType , only : soilstate_type
use WaterFluxBulkType, only : waterfluxbulk_type

implicit none
Expand Down Expand Up @@ -50,12 +51,6 @@ module SaturatedExcessRunoffMod
procedure, private, nopass :: ComputeFsatTopmodel
procedure, private, nopass :: ComputeFsatVic
end type saturated_excess_runoff_type
public :: readParams

type, private :: params_type
real(r8) :: fff ! Decay factor for fractional saturated area (1/m)
end type params_type
type(params_type), private :: params_inst

! !PRIVATE DATA MEMBERS:

Expand Down Expand Up @@ -175,26 +170,6 @@ subroutine InitCold(this, bounds)

end subroutine InitCold

!-----------------------------------------------------------------------
subroutine readParams( ncid )
!
! !USES:
use ncdio_pio, only: file_desc_t
use paramUtilMod, only: readNcdioScalar
!
! !ARGUMENTS:
implicit none
type(file_desc_t),intent(inout) :: ncid ! pio netCDF file id
!
! !LOCAL VARIABLES:
character(len=*), parameter :: subname = 'readParams_SaturatedExcessRunoff'
!--------------------------------------------------------------------

! Decay factor for fractional saturated area (1/m)
call readNcdioScalar(ncid, 'fff', subname, params_inst%fff)

end subroutine readParams

! ========================================================================
! Science routines
! ========================================================================
Expand Down Expand Up @@ -315,6 +290,8 @@ end subroutine SaturatedExcessRunoff
subroutine ComputeFsatTopmodel(bounds, num_hydrologyc, filter_hydrologyc, &
soilhydrology_inst, soilstate_inst, fsat)
!
! USES
use ColumnType , only : col
! !DESCRIPTION:
! Compute fsat using the TOPModel-based parameterization
!
Expand Down Expand Up @@ -349,9 +326,9 @@ subroutine ComputeFsatTopmodel(bounds, num_hydrologyc, filter_hydrologyc, &
c = filter_hydrologyc(fc)
if (frost_table(c) > zwt_perched(c) .and. frost_table(c) <= zwt(c)) then
! use perched water table to determine fsat (if present)
fsat(c) = wtfact(c) * exp(-0.5_r8*params_inst%fff*zwt_perched(c))
fsat(c) = wtfact(c) * exp(-0.5_r8*distparams%fff%param_val(col%gridcell(c))*zwt_perched(c))
else
fsat(c) = wtfact(c) * exp(-0.5_r8*params_inst%fff*zwt(c))
fsat(c) = wtfact(c) * exp(-0.5_r8*distparams%fff%param_val(col%gridcell(c))*zwt(c))
end if
end do

Expand Down
Loading