Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facilitate hybrid runs #159

Merged
merged 2 commits into from
Apr 5, 2024
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
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."
Comment on lines +240 to +243
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you creating the restart_file from the case instead of reading the rpointer file? Alternatively, why are you checking for the existence of an rpointer file if you aren't reading it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For continuation runs, MOM6 reads the rpointer file regardless of run type. Therefore, a check is performed to confirm its existence.

However, in the case of initial hybrid runs, MOM6 does not read rpointer but instead reads the initial condition files listed in MOM_input. So, for an initial hybrid run (and for initial branch runs too), the above block disregards the rpointer file and determines the required restart file name from the reference case properties. Maybe for initial branch runs, a check may be added to confirm that reference case and rpointer are consistent.

The reason I check for the existence of rpointer file when it's an initial hybrid run is because of CESM conventions, but I am happy to update the check to be performed only for continuation runs and branch runs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! I think this block of code makes sense given the structure of updates in the companion MOM6 PR.


# 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