Skip to content

Commit

Permalink
Merge remote-tracking branch 'escomp/master' into CLM5_MEGAN_ISOP
Browse files Browse the repository at this point in the history
slevis resolved conflicts:
doc/ChangeLog
doc/ChangeSum
  • Loading branch information
slevis-lmwg committed Aug 12, 2024
2 parents 9dfc55a + 289913e commit cc6e364
Show file tree
Hide file tree
Showing 35 changed files with 2,542 additions and 147 deletions.
111 changes: 100 additions & 11 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ sub process_namelist_inline_logic {
# namelist options for dust emissions
######################################
setup_logic_dust_emis($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref);
setup_logic_prigent_roughness($opts, $nl_flags, $definition, $defaults, $nl);

#################################
# namelist group: megan_emis_nl #
Expand Down Expand Up @@ -1874,10 +1875,15 @@ sub process_namelist_inline_logic {
#########################################
setup_logic_initinterp($opts, $nl_flags, $definition, $defaults, $nl);

###############################
# namelist group: exice_streams #
###############################
setup_logic_exice($opts, $nl_flags, $definition, $defaults, $nl);
#################################
# namelist group: exice_streams #
#################################
setup_logic_exice($opts, $nl_flags, $definition, $defaults, $nl, $physv);

##########################################
# namelist group: clm_temperature_inparm #
##########################################
setup_logic_coldstart_temp($opts,$nl_flags, $definition, $defaults, $nl);
}

#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -2381,7 +2387,6 @@ sub setup_logic_soilstate {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'organic_frac_squared' );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_bedrock',
'use_fates'=>$nl_flags->{'use_fates'}, 'vichydro'=>$nl_flags->{'vichydro'} );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_excess_ice'); # excess ice flag should be read before stream vars

my $var1 = "soil_layerstruct_predefined";
my $var2 = "soil_layerstruct_userdefined";
Expand Down Expand Up @@ -4071,9 +4076,6 @@ sub setup_logic_dust_emis {
"$option is being set, need to change one or the other" );
}
}
if ( $dust_emis_method eq "Leung_2023" ) {
$log->warning("dust_emis_method is Leung_2023 and that option has NOT been brought into CTSM yet");
}
}
# Otherwise make sure dust settings are NOT being set in CLM
} else {
Expand Down Expand Up @@ -4930,13 +4932,31 @@ sub setup_logic_exice {
#
# excess ice streams
#
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;
my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_;
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_excess_ice', 'phys'=>$physv->as_string());
my $use_exice = $nl->get_value( 'use_excess_ice' );
my $use_exice_streams = $nl->get_value( 'use_excess_ice_streams' );
# IF excess ice streams is on
my $finidat = $nl->get_value('finidat');
# If coldstart and use_excess_ice is on:
if ( ( (not defined($use_exice_streams)) && value_is_true($use_exice) ) && string_is_undef_or_empty($finidat) ) {
$nl->set_variable_value('exice_streams', 'use_excess_ice_streams' , '.true.');
$use_exice_streams = '.true.';
# if excess ice is turned off
} elsif ( (not defined($use_exice_streams)) && (not value_is_true($use_exice)) ) {
$use_exice_streams = '.false.';
# Checking for cold clm_start_type and not finidat here since finidat can be not set set in branch/hybrid runs and
# These cases are handled in the restart routines in the model
} elsif ( defined($use_exice_streams) && (not value_is_true($use_exice_streams)) && value_is_true($use_exice) &&
( $nl_flags->{'clm_start_type'} eq "'cold'" || $nl_flags->{'clm_start_type'} eq "'arb_ic'" )) {
$log->fatal_error("use_excess_ice_streams can NOT be FALSE when use_excess_ice is TRUE on the cold start" );
}

# Put use_exice_streams into nl_flags so can be referenced later
$nl_flags->{'use_excice_streams'} = $use_exice_streams;
# If excess ice streams is on
if (defined($use_exice_streams) && value_is_true($use_exice_streams)) {
# Can only be true if excess ice is also on, otherwise fail
if (defined($use_exice) && not value_is_true($use_exice)) {
if ( defined($use_exice) && (not value_is_true($use_exice)) ) {
$log->fatal_error("use_excess_ice_streams can NOT be TRUE when use_excess_ice is FALSE" );
}
# Otherwise if ice streams are off
Expand Down Expand Up @@ -4973,6 +4993,46 @@ sub setup_logic_exice {

} # end exice streams

sub setup_logic_coldstart_temp {

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

# set initial temperatures for excess ice gridcells: needs to be set whether excess ice is on or not

my $use_exice = $nl->get_value( 'use_excess_ice' );
my $finidat = $nl->get_value('finidat');

my @list = ( "excess_ice_coldstart_temp", "excess_ice_coldstart_depth" );

# Only needs to be set by the user if it's a coldstart
if ( ! string_is_undef_or_empty($finidat) ) {
foreach my $var ( @list ) {
my $val = $nl->get_value( $var );
if ( defined($val) ) {
$log->warning("$var only needs to be set if this is a cold-start, although InitCold is always called");
}
}
}

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'excess_ice_coldstart_temp',
'use_excess_ice'=>$use_exice);
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'excess_ice_coldstart_depth',
'use_excess_ice'=>$use_exice);

my $use_exice_streams = $nl_flags->{'use_excice_streams'};
my $exice_cs_temp = $nl->get_value( 'excess_ice_coldstart_temp' );
my $exice_cs_depth = $nl->get_value( 'excess_ice_coldstart_depth' );

if (defined($use_exice_streams) && value_is_true($use_exice_streams)) {
if (defined($exice_cs_depth) && $exice_cs_depth <= 0.0 ) {
$log->fatal_error("excess_ice_coldstart_depth is <= 0.0" );
}
if (defined($exice_cs_temp) && $exice_cs_temp >= 0.0 ) {
$log->fatal_error("excess_ice_coldstart_temp is >= 0.0, no excess ice will be present in this run" );
}
}
}

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

sub setup_logic_z0param {
Expand Down Expand Up @@ -5019,6 +5079,33 @@ sub setup_logic_misc {

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

sub setup_logic_prigent_roughness {
#
# The Prigent roughness stream data set read in if needed
#
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;
my $var = "use_prigent_roughness";
my $dust_emis_method = remove_leading_and_trailing_quotes( $nl->get_value('dust_emis_method') );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var,
'dust_emis_method'=>$dust_emis_method );
my $use_prigent = $nl->get_value($var);
if ( &value_is_true($use_prigent) ) {
if ( $dust_emis_method ne "Leung_2023" ) {
# The Prigent dataset could be used for other purposes
# (such as roughness as in https://github.com/ESCOMP/CTSM/issues/2349)
$log->warning( "$var does NOT need to on without dust_emis_method being Leung_2023, it simply won't be used" );
}
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_prigentroughness' );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_meshfile_prigentroughness' );
} elsif ( $dust_emis_method eq "Leung_2023" ) {
# In the future we WILL allow it to be turned off for testing and Paleo work
# see: https://github.com/ESCOMP/CTSM/issues/2381)
$log->fatal_error("variable \"$var\" MUST be true when Leung_2023 dust emission method is being used" );
}
}

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

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

Expand Down Expand Up @@ -5068,8 +5155,10 @@ sub write_output_files {
push @groups, "lifire_inparm";
push @groups, "ch4finundated";
push @groups, "exice_streams";
push @groups, "clm_temperature_inparm";
push @groups, "soilbgc_decomp";
push @groups, "clm_canopy_inparm";
push @groups, "prigentroughness";
push @groups, "zendersoilerod";
if (remove_leading_and_trailing_quotes($nl->get_value('snow_cover_fraction_method')) eq 'SwensonLawrence2012') {
push @groups, "scf_swenson_lawrence_2012_inparm";
Expand Down
16 changes: 15 additions & 1 deletion bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,17 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c
<stream_meshfile_zendersoilerod dust_emis_method="Zender_2003" zender_soil_erod_source="lnd"
>lnd/clm2/dustemisdata/dust_2x2_ESMFmesh_cdf5_c230730.nc</stream_meshfile_zendersoilerod>

<!-- ========================================= -->
<!-- Defaults for Prigent's roughness data -->
<!-- ========================================= -->

<use_prigent_roughness dust_emis_method="Leung_2023">.true.</use_prigent_roughness>
<use_prigent_roughness >.false.</use_prigent_roughness>
<stream_fldfilename_prigentroughness
>lnd/clm2/dustemisdata/Prigent_2005_roughness_0.25x0.25_cdf5_c240127.nc</stream_fldfilename_prigentroughness>
<stream_meshfile_prigentroughness
>lnd/clm2/dustemisdata/dust_0.25x0.25_ESMFmesh_cdf5_c240222.nc</stream_meshfile_prigentroughness>

<!-- ========================================= -->
<!-- Defaults for different BGC/decomp modes -->
<!-- ========================================= -->
Expand Down Expand Up @@ -2635,7 +2646,10 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c
<!-- ========================================= -->

<use_excess_ice>.false.</use_excess_ice>

<excess_ice_coldstart_temp>-1.0</excess_ice_coldstart_temp>
<excess_ice_coldstart_depth>0.5</excess_ice_coldstart_depth>
<excess_ice_coldstart_temp use_excess_ice=".true.">-3.15</excess_ice_coldstart_temp>
<excess_ice_coldstart_depth use_excess_ice=".true.">0.5</excess_ice_coldstart_depth>
<stream_fldfilename_exice use_excess_ice=".true.">lnd/clm2/paramdata/exice_init_0.125x0.125_c20220516.nc</stream_fldfilename_exice>
<stream_meshfile_exice use_excess_ice=".true.">lnd/clm2/paramdata/exice_init_0.125x0.125_ESMFmesh_cdf5_c20220802.nc</stream_meshfile_exice>
<stream_mapalgo_exice use_excess_ice=".true.">bilinear</stream_mapalgo_exice>
Expand Down
32 changes: 32 additions & 0 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,25 @@ Mapping method from Nitrogen deposition input file to the model resolution
copy = copy using the same indices
</entry>

<!-- ======================================================================================== -->
<!-- Prigent roughness stream -->
<!-- ======================================================================================== -->

<entry id="use_prigent_roughness" type="logical" category="clm_physics"
group="prigentroughness" valid_values="" >
If TRUE use the Prigent roughness dataset
</entry>

<entry id="stream_fldfilename_prigentroughness" type="char*256" category="datasets"
input_pathname="abs" group="prigentroughness" valid_values="" >
Filename of input stream data for aeolian roughness length (from Prigent's roughness dataset)
</entry>

<entry id="stream_meshfile_prigentroughness" type="char*256" category="datasets"
input_pathname="abs" group="prigentroughness" valid_values="" >
mesh filename of input stream data for aeolian roughness length (from Prigent's roughness dataset)
</entry>

<!-- ======================================================================================== -->
<!-- Dust namelist and Zender soil erodibility stream -->
<!-- ======================================================================================== -->
Expand Down Expand Up @@ -1783,6 +1802,7 @@ If true, will ignore the prescribed soilm data for that point and let the model
prescribed data.
</entry>


<!-- ======================================================================================== -->
<!-- lai_streams streams Namelist (when phys = CLM4_5) -->
<!-- ======================================================================================== -->
Expand Down Expand Up @@ -2946,6 +2966,18 @@ use case.)
If TRUE turn on the excess ice physics, (Lee et al., 2014; Cai et al., 2020)
</entry>

<entry id="excess_ice_coldstart_temp" type="real" category="clm_physics"
group="clm_temperature_inparm" >
Initial soil temperature to use for gridcells with excess ice present during a run starting with coldstart (deg C). Value only applys if use_excess_ice is true.
</entry>

<entry id="excess_ice_coldstart_depth" type="real" category="clm_physics"
group="clm_temperature_inparm" >
Soil depth below which initial excess ice concentration will be applied during a run starting with coldstart (m). Value only applys if use_excess_ice is true.
If this is set below depth of the soil depth, only the last soil layer will get excess ice.
</entry>


<entry id="use_excess_ice_streams" type="logical" category="clm_physics"
group="exice_streams" valid_values="" >
If TRUE and use_excess_ice is TRUE, use the excess ice stream to determine the initial values of the excess ice field
Expand Down
36 changes: 30 additions & 6 deletions bld/unit_testers/build-namelist_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile {
#
# Figure out number of tests that will run
#
my $ntests = 3329;
my $ntests = 3339;

if ( defined($opts{'compare'}) ) {
$ntests += 1999;
Expand Down Expand Up @@ -322,7 +322,7 @@ sub cat_and_create_namelistinfile {
"-res 0.9x1.25 -namelist '&a irrigate=.true./'", "-res 0.9x1.25 -verbose", "-res 0.9x1.25 -ssp_rcp SSP2-4.5", "-res 0.9x1.25 -test", "-res 0.9x1.25 -sim_year 1850",
"-res 0.9x1.25 -namelist '&a use_lai_streams=.true.,use_soil_moisture_streams=.true./'",
"-res 0.9x1.25 -namelist '&a use_excess_ice=.true. use_excess_ice_streams=.true./'",
"-res 0.9x1.25 -namelist '&a use_excess_ice=.true. use_excess_ice_streams=.false./'",
"-res 0.9x1.25 --clm_start_type cold -namelist '&a use_excess_ice=.true. use_excess_ice_streams=.true./'",
"-res 0.9x1.25 -use_case 1850_control",
"-res 1x1pt_US-UMB -clm_usr_name 1x1pt_US-UMB -namelist '&a fsurdat=\"/dev/null\"/'",
"-res 1x1_brazil",
Expand Down Expand Up @@ -517,6 +517,10 @@ sub cat_and_create_namelistinfile {
namelst=>"use_crop=.true.",
phys=>"clm4_5",
},
"LeungDust_WO_Prigent" =>{ options=>" -envxml_dir . -bgc sp",
namelst=>"use_prigent_roughness=.false.",
phys=>"clm5_1",
},
"soilm_stream off w file" =>{ options=>"-res 0.9x1.25 -envxml_dir .",
namelst=>"use_soil_moisture_streams = .false.,stream_fldfilename_soilm='file_provided_when_off'",
phys=>"clm5_0",
Expand All @@ -537,6 +541,18 @@ sub cat_and_create_namelistinfile {
namelst=>"use_excess_ice=.true., use_excess_ice_streams = .false.,stream_mapalgo_exice='bilinear'",
phys=>"clm5_0",
},
"coldstart exice on wo stream"=>{ options=>"-res 0.9x1.25 -envxml_dir . --clm_start_type cold",
namelst=>"use_excess_ice=.true., use_excess_ice_streams = .false.",
phys=>"clm6_0",
},
"coldstart exice on bad temp" =>{ options=>"-res 0.9x1.25 -envxml_dir . --clm_start_type cold",
namelst=>"use_excess_ice=.true., use_excess_ice_streams = .true., excess_ice_coldstart_temp=0.0",
phys=>"clm6_0",
},
"coldstart exice on bad depth" =>{ options=>"-res 0.9x1.25 -envxml_dir . --clm_start_type cold",
namelst=>"use_excess_ice=.true., use_excess_ice_streams = .true., excess_ice_coldstart_depth=0.0",
phys=>"clm6_0",
},
"clm50CNDVwtransient" =>{ options=>" -envxml_dir . -use_case 20thC_transient -dynamic_vegetation -res 10x15 -ignore_warnings",
namelst=>"",
phys=>"clm5_0",
Expand Down Expand Up @@ -1220,10 +1236,6 @@ sub cat_and_create_namelistinfile {

my %warntest = (
# Warnings without the -ignore_warnings option given
"dustemisLeung" =>{ options=>"-envxml_dir .",
namelst=>"dust_emis_method = 'Leung_2023'",
phys=>"clm5_1",
},
"coldwfinidat" =>{ options=>"-envxml_dir . -clm_start_type cold",
namelst=>"finidat = 'testfile.nc'",
phys=>"clm5_0",
Expand Down Expand Up @@ -1256,6 +1268,18 @@ sub cat_and_create_namelistinfile {
namelst=>"use_fun=.true.,use_flexiblecn=.false.",
phys=>"clm6_0",
},
"Set coldtemp wo coldstart" =>{ options=>"-envxml_dir . --clm_start_type startup",
namelst=>"use_excess_ice=.true.,excess_ice_coldstart_temp=-10.",
phys=>"clm6_0",
},
"Set colddepth wo coldstart" =>{ options=>"-envxml_dir . --clm_start_type startup",
namelst=>"use_excess_ice=.true.,excess_ice_coldstart_depth=0.5",
phys=>"clm6_0",
},
"PrigentOnWOLeung" =>{ options=>"-envxml_dir . -bgc sp",
namelst=>"use_prigent_roughness=.true.,dust_emis_method='Zender_2003'",
phys=>"clm6_0",
},
"NotNEONbutNEONlightres" =>{ options=>"--res CLM_USRDAT --clm_usr_name regional --envxml_dir . --bgc bgc --light_res 106x174",
namelst=>"fsurdat='build-namelist_test.pl'",
phys=>"clm6_0",
Expand Down
Loading

0 comments on commit cc6e364

Please sign in to comment.