Skip to content

Commit 2c53e0a

Browse files
committed
Merge branch 'multiple_icesheets_evolve'
Support one ice sheet evolving and one not evolving Changes needed to allow a mix of evolving and non-evolving ice sheets in a single run. The primary need for this was moving zero_gcm_fluxes from cism_in into the config file, but I also made some other small changes to support this scenario. I have also added an ERI test of this scenario to make sure that hybrid, branch and restart runs all work when you have a mix of evolving and non-evolving ice sheets. Also some other minor fixes. Resolves #53 (Change handling of some ice sheet-specific variables that are currently in cism_in) Resolves ESCOMP/CISM-warpper#54 (Do some testing with one ice sheet evolving and the other not evolving)
2 parents 31a2c72 + d91e392 commit 2c53e0a

16 files changed

+157
-96
lines changed

ChangeLog

+43
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22
This file describes what tags were created on master and why
33
================================================================================
44

5+
================================================================================
6+
Originator: sacks
7+
Date: December 28, 2021
8+
Version: cismwrap_2_1_95
9+
One-line summary: Support one ice sheet evolving and one not evolving
10+
11+
Purpose of changes:
12+
13+
Changes needed to allow a mix of evolving and non-evolving ice sheets
14+
in a single run. The primary need for this was moving zero_gcm_fluxes
15+
from cism_in into the config file, but I also made some other small
16+
changes to support this scenario. I have also added an ERI test of
17+
this scenario to make sure that hybrid, branch and restart runs all
18+
work when you have a mix of evolving and non-evolving ice sheets.
19+
20+
Also some other minor fixes.
21+
22+
Standalone checkout supported in this tag (Yes/No): Yes
23+
(If yes, this implies that we expect to be able to build and run a
24+
case from a standalone checkout using manage_externals, and for this
25+
to continue to work long-term. The answer may be "No" if the set of
26+
externals pointed to by manage_externals is broken, or if at least
27+
one external points to a temporary branch that is may be deleted in
28+
the near future.)
29+
30+
If No: Notes on externals used for testing:
31+
32+
Changes answers relative to previous tag: NO
33+
34+
Bugs fixed (include github issue number):
35+
36+
Resolves ESCOMP/CISM-wrapper#53 (Change handling of some ice
37+
sheet-specific variables that are currently in cism_in)
38+
39+
Resolves ESCOMP/CISM-warpper#54 (Do some testing with one ice sheet
40+
evolving and the other not evolving)
41+
42+
Summary of testing:
43+
44+
Full aux_glc test suite on cheyenne and izumi.
45+
46+
All tests passed and were bit-for-bit.
47+
548
================================================================================
649
Originator: sacks
750
Date: December 27, 2021

Externals_CISM.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
local_path = source_cism
33
protocol = git
44
repo_url = https://github.com/ESCOMP/cism
5-
tag = cism_main_2.01.010
5+
tag = cism_main_2.01.011
66
required = True
77

88
[externals_description]

cime_config/buildnml

+39-48
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,6 @@ def _icesheet_consistency_checks(case, icesheet_names, glc_grid_names):
284284
expect(found_evolving_icesheet,
285285
"CISM_EVOLVE is TRUE, but no ice sheets are set to evolve")
286286

287-
# TODO(wjs, 2021-02-26) This is a temporary check that we can remove once we resolve
288-
# https://github.com/ESCOMP/CISM-wrapper/issues/54
289-
# For now, ensure that all ice sheets are either evolving or non-evolving (having one
290-
# evolving and one non-evolving is untested)
291-
icesheet_evolution = _is_icesheet_evolving(case, icesheet_names[0])
292-
for icesheet in icesheet_names[1:]:
293-
expect(_is_icesheet_evolving(case, icesheet) == icesheet_evolution,
294-
"For now, ice sheets must either all be evolving or all be non-evolving")
295-
296287
####################################################################################
297288
def _check_compset_grid_consistency(case, icesheet_names, glc_grid_names):
298289
####################################################################################
@@ -383,7 +374,6 @@ def _create_cism_in(case, confdir, inst_string, icesheet_names, infile, nmlgen,
383374
# Note that the cism_evolve value used in cism_in is the overall CISM_EVOLVE, which is
384375
# true if *any* ice sheet is evolving.
385376
config['cism_evolve'] = '.true.' if case.get_value('CISM_EVOLVE') else '.false.'
386-
config['glc_two_way_coupling'] = '.true.' if case.get_value('GLC_TWO_WAY_COUPLING') else '.false.'
387377
config['calendar'] = case.get_value("CALENDAR")
388378

389379
run_type = _get_effective_run_type(case)
@@ -421,8 +411,6 @@ def _create_cism_in(case, confdir, inst_string, icesheet_names, infile, nmlgen,
421411
output_file = os.path.join(confdir, "cism_in")
422412
nmlgen.write_output_file(output_file, data_list_path, groups=groups, sorted_groups=False)
423413

424-
_cism_in_final_consistency_checks(nmlgen, config)
425-
426414
####################################################################################
427415
def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
428416
infile_overall, infile_this_icesheet, nmlgen, data_list_path):
@@ -449,6 +437,10 @@ def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
449437
config['icesheet'] = icesheet
450438
config['glc_grid'] = glc_grid
451439
config['cism_phys'] = case.get_value("CISM_PHYS")
440+
if case.get_value('GLC_TWO_WAY_COUPLING'):
441+
config['glc_two_way_coupling'] = '.true.'
442+
else:
443+
config['glc_two_way_coupling'] = '.false.'
452444
if _is_icesheet_evolving(case, icesheet):
453445
config['cism_evolve_this_icesheet'] = '.true.'
454446
else:
@@ -478,7 +470,6 @@ def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
478470
icesheet=icesheet,
479471
run_type=run_type,
480472
cism_observed_ic=cism_observed_ic,
481-
cism_evolve_this_icesheet=config['cism_evolve_this_icesheet'],
482473
inst_string=inst_string)
483474

484475
#----------------------------------------------------
@@ -514,7 +505,7 @@ def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
514505
# ------------------------------------------------------------------------
515506
# Final consistency checks
516507
# ------------------------------------------------------------------------
517-
_cism_config_final_consistency_checks(nmlgen)
508+
_cism_config_final_consistency_checks(nmlgen, icesheet)
518509

519510
###############################################################################
520511
def _initial_consistency_checks(case):
@@ -538,9 +529,19 @@ def _get_effective_run_type(case):
538529

539530
comp_interface = case.get_value("COMP_INTERFACE")
540531
cism_evolve = case.get_value("CISM_EVOLVE")
541-
# NOTE: with the nuopc interface, the CISM run phase is never called when running
542-
# in noevolve mode, so a restart file will never be written for cism - only initial
543-
# information will be sent back to CTSM.
532+
# NOTE: with the nuopc interface, the CISM run phase is never called when running in
533+
# noevolve mode, so a restart file will never be written for cism - only initial
534+
# information will be sent back to CTSM. Since we don't have a restart file to start
535+
# from, we need to tell CISM to start in startup mode in this situation.
536+
#
537+
# Note that this looks at the overall cism_evolve, which is only False if no ice
538+
# sheets are evolving: In the situation where one ice sheet is evolving but another is
539+
# not, the overall cism_evolve will be True and restart files will still be written
540+
# for every ice sheet (even non-evolving ones), so we can safely restart from these
541+
# restart files (so we do not need to force run_type to "startup"). (Also note that,
542+
# because all ice sheets share a single time manager in the CISM-wrapper layer, it
543+
# might currently be awkward or impossible for one ice sheet to start in startup mode
544+
# and another to start in branch mode, for example.)
544545
if (comp_interface == 'nuopc' and not cism_evolve):
545546
logger.debug("Interface is nuopc, cism is not evolving: CISM run_type is always startup")
546547
run_type = "startup"
@@ -549,7 +550,7 @@ def _get_effective_run_type(case):
549550

550551
###############################################################################
551552
def _set_restart_options(nmlgen, case, icesheet, run_type, cism_observed_ic,
552-
cism_evolve_this_icesheet, inst_string):
553+
inst_string):
553554
###############################################################################
554555
"""
555556
Sets defaults for variables related to restart in cism_in
@@ -560,7 +561,6 @@ def _set_restart_options(nmlgen, case, icesheet, run_type, cism_observed_ic,
560561
- icesheet: name of this ice sheet
561562
- run_type: string - 'startup', 'hybrid' or 'branch'
562563
- cism_observed_ic: logical
563-
- cism_evolve_this_icesheet: string - '.true.' or '.false.'
564564
- inst_string: string
565565
"""
566566
if run_type == 'startup':
@@ -570,7 +570,7 @@ def _set_restart_options(nmlgen, case, icesheet, run_type, cism_observed_ic,
570570
expect(False,"CISM_OBSERVED_IC=TRUE not allowed for branch runs - only for hybrid runs")
571571
else:
572572
restart = 0
573-
elif run_type == 'hybrid' and _value_is_false(cism_evolve_this_icesheet):
573+
elif run_type == 'hybrid' and not case.get_value('CISM_EVOLVE'):
574574
# We could use the hybrid refcase's CISM restart file in this case. However, we
575575
# often run into problems where a change in CISM makes it incompatible with old
576576
# restart files, and this breaks configurations that are set up as hybrid runs
@@ -588,9 +588,12 @@ def _set_restart_options(nmlgen, case, icesheet, run_type, cism_observed_ic,
588588
# observed initial conditions. Thus, the user would need to explicitly set
589589
# 'cisminputfile' and 'restart' in this case.
590590
#
591-
# Note that this logic is currently based on the ice sheet-specific CISM_EVOLVE
592-
# value; this may or may not be the right thing to do (see
593-
# https://github.com/ESCOMP/CISM-wrapper/issues/54).
591+
# Note that this logic is based on the overall CISM_EVOLVE, so it is not triggered
592+
# if one ice sheet is evolving but another is not. Also note that this logic is
593+
# currently redundant with the NUOPC-specific logic that sets run_type to
594+
# "startup" if CISM_EVOLVE is FALSE (in _get_effective_run_type). But we're
595+
# keeping this redundancy for the sake of MCT runs and in case the NUOPC-specific
596+
# logic is ever changed.
594597
restart = 0
595598
elif run_type == 'branch' or run_type == 'hybrid':
596599
run_refcase = case.get_value('RUN_REFCASE')
@@ -692,41 +695,28 @@ def _add_conditional_section_to_cism_config(nmlgen, output_file, group,
692695
nmlgen.confirm_group_is_empty(group, errmsg)
693696

694697
###############################################################################
695-
def _cism_in_final_consistency_checks(nmlgen, config):
698+
def _cism_config_final_consistency_checks(nmlgen, icesheet):
696699
###############################################################################
697700
num_errors = 0
701+
num_errors += _check_cism_dt(float(nmlgen.get_value("dt")), icesheet)
698702

699-
# TODO(wjs, 2021-02-25) We will move zero_gcm_fluxes to the cism.icesheet.config file,
700-
# making it ice sheet-specific. Then this needs to be changed to check the ice
701-
# sheet-specific zero_gcm_fluxes against the ice sheet-specific evolve_ice. See also
702-
# https://github.com/ESCOMP/CISM-wrapper/issues/53.
703-
if _value_is_false(config["cism_evolve"]):
704-
# The important condition is if evolve_ice = 0. But since evolve_ice is in
705-
# cism.icesheet.config, we don't have access to that value when doing consistency
706-
# checks on cism_in. We force evolve_ice to match CISM_EVOLVE, so we can check
707-
# this by checking CISM_EVOLVE.
703+
if int(nmlgen.get_value("evolve_ice")) == 0:
708704
if _value_is_false(nmlgen.get_value("zero_gcm_fluxes")):
709705
errmsg = """\
710-
ERROR: For CISM_EVOLVE FALSE, you must also set zero_gcm_fluxes = .true.
706+
ERROR for ice sheet {}:
707+
For evolve_ice = 0 (set from CISM_EVOLVE_ICESHEET for this icesheet),
708+
zero_gcm_fluxes must be set to .true.
711709
(This is because evolve_ice = 0 implies that there will be no fluxes,
712-
and you must explicitly set zero_gcm_fluxes = .true. for the sake of logic
710+
and so zero_gcm_fluxes must also be set to .true. for the sake of logic
713711
that depends on whether these fluxes will be zero - particularly, the creation
714-
of icemask_coupled_fluxes used by CTSM)."""
712+
of icemask_coupled_fluxes used by CTSM).""".format(icesheet)
715713
print(errmsg)
716714
num_errors += 1
717715

718-
expect(num_errors == 0, "Errors in cism_in final consistency checks (see above)")
719-
720-
###############################################################################
721-
def _cism_config_final_consistency_checks(nmlgen):
722-
###############################################################################
723-
num_errors = 0
724-
num_errors += _check_cism_dt(float(nmlgen.get_value("dt")))
725-
726-
expect(num_errors == 0, "Errors in cism.config final consistency checks (see above)")
716+
expect(num_errors == 0, "Errors in cism.{}.config final consistency checks (see above)".format(icesheet))
727717

728718
###############################################################################
729-
def _check_cism_dt(dt):
719+
def _check_cism_dt(dt, icesheet):
730720
###############################################################################
731721
"""Checks CISM's dt value: i.e., the dt variable in the time section of cism.icesheet.config
732722
@@ -742,9 +732,10 @@ def _check_cism_dt(dt):
742732
# value near machine epsilon
743733
if (abs(dt_hours - dt_hours_int)/dt_hours > 1e-15):
744734
errmsg = """\
745-
ERROR: dt (in years) must translate into an integer number of hours
735+
ERROR for ice sheet {}:
736+
dt (in years) must translate into an integer number of hours
746737
dt = {}
747-
dt (hours) = {}""".format(dt, dt_hours)
738+
dt (hours) = {}""".format(icesheet, dt, dt_hours)
748739
print(errmsg)
749740
num_errors += 1
750741

cime_config/config_component.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@
129129
<default_value>FALSE</default_value>
130130
<values>
131131
<!-- If ANY ice sheet is evolving, then set the overall
132-
CISM_EVOLVE to TRUE. This is needed for some logic in CMEPS,
133-
but note that combining an evolving and non-evolving ice
134-
sheet has not been tested yet and may not work correctly. -->
132+
CISM_EVOLVE to TRUE. This is needed for some logic in CMEPS.
133+
-->
135134
<value compset="_CISM[^_]*-EVOLVE">TRUE</value>
136135

137136
<!-- BACKWARDS_COMPATIBILITY(wjs, 2021-02-25) Backwards

cime_config/namelist_definition_cism.xml

+20-19
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,6 @@ Sub-elements of each entry include:
142142
</desc>
143143
</entry>
144144

145-
<!-- TODO(wjs, 2021-02-25) I think we'll need to move this to
146-
cism.icesheet.config, since we will allow cism_evolve to differ
147-
for each ice sheet -->
148-
<entry id="zero_gcm_fluxes">
149-
<type>logical</type>
150-
<category>cism</category>
151-
<group>cism_params</group>
152-
<values>
153-
<value glc_two_way_coupling=".true." cism_evolve=".true.">.false.</value>
154-
<value glc_two_way_coupling=".false." cism_evolve=".true.">.true.</value>
155-
<value glc_two_way_coupling=".true." cism_evolve=".false.">.true.</value>
156-
<value glc_two_way_coupling=".false." cism_evolve=".false.">.true.</value>
157-
</values>
158-
<desc>
159-
If true, zero out all fluxes sent to the GCM
160-
Default: Depends on GLC_TWO_WAY_COUPLING xml variable
161-
</desc>
162-
</entry>
163-
164145
<entry id="test_coupling">
165146
<type>logical</type>
166147
<category>cism</category>
@@ -186,6 +167,9 @@ Sub-elements of each entry include:
186167
Whether to enable overrides of the glc fraction sent to the coupler.
187168
If this is true, then settings in glc_override_nml are used.
188169
ONLY MEANT FOR TESTING - SHOULD NOT BE USED FOR SCIENCE RUNS.
170+
Note that, if running with multiple ice sheets, this and the
171+
various override settings apply to all ice sheets: there is no way
172+
to do overrides for one ice sheet but not the others.
189173
Default: .false.
190174
</desc>
191175
</entry>
@@ -626,6 +610,23 @@ Sub-elements of each entry include:
626610
</desc>
627611
</entry>
628612

613+
<entry id="zero_gcm_fluxes">
614+
<type>logical</type>
615+
<category>cism_config_climate</category>
616+
<group>glad_climate</group>
617+
<values>
618+
<value glc_two_way_coupling=".true." cism_evolve_this_icesheet=".true.">.false.</value>
619+
<value glc_two_way_coupling=".false." cism_evolve_this_icesheet=".true.">.true.</value>
620+
<value glc_two_way_coupling=".true." cism_evolve_this_icesheet=".false.">.true.</value>
621+
<value glc_two_way_coupling=".false." cism_evolve_this_icesheet=".false.">.true.</value>
622+
</values>
623+
<desc>
624+
If true, zero out all fluxes sent to the GCM
625+
Default: Depends on GLC_TWO_WAY_COUPLING xml variable and whether
626+
this ice sheet is evolving
627+
</desc>
628+
</entry>
629+
629630
<entry id="ice_tstep_multiply" skip_default_entry="true">
630631
<type>integer</type>
631632
<category>cism_config_climate</category>

cime_config/testdefs/testlist_cism.xml

+13
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,19 @@
840840
</machines>
841841
</test>
842842

843+
<test name="ERI_Ly9" grid="f09_g17_ais8gris4" compset="T1850Gag" testmods="cism-noevolve_ais">
844+
<machines>
845+
846+
<machine name="cheyenne" compiler="gnu" category="aux_glc">
847+
<options>
848+
<option name="wallclock">0:50:00</option>
849+
<option name="comment">ERI test with one ice sheet evolving and the other not, to make sure restart, branch and hybrid runs all work when one ice sheet is evolving and another is not.</option>
850+
</options>
851+
</machine>
852+
853+
</machines>
854+
</test>
855+
843856
<test name="IRT_Ly5_P24x1" grid="f09_g17_ais8gris4" compset="T1850Gag">
844857
<machines>
845858

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This testmod turns off ice evolution for Antarctica but leaves it on for
2+
other ice sheets. It is meant to be used in a multi-ice sheet test.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./xmlchange CISM_EVOLVE_ANTARCTICA=FALSE

drivers/cpl/mct/glc_comp_mct.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module glc_comp_mct
1818
use glc_import_export
1919
use glc_cpl_indices
2020
use glc_constants, only: verbose, stdout, stderr, radius
21-
use glc_constants, only: zero_gcm_fluxes, model_doi_url, icesheet_names
21+
use glc_constants, only: zero_gcm_fluxes_for_all_icesheets, model_doi_url, icesheet_names
2222
use glc_InitMod, only: glc_initialize
2323
use glc_RunMod, only: glc_run
2424
use glc_FinalMod, only: glc_final
@@ -209,7 +209,7 @@ subroutine glc_init_mct( EClock, cdata, x2g, g2x, NLFilename )
209209

210210
! Set flags in infodata
211211

212-
glc_coupled_fluxes = (.not. zero_gcm_fluxes)
212+
glc_coupled_fluxes = (.not. zero_gcm_fluxes_for_all_icesheets)
213213
call seq_infodata_PutData(infodata, &
214214
glc_present= .true., &
215215
glclnd_present = .true., &

drivers/cpl/mct/glc_import_export.F90

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module glc_import_export
33
use shr_sys_mod
44
use shr_kind_mod, only: IN=>SHR_KIND_IN, R8=>SHR_KIND_R8
55
use shr_kind_mod, only: CS=>SHR_KIND_CS, CL=>SHR_KIND_CL
6-
use glc_constants, only: verbose, stdout, stderr, tkfrz, zero_gcm_fluxes, enable_frac_overrides
6+
use glc_constants, only: verbose, stdout, stderr, tkfrz, enable_frac_overrides
77
use glc_communicate, only: my_task, master_task
88
use glc_cpl_indices
99

@@ -58,7 +58,7 @@ subroutine glc_export(g2x)
5858

5959
!-------------------------------------------------------------------
6060
use glc_indexing, only : get_nx, get_ny, spatial_to_vector
61-
use glc_fields, only : cpl_bundles
61+
use glc_fields, only : cpl_bundles, ice_sheet
6262
use glc_route_ice_runoff, only: route_ice_runoff
6363
use glc_override_frac , only: do_frac_overrides
6464

@@ -127,7 +127,7 @@ subroutine glc_export(g2x)
127127
allocate(rofi_to_ocn(nx, ny))
128128
allocate(rofi_to_ice(nx, ny))
129129

130-
if (zero_gcm_fluxes) then
130+
if (ice_sheet%instances(1)%zero_gcm_fluxes) then
131131
icemask_coupled_fluxes = 0._r8
132132
hflx_to_cpl = 0._r8
133133
rofl_to_cpl = 0._r8

0 commit comments

Comments
 (0)