@@ -284,15 +284,6 @@ def _icesheet_consistency_checks(case, icesheet_names, glc_grid_names):
284
284
expect (found_evolving_icesheet ,
285
285
"CISM_EVOLVE is TRUE, but no ice sheets are set to evolve" )
286
286
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
-
296
287
####################################################################################
297
288
def _check_compset_grid_consistency (case , icesheet_names , glc_grid_names ):
298
289
####################################################################################
@@ -383,7 +374,6 @@ def _create_cism_in(case, confdir, inst_string, icesheet_names, infile, nmlgen,
383
374
# Note that the cism_evolve value used in cism_in is the overall CISM_EVOLVE, which is
384
375
# true if *any* ice sheet is evolving.
385
376
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.'
387
377
config ['calendar' ] = case .get_value ("CALENDAR" )
388
378
389
379
run_type = _get_effective_run_type (case )
@@ -421,8 +411,6 @@ def _create_cism_in(case, confdir, inst_string, icesheet_names, infile, nmlgen,
421
411
output_file = os .path .join (confdir , "cism_in" )
422
412
nmlgen .write_output_file (output_file , data_list_path , groups = groups , sorted_groups = False )
423
413
424
- _cism_in_final_consistency_checks (nmlgen , config )
425
-
426
414
####################################################################################
427
415
def _create_cism_config (case , confdir , inst_string , icesheet , glc_grid ,
428
416
infile_overall , infile_this_icesheet , nmlgen , data_list_path ):
@@ -449,6 +437,10 @@ def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
449
437
config ['icesheet' ] = icesheet
450
438
config ['glc_grid' ] = glc_grid
451
439
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.'
452
444
if _is_icesheet_evolving (case , icesheet ):
453
445
config ['cism_evolve_this_icesheet' ] = '.true.'
454
446
else :
@@ -478,7 +470,6 @@ def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
478
470
icesheet = icesheet ,
479
471
run_type = run_type ,
480
472
cism_observed_ic = cism_observed_ic ,
481
- cism_evolve_this_icesheet = config ['cism_evolve_this_icesheet' ],
482
473
inst_string = inst_string )
483
474
484
475
#----------------------------------------------------
@@ -514,7 +505,7 @@ def _create_cism_config(case, confdir, inst_string, icesheet, glc_grid,
514
505
# ------------------------------------------------------------------------
515
506
# Final consistency checks
516
507
# ------------------------------------------------------------------------
517
- _cism_config_final_consistency_checks (nmlgen )
508
+ _cism_config_final_consistency_checks (nmlgen , icesheet )
518
509
519
510
###############################################################################
520
511
def _initial_consistency_checks (case ):
@@ -538,9 +529,19 @@ def _get_effective_run_type(case):
538
529
539
530
comp_interface = case .get_value ("COMP_INTERFACE" )
540
531
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.)
544
545
if (comp_interface == 'nuopc' and not cism_evolve ):
545
546
logger .debug ("Interface is nuopc, cism is not evolving: CISM run_type is always startup" )
546
547
run_type = "startup"
@@ -549,7 +550,7 @@ def _get_effective_run_type(case):
549
550
550
551
###############################################################################
551
552
def _set_restart_options (nmlgen , case , icesheet , run_type , cism_observed_ic ,
552
- cism_evolve_this_icesheet , inst_string ):
553
+ inst_string ):
553
554
###############################################################################
554
555
"""
555
556
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,
560
561
- icesheet: name of this ice sheet
561
562
- run_type: string - 'startup', 'hybrid' or 'branch'
562
563
- cism_observed_ic: logical
563
- - cism_evolve_this_icesheet: string - '.true.' or '.false.'
564
564
- inst_string: string
565
565
"""
566
566
if run_type == 'startup' :
@@ -570,7 +570,7 @@ def _set_restart_options(nmlgen, case, icesheet, run_type, cism_observed_ic,
570
570
expect (False ,"CISM_OBSERVED_IC=TRUE not allowed for branch runs - only for hybrid runs" )
571
571
else :
572
572
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' ):
574
574
# We could use the hybrid refcase's CISM restart file in this case. However, we
575
575
# often run into problems where a change in CISM makes it incompatible with old
576
576
# 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,
588
588
# observed initial conditions. Thus, the user would need to explicitly set
589
589
# 'cisminputfile' and 'restart' in this case.
590
590
#
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.
594
597
restart = 0
595
598
elif run_type == 'branch' or run_type == 'hybrid' :
596
599
run_refcase = case .get_value ('RUN_REFCASE' )
@@ -692,41 +695,28 @@ def _add_conditional_section_to_cism_config(nmlgen, output_file, group,
692
695
nmlgen .confirm_group_is_empty (group , errmsg )
693
696
694
697
###############################################################################
695
- def _cism_in_final_consistency_checks (nmlgen , config ):
698
+ def _cism_config_final_consistency_checks (nmlgen , icesheet ):
696
699
###############################################################################
697
700
num_errors = 0
701
+ num_errors += _check_cism_dt (float (nmlgen .get_value ("dt" )), icesheet )
698
702
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 :
708
704
if _value_is_false (nmlgen .get_value ("zero_gcm_fluxes" )):
709
705
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.
711
709
(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
713
711
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 )
715
713
print (errmsg )
716
714
num_errors += 1
717
715
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 ))
727
717
728
718
###############################################################################
729
- def _check_cism_dt (dt ):
719
+ def _check_cism_dt (dt , icesheet ):
730
720
###############################################################################
731
721
"""Checks CISM's dt value: i.e., the dt variable in the time section of cism.icesheet.config
732
722
@@ -742,9 +732,10 @@ def _check_cism_dt(dt):
742
732
# value near machine epsilon
743
733
if (abs (dt_hours - dt_hours_int )/ dt_hours > 1e-15 ):
744
734
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
746
737
dt = {}
747
- dt (hours) = {}""" .format (dt , dt_hours )
738
+ dt (hours) = {}""" .format (icesheet , dt , dt_hours )
748
739
print (errmsg )
749
740
num_errors += 1
750
741
0 commit comments