Skip to content

Commit

Permalink
Merge pull request #159 from ESCOMP/facilitate_hybrid_runs
Browse files Browse the repository at this point in the history
Facilitate hybrid runs
  • Loading branch information
gustavo-marques authored Apr 5, 2024
2 parents 3e3b0fb + 1da983f commit e5d19e0
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 12 deletions.
27 changes: 27 additions & 0 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,30 @@ def _copy_input_files(case, dest_dir, inst_suffixes):
]:
shutil.copy(os.path.join(rundir, filename), dest_dir)

def prechecks(case, inst_suffixes):
"""Performs prechecks to ensure that necessary restart files and rpointer files are present in rundir."""

rundir = case.get_value("RUNDIR")
run_type = case.get_value("RUN_TYPE")
continue_run = case.get_value("CONTINUE_RUN")
get_refcase = case.get_value("GET_REFCASE")
run_refcase = case.get_value("RUN_REFCASE")
run_refdate = case.get_value("RUN_REFDATE")
run_reftod = case.get_value("RUN_REFTOD")

# check if rpointer files are present in rundir
if run_type != "startup" or continue_run:
for inst_suffix in inst_suffixes:
pointer_file = os.path.join(rundir, "rpointer.ocn" + inst_suffix)
expect(
os.path.exists(pointer_file),
f"Missing rpointer file rpointer.ocn{inst_suffix} in rundir.",
)

# check if the restart file is present in rundir
if run_type in ["branch", "hybrid"] and not continue_run and not get_refcase:
restart_file = os.path.join(rundir, f'./{run_refcase}.mom6.r.{run_refdate}-{run_reftod}.nc')
assert os.path.exists(restart_file), f"Missing restart file {run_refcase}.mom6.r.{run_refdate}-{run_reftod}.nc in rundir."

# pylint: disable=unused-argument
###############################################################################
Expand All @@ -233,6 +257,9 @@ def buildnml(case, caseroot, compname):
["_{:04d}".format(i + 1) for i in range(ninst)] if ninst > 1 else [""]
)

# prechecks
prechecks(case, inst_suffixes)

# prepare all input files
prep_input(case, inst_suffixes)

Expand Down
59 changes: 53 additions & 6 deletions param_templates/MOM_input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ Global:
datatype: logical
units: Boolean
value:
$OCN_GRID == "gx1v6": True
$OCN_GRID == "tx0.66v1": True
$OCN_GRID == "tx2_3v2": True
$OCN_GRID == "tx0.25v1": True
$RUN_TYPE != "hybrid" and $OCN_GRID in ["gx1v6", "tx0.66v1", "tx2_3v2", "tx0.25v1"]:
True
else:
False
TEMP_SALT_Z_INIT_FILE:
description: |
"default = 'temp_salt_z.nc'
Expand Down Expand Up @@ -3006,7 +3006,16 @@ Global:
USER - call a user modified routine."
datatype: string
value:
$OCN_GRID == "MISOMIP": "ISOMIP"
$RUN_TYPE == "hybrid":
"thickness_file"
else:
$OCN_GRID == "MISOMIP": "ISOMIP"
THICKNESS_FILE:
description: "The name of the thickness file"
datatype: string
value:
$RUN_TYPE == "hybrid":
= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'
SPONGE_CONFIG:
description: |
"default = 'file'
Expand Down Expand Up @@ -3054,7 +3063,45 @@ Global:
USER - call a user modified routine."
datatype: string
value:
$OCN_GRID == "MISOMIP": "ISOMIP"
$RUN_TYPE == "hybrid":
"file"
else:
$OCN_GRID == "MISOMIP": "ISOMIP"
TS_FILE:
description: "The initial condition file for the temperature and salinity."
datatype: string
value:
$RUN_TYPE == "hybrid":
= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'
TEMP_IC_VAR:
description: "The initial condition variable for potential temperature"
datatype: string
value:
$RUN_TYPE == "hybrid": "Temp"
SALT_IC_VAR:
description: "The initial condition variable for the salinity."
datatype: string
value:
$RUN_TYPE == "hybrid": "Salt"
VELOCITY_CONFIG:
description: "A string that determines how the initial velocities are specified for a new run."
datatype: string
value:
$RUN_TYPE == "hybrid": "file"
VELOCITY_FILE:
description: "The name of the velocity initial condition file."
datatype: string
value:
$RUN_TYPE == "hybrid":
= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'
AGE_IC_FILE:
description: |
"The file in which the age-tracer initial values can be found, or an empty
string for internal initialization."
datatype: string
value:
$RUN_TYPE == "hybrid" and $CONTINUE_RUN == False:
= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'
T_REF:
description: |
"[degC]
Expand Down
65 changes: 59 additions & 6 deletions param_templates/json/MOM_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,8 @@
"datatype": "logical",
"units": "Boolean",
"value": {
"$OCN_GRID == \"gx1v6\"": true,
"$OCN_GRID == \"tx0.66v1\"": true,
"$OCN_GRID == \"tx2_3v2\"": true,
"$OCN_GRID == \"tx0.25v1\"": true
"$RUN_TYPE != \"hybrid\" and $OCN_GRID in [\"gx1v6\", \"tx0.66v1\", \"tx2_3v2\", \"tx0.25v1\"]": true,
"else": false
}
},
"TEMP_SALT_Z_INIT_FILE": {
Expand Down Expand Up @@ -2405,7 +2403,17 @@
"description": "\"A string that determines how the initial layer\nthicknesses are specified for a new run:\nfile - read interface heights from the file specified\nthickness_file - read thicknesses from the file specified\nby (THICKNESS_FILE).\ncoord - determined by ALE coordinate.\nuniform - uniform thickness layers evenly distributed\nbetween the surface and MAXIMUM_DEPTH.\nDOME - use a slope and channel configuration for the\nDOME sill-overflow test case.\nISOMIP - use a configuration for the\nISOMIP test case.\nbenchmark - use the benchmark test case thicknesses.\nsearch - search a density profile for the interface\ndensities. This is not yet implemented.\ncircle_obcs - the circle_obcs test case is used.\nDOME2D - 2D version of DOME initialization.\nadjustment2d - TBD AJA.\nsloshing - TBD AJA.\nseamount - TBD AJA.\nrossby_front - a mixed layer front in thermal wind balance.\nUSER - call a user modified routine.\"\n",
"datatype": "string",
"value": {
"$OCN_GRID == \"MISOMIP\"": "ISOMIP"
"$RUN_TYPE == \"hybrid\"": "thickness_file",
"else": {
"$OCN_GRID == \"MISOMIP\"": "ISOMIP"
}
}
},
"THICKNESS_FILE": {
"description": "The name of the thickness file",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\"": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'"
}
},
"SPONGE_CONFIG": {
Expand Down Expand Up @@ -2434,7 +2442,52 @@
"description": "\"A string that determines how the initial tempertures\nand salinities are specified for a new run:\nfile - read velocities from the file specified\nby (TS_FILE).\nfit - find the temperatures that are consistent with\nthe layer densities and salinity S_REF.\nTS_profile - use temperature and salinity profiles\n(read from TS_FILE) to set layer densities.\nbenchmark - use the benchmark test case T & S.\nlinear - linear in logical layer space.\nDOME2D - 2D DOME initialization.\nISOMIP - ISOMIP initialization.\nadjustment2d - TBD AJA.\nsloshing - TBD AJA.\nseamount - TBD AJA.\nrossby_front - a mixed layer front in thermal wind balance.\nSCM_ideal_hurr - used in the SCM idealized hurricane test.\nUSER - call a user modified routine.\"\n",
"datatype": "string",
"value": {
"$OCN_GRID == \"MISOMIP\"": "ISOMIP"
"$RUN_TYPE == \"hybrid\"": "file",
"else": {
"$OCN_GRID == \"MISOMIP\"": "ISOMIP"
}
}
},
"TS_FILE": {
"description": "The initial condition file for the temperature and salinity.",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\"": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'"
}
},
"TEMP_IC_VAR": {
"description": "The initial condition variable for potential temperature",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\"": "Temp"
}
},
"SALT_IC_VAR": {
"description": "The initial condition variable for the salinity.",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\"": "Salt"
}
},
"VELOCITY_CONFIG": {
"description": "A string that determines how the initial velocities are specified for a new run.",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\"": "file"
}
},
"VELOCITY_FILE": {
"description": "The name of the velocity initial condition file.",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\"": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'"
}
},
"AGE_IC_FILE": {
"description": "\"The file in which the age-tracer initial values can be found, or an empty\nstring for internal initialization.\"\n",
"datatype": "string",
"value": {
"$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'"
}
},
"T_REF": {
Expand Down

0 comments on commit e5d19e0

Please sign in to comment.