Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 40 additions & 1 deletion cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<entry_id version="3.0">

<description>
<desc ocn="MOM6[%MARBL-BIO][%MARBL-ABIO]">MOM6 OCEAN </desc>
<desc ocn="MOM6[%MARBL-BIO][%MARBL-ABIO][%PHYS-CYCLE]">MOM6 OCEAN </desc>
<desc option="MARBL-BIO">MARBL Biogeochemistry Tracer Library base biotic tracers</desc>
<desc option="MARBL-ABIO">MARBL Biogeochemistry Tracer Library abiotic DIC tracers</desc>
<desc option="PHYS-CYCLE">phys cycle option</desc>
</description>

<entry id="COMP_OCN">
Expand Down Expand Up @@ -206,6 +207,44 @@
</desc>
</entry>

<entry id="MOM6_PHYS_CYCLE_YEARS_IN_CYCLE">
<type>integer</type>
<default_value>0</default_value>
<group>run_component_mom</group>
<file>env_run.xml</file>
<desc>number of years to run before cycling MOM6 physics
MOM6 physics cycling only occurs if MOM6_PHYS_CYCLE_YEARS_IN_CYCLE>0
and pre- and post-run scripts are specified in env vars
PRERUN_SCRIPT and POSTRUN_SCRIPT</desc>
</entry>

<entry id="MOM6_PHYS_CYCLE_MONTHS_RUN_SINCE_CYCLE">
<type>integer</type>
<default_value>0</default_value>
<group>run_component_mom</group>
<file>env_run.xml</file>
<desc>number of months run since most recent cycling of MOM6 physics</desc>
</entry>

<entry id="MOM6_TRACER_IC_FILE_OVERRIDE_POINTER">
<type>char</type>
<default_value></default_value>
<group>run_component_mom</group>
<file>env_run.xml</file>
<desc>File containing tracer IC filenames</desc>
</entry>

<entry id="MARBL_ENFORCE_TRACER_ZINT">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_component_mom</group>
<file>env_run.xml</file>
<desc>Rescale MARBL tracers so that their vertical integrals match
their vertical integrals computed from the IC file(s).
</desc>
</entry>

<help>
=========================================
MOM6 naming conventions
Expand Down
41 changes: 41 additions & 0 deletions cime_config/config_compsets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,50 @@
<lname>1850_DATM%JRA-1p5-2023_SLND_CICE_MOM6%MARBL-BIO_DROF%JRA-1p5-2023_SGLC_WW3</lname>
</compset>

<!-- PHYS_CYCLE configuration requires a cdeps/drof change to work with JRA
<compset>
<alias>GW1850MARBL_JRA_PHYS_CYCLE</alias>
<lname>1850_DATM%JRA-1p5-2023_SLND_CICE_MOM6%MARBL-BIO%PHYS-CYCLE_DROF%JRA-1p5-2023_SGLC_WW3</lname>
</compset>
-->

<compset>
<alias>GW1850MARBL_CPLHIST</alias>
<lname>1850_DATM%CPLHIST_SLND_CICE_MOM6%MARBL-BIO_DROF%CPLHIST_SGLC_WW3</lname>
</compset>

<compset>
<alias>GW1850MARBL_CPLHIST_PHYS_CYCLE</alias>
<lname>1850_DATM%CPLHIST_SLND_CICE_MOM6%MARBL-BIO%PHYS-CYCLE_DROF%CPLHIST_SGLC_WW3</lname>
</compset>

<compset>
<alias>GW1850ABIOMARBL_JRA</alias>
<lname>1850_DATM%JRA-1p5-2023_SLND_CICE_MOM6%MARBL-ABIO_DROF%JRA-1p5-2023_SGLC_WW3</lname>
</compset>

<!-- ENTRIES -->

<entries>

<entry id="PRERUN_SCRIPT">
<values>
<value compset="MOM6%[^_]*PHYS-CYCLE">$SRCROOT/components/mom/cime_config/phys_cycle_prerun</value>
</values>
</entry>

<entry id="POSTRUN_SCRIPT">
<values>
<value compset="MOM6%[^_]*PHYS-CYCLE">$SRCROOT/components/mom/cime_config/phys_cycle_postrun</value>
</values>
</entry>

<entry id="RESUBMIT_SETS_CONTINUE_RUN">
<values>
<value compset="MOM6%[^_]*PHYS-CYCLE">FALSE</value>
</values>
</entry>

</entries>

</compsets>
71 changes: 38 additions & 33 deletions cime_config/config_pes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,39 +210,6 @@
<rootpe_glc>0</rootpe_glc>
</rootpe>
</pes>
<pes pesize="any" compset="_DATM.+_CICE.*_MOM6%[^_]*MARBL-BIO.+_WW3">
<comment>none</comment>
<ntasks>
<ntasks_atm>384</ntasks_atm>
<ntasks_rof>384</ntasks_rof>
<ntasks_cpl>384</ntasks_cpl>
<ntasks_ice>384</ntasks_ice>
<ntasks_ocn>2560</ntasks_ocn>
<ntasks_lnd>1</ntasks_lnd>
<ntasks_wav>128</ntasks_wav>
<ntasks_glc>1</ntasks_glc>
</ntasks>
<nthrds>
<nthrds_atm>1</nthrds_atm>
<nthrds_lnd>1</nthrds_lnd>
<nthrds_rof>1</nthrds_rof>
<nthrds_ice>1</nthrds_ice>
<nthrds_ocn>1</nthrds_ocn>
<nthrds_glc>1</nthrds_glc>
<nthrds_wav>1</nthrds_wav>
<nthrds_cpl>1</nthrds_cpl>
</nthrds>
<rootpe>
<rootpe_atm>0</rootpe_atm>
<rootpe_rof>0</rootpe_rof>
<rootpe_cpl>0</rootpe_cpl>
<rootpe_ice>0</rootpe_ice>
<rootpe_ocn>512</rootpe_ocn>
<rootpe_lnd>0</rootpe_lnd>
<rootpe_wav>384</rootpe_wav>
<rootpe_glc>0</rootpe_glc>
</rootpe>
</pes>
<pes pesize="any" compset="_DATM.+_DICE.*_MOM6(?!.*%MARBL-BIO).+_SWAV">
<comment>none</comment>
<ntasks>
Expand Down Expand Up @@ -413,6 +380,44 @@
</mach>
</grid>

<grid name="oi%tx2_3v[23]">
<mach name="derecho">
<pes pesize="any" compset="_DATM.+_CICE.*_MOM6%[^_]*MARBL-BIO.+_WW3">
<comment>MARBL 2/3, any DATM forcing, including CPLHIST</comment>
<ntasks>
<ntasks_atm>384</ntasks_atm>
<ntasks_rof>384</ntasks_rof>
<ntasks_cpl>384</ntasks_cpl>
<ntasks_ice>384</ntasks_ice>
<ntasks_ocn>2560</ntasks_ocn>
<ntasks_lnd>1</ntasks_lnd>
<ntasks_wav>128</ntasks_wav>
<ntasks_glc>1</ntasks_glc>
</ntasks>
<nthrds>
<nthrds_atm>1</nthrds_atm>
<nthrds_lnd>1</nthrds_lnd>
<nthrds_rof>1</nthrds_rof>
<nthrds_ice>1</nthrds_ice>
<nthrds_ocn>1</nthrds_ocn>
<nthrds_glc>1</nthrds_glc>
<nthrds_wav>1</nthrds_wav>
<nthrds_cpl>1</nthrds_cpl>
</nthrds>
<rootpe>
<rootpe_atm>0</rootpe_atm>
<rootpe_rof>0</rootpe_rof>
<rootpe_cpl>0</rootpe_cpl>
<rootpe_ice>0</rootpe_ice>
<rootpe_ocn>512</rootpe_ocn>
<rootpe_lnd>0</rootpe_lnd>
<rootpe_wav>384</rootpe_wav>
<rootpe_glc>0</rootpe_glc>
</rootpe>
</pes>
</mach>
</grid>

<grid name="a%(TL319|T62).+oi%tx2_0v1">
<mach name="derecho">
<pes pesize="any" compset="any">
Expand Down
121 changes: 121 additions & 0 deletions cime_config/phys_cycle_postrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env python

"""mom6 physics cycle postrun script
"""

import logging
import os
import sys

_CIMEROOT = os.environ.get("CIMEROOT")
if _CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools"))

from standard_script_setup import *
from CIME.case import Case
from CIME.utils import expect

logger = logging.getLogger(__name__)

###############################################################################
def phys_cycle_postrun(caseroot):
###############################################################################

ch = logging.StreamHandler(stream=sys.stdout)
ch.setLevel(logging.INFO)
logger.addHandler(ch)

with Case(caseroot, read_only=False) as case:
mom6_phys_cycle_years_in_cycle = case.get_value("MOM6_PHYS_CYCLE_YEARS_IN_CYCLE")
expect(mom6_phys_cycle_years_in_cycle is not None,
f"MOM6_PHYS_CYCLE_YEARS_IN_CYCLE should be defined when {sys.argv[0]} is called")
if mom6_phys_cycle_years_in_cycle <= 0:
return

# -------------------------------------------------------------------------
# Determine if model has run the length of MOM6 physics run cycle length
# this assumes that STOP_ options have not been changed during the submission
# -------------------------------------------------------------------------

stop_option = case.get_value("STOP_OPTION")
stop_n = case.get_value("STOP_N")

mom6_phys_cycle_months_run_since_cycle = case.get_value(
"MOM6_PHYS_CYCLE_MONTHS_RUN_SINCE_CYCLE"
)

# we know from phys_cycle_prerun that stop_option is either "nmonth*" or "nyear*"

if stop_option.find("nmonth") == 0:
mom6_phys_cycle_months_run_since_cycle_new = (
mom6_phys_cycle_months_run_since_cycle + stop_n
)
if stop_option.find("nyear") == 0:
mom6_phys_cycle_months_run_since_cycle_new = (
mom6_phys_cycle_months_run_since_cycle + stop_n * 12
)

case.set_value("MOM6_PHYS_CYCLE_MONTHS_RUN_SINCE_CYCLE",
mom6_phys_cycle_months_run_since_cycle_new)
logger.info("MOM6_PHYS_CYCLE_MONTHS_RUN_SINCE_CYCLE incremented to %d",
mom6_phys_cycle_months_run_since_cycle_new)

if mom6_phys_cycle_months_run_since_cycle_new < mom6_phys_cycle_years_in_cycle * 12:
case.set_value("CONTINUE_RUN", "TRUE")
case.set_value("MOM6_TRACER_IC_FILE_OVERRIDE_POINTER", "")
case.set_value("MARBL_ENFORCE_TRACER_ZINT", "FALSE")
case.flush()
return

# -------------------------------------------------------------------------
# Model has run the length of MOM6 physics run cycle length, reset model physics
# -------------------------------------------------------------------------

logger.info("resetting model physics")
case.set_value("CONTINUE_RUN", "FALSE")
case.set_value("MOM6_PHYS_CYCLE_MONTHS_RUN_SINCE_CYCLE", 0)

# -------------------------------------------------------------------------
# Compute new RUN_STARTDATE
# -------------------------------------------------------------------------

run_startdate = case.get_value("RUN_STARTDATE")
yyyy = int(run_startdate[:4])
yyyy = yyyy + mom6_phys_cycle_years_in_cycle
run_startdate = f"{yyyy:04d}{run_startdate[4:]}"
case.set_value("RUN_STARTDATE", run_startdate)
logger.info("RUN_STARTDATE incremented to %s", run_startdate)

# -------------------------------------------------------------------------
# Configure tracer module initialization for new PHYS_CYCLE cycle
# -------------------------------------------------------------------------

case.set_value("MOM6_TRACER_IC_FILE_OVERRIDE_POINTER",
f"./rpointer.ocn.{run_startdate}-00000")
case.set_value("MARBL_ENFORCE_TRACER_ZINT", "TRUE")

# -------------------------------------------------------------------------
# Update CPLHIST ALIGN variables
# -------------------------------------------------------------------------

varnames_dict = {
'DATM_MODE': 'DATM_YR_ALIGN',
'DROF_MODE': 'DROF_CPLHIST_YR_ALIGN'
}
for mode_varname, align_varname in varnames_dict.items():
if case.get_value(mode_varname) == "CPLHIST":
align_val = case.get_value(align_varname)
if align_val is not None:
align_val = align_val + mom6_phys_cycle_years_in_cycle
case.set_value(align_varname, align_val)
logger.info("%s incremented to %d", align_varname, align_val)

case.flush()

###############################################################################

if __name__ == "__main__":
expect(len(sys.argv) == 2, "caseroot is a required input argument")
caseroot = sys.argv[1]
phys_cycle_postrun(caseroot)
80 changes: 80 additions & 0 deletions cime_config/phys_cycle_prerun
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python

"""mom6 physics cycle prerun script
"""

import logging
import os
import sys

_CIMEROOT = os.environ.get("CIMEROOT")
if _CIMEROOT is None:
raise SystemExit("ERROR: must set CIMEROOT environment variable")
sys.path.append(os.path.join(_CIMEROOT, "CIME", "Tools"))

from standard_script_setup import *
from CIME.case import Case
from CIME.utils import expect

logger = logging.getLogger(__name__)

###############################################################################
def phys_cycle_prerun(caseroot):
###############################################################################

ch = logging.StreamHandler(stream=sys.stdout)
ch.setLevel(logging.INFO)
logger.addHandler(ch)

with Case(caseroot, read_only=False) as case:
mom6_phys_cycle_years_in_cycle = case.get_value("MOM6_PHYS_CYCLE_YEARS_IN_CYCLE")
expect(mom6_phys_cycle_years_in_cycle is not None,
f"MOM6_PHYS_CYCLE_YEARS_IN_CYCLE should be defined when {sys.argv[0]} is called")
logger.info("mom6_phys_cycle_years_in_cycle = %d", mom6_phys_cycle_years_in_cycle)
if mom6_phys_cycle_years_in_cycle <= 0:
return

# RUN_TYPE cannot be branch
expect(case.get_value("RUN_TYPE") != "branch",
"RUN_TYPE set to branch not implemented for MOM6 physics cycling"
" because RUN_STARTDATE cannot be incremented")

# stop_option must be nmonth, nmonths, nyear or nyears
stop_option = case.get_value("STOP_OPTION")
expect((stop_option.find("nmonth") == 0) or (stop_option.find("nyear") == 0),
f"STOP_OPTION={stop_option} not implemented for MOM6 physics cycling")

# -------------------------------------------------------------------------
# Ensure that phys_cycle scripts are in charge of setting CONTINUE_RUN
# -------------------------------------------------------------------------
case.set_value("RESUBMIT_SETS_CONTINUE_RUN", "FALSE")
case.flush()

# -------------------------------------------------------------------------
# Ensure that the current run length will not overshoot the phys_cycle run length
# -------------------------------------------------------------------------

mom6_phys_cycle_months_run_since_cycle = case.get_value(
"MOM6_PHYS_CYCLE_MONTHS_RUN_SINCE_CYCLE"
)
mom6_phys_cycle_years_in_cycle = case.get_value("MOM6_PHYS_CYCLE_YEARS_IN_CYCLE")

stop_n = case.get_value("STOP_N")
if stop_option.find("nmonth") == 0:
mom6_phys_cycle_months_run_since_cycle_new = (
mom6_phys_cycle_months_run_since_cycle + stop_n
)
elif stop_option.find("nyear") == 0:
mom6_phys_cycle_months_run_since_cycle_new = (
mom6_phys_cycle_months_run_since_cycle + stop_n * 12
)

expect(mom6_phys_cycle_months_run_since_cycle_new <= mom6_phys_cycle_years_in_cycle * 12,
"run will overshoot phys_cycle run length")

###############################################################################

if __name__ == "__main__":
expect(len(sys.argv) == 2, "caseroot is a required input argument")
caseroot = sys.argv[1]
phys_cycle_prerun(caseroot)
Loading
Loading