Skip to content

Commit

Permalink
Merge pull request ESCOMP#2465 from mvdebolskiy/fix/excess-ice-cold-s…
Browse files Browse the repository at this point in the history
…tart

Fix/excess ice cold start
  • Loading branch information
ekluzek authored Aug 2, 2024
2 parents e7626f8 + a8371f7 commit 33daaf8
Show file tree
Hide file tree
Showing 15 changed files with 465 additions and 90 deletions.
79 changes: 71 additions & 8 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1874,10 +1874,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 +2386,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 @@ -4930,13 +4934,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 +4995,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 @@ -5068,6 +5130,7 @@ 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, "zendersoilerod";
Expand Down
5 changes: 4 additions & 1 deletion bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2635,7 +2635,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
12 changes: 12 additions & 0 deletions bld/namelist_files/namelist_definition_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,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
29 changes: 27 additions & 2 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 = 3338;

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 @@ -537,6 +537,21 @@ 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.",
GLC_TWO_WAY_COUPLING=>"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",
GLC_TWO_WAY_COUPLING=>"FALSE",
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",
GLC_TWO_WAY_COUPLING=>"FALSE",
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 @@ -1256,6 +1271,16 @@ 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.",
GLC_TWO_WAY_COUPLING=>"FALSE",
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",
GLC_TWO_WAY_COUPLING=>"FALSE",
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
114 changes: 114 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,118 @@
===============================================================
Tag name: ctsm5.2.018
Originator(s): mvdebolskiy
Date: Fri 02 Aug 2024 09:26:33 AM MDT
One-line Summary: Fix/excess ice cold start

Purpose and description of changes
----------------------------------

Changed the way soil temperature is initialized when excess ice is on and the model starts from cold.

Specific notes

TemperatureType now has a private ReadNL subroutine that reads two new namelist options: excess_ice_coldstart_depth and excess_ice_coldstart_temp which control top depth (higher layers get default initial temperature) and soil temperature for soil layers ONLY in columns where excess ice is present. Other columns get their default soil temperature.

New namelist options belong to a new group "clm_temperature_inparm" with its own logic routine. This is done so in the future hardcoded cold start temperatures can be moved to the namelists. Two namelist tests have been added to check for invalid values logic as well as a test for use_excess_ice_streams logic. use_excess_ice_streams has no default value (due to options for restart) and default value set in the CLMBuildNamelist.pm.

excessicestream_type has been taken out of waterstate_type and its routines are called directly in clm_inst%Init. Checks for UseExcessIceStreams() are still in place in WaterStateType.F90 for double-checking. clm_inst%Init now has a new local variable with excess ice concentration that are read from streams (or zeros if use_excess_ice is false). Arguments for temperature_type%Init and water_type%Init (and children types) have been changed to include this new variable. Fortran unit tests are also updated to account for these new arguments.




Significant changes to scientifically-supported configurations
--------------------------------------------------------------

Does this tag change answers significantly for any of the following physics configurations?
(Details of any changes will be given in the "Answer changes" section below.)

[Put an [X] in the box for any configuration with significant answer changes.]

[ ] clm6_0

[ ] clm5_1

[ ] clm5_0

[ ] ctsm5_0-nwp

[ ] clm4_5


Bugs fixed
----------

List of CTSM issues fixed (include CTSM Issue # and description) [one per line]:
Fixes #2384 -- Cold start temperature init when excess ice is on
Fixes #2373 -- SMS_Lm3_D_Mmpi-serial.1x1_brazil.I2000Clm50FatesCruRsGs.izumi_intel.clm-FatesColdHydro fails

Notes of particular relevance for users
---------------------------------------

Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables):
Added: excess_ice_coldstart_temp and excess_ice_coldstart_depth

Changes made to namelist defaults (e.g., changed parameter values):
Set new namelist items differently when excess ice is on or off

Notes of particular relevance for developers:
---------------------------------------------

Caveats for developers (e.g., code that is duplicated that requires double maintenance):
Note that the coldstart variables are always used even without excess ice or with an finidat file.
InitCold is always called so the variables are always set.

Changes to tests or testing:
New tests for build-namelist unit tester

Testing summary: regular
----------------

[PASS means all tests PASS; OK means tests PASS other than expected fails.]

build-namelist tests (if CLMBuildNamelist.pm has changed):

derecho - PASS (998 are different from baseline)

python testing (if python code has changed; see instructions in python/README.md; document testing done):

derecho - PASS

regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):

derecho ----- OK
izumi ------- OK

any other testing (give details below):

SMS_Lm12.f09_f09_mg17.I1850Clm60Sp.derecho_intel.clm-ExcessIceStartup_output_sp_exice
derecho ---- PASS

Answer changes
--------------

Changes answers relative to baseline:

Summarize any changes to answers, i.e.,
- what code configurations: excess ice on, with coldstart or with finidat file interpolation
- what platforms/compilers: all
- nature of change: different at startup
Different for cold-start and can be different for a few points where the cold-start
values are still used on interpoaltion of an existing finidat file

Tests that compare different to baseline:
ERS_D.f10_f10_mg37.I1850Clm60Sp.izumi_nag.clm-ExcessIceStreams
failed baseline comparison (though answers for default physics configurations have not changed).

Other details
-------------

Pull Requests that document the changes (include PR ids):
(https://github.com/ESCOMP/ctsm/pull)
#2465 -- fix excess ice cold starts

===============================================================
===============================================================
Tag name: ctsm5.2.017
Originator(s): erik (Erik Kluzek,UCAR/TSS,303-497-1326)
Date: Tue 30 Jul 2024 08:39:20 AM MDT
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeSum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Tag Who Date Summary
============================================================================================================================
ctsm5.2.018 mvdebols 08/02/2024 Fix/excess ice cold start
ctsm5.2.017 erik 07/30/2024 Dust emissions control moved to cmeps
ctsm5.2.016 samrabin 07/27/2024 Enable new crop calendars for clm60 compsets
ctsm5.2.015 multiple 07/22/2024 Update submodule tags to pass runoff from cism to rof
Expand Down
Loading

0 comments on commit 33daaf8

Please sign in to comment.