From c752ef4c58debb67fa8980136f8a8260d3b04094 Mon Sep 17 00:00:00 2001 From: alperaltuntas Date: Mon, 1 Apr 2024 16:03:04 -0600 Subject: [PATCH 1/2] add param changes and buildnml checks for hybrid runs --- cime_config/buildnml | 27 ++++++++++++ param_templates/MOM_input.yaml | 59 +++++++++++++++++++++++--- param_templates/json/MOM_input.json | 65 ++++++++++++++++++++++++++--- 3 files changed, 139 insertions(+), 12 deletions(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index e8415d6..8c508a5 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -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 ############################################################################### @@ -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) diff --git a/param_templates/MOM_input.yaml b/param_templates/MOM_input.yaml index 7355243..73ae03e 100644 --- a/param_templates/MOM_input.yaml +++ b/param_templates/MOM_input.yaml @@ -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" or $CONTINUE_RUN == True 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' @@ -3006,7 +3006,16 @@ Global: USER - call a user modified routine." datatype: string value: - $OCN_GRID == "MISOMIP": "ISOMIP" + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + "thickness_file" + else: + $OCN_GRID == "MISOMIP": "ISOMIP" + THICKNESS_FILE: + description: "The name of the thickness file" + datatype: string + value: + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + = f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc' SPONGE_CONFIG: description: | "default = 'file' @@ -3054,7 +3063,45 @@ Global: USER - call a user modified routine." datatype: string value: - $OCN_GRID == "MISOMIP": "ISOMIP" + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + "file" + else: + $OCN_GRID == "MISOMIP": "ISOMIP" + TS_FILE: + description: "The initial condition file for the temperature and salinity." + datatype: string + value: + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + = 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" and $CONTINUE_RUN == False: "Temp" + SALT_IC_VAR: + description: "The initial condition variable for the salinity." + datatype: string + value: + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: "Salt" + VELOCITY_CONFIG: + description: "A string that determines how the initial velocities are specified for a new run." + datatype: string + value: + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: "file" + VELOCITY_FILE: + description: "The name of the velocity initial condition file." + datatype: string + value: + $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + = 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] diff --git a/param_templates/json/MOM_input.json b/param_templates/json/MOM_input.json index a29d617..d39f49f 100644 --- a/param_templates/json/MOM_input.json +++ b/param_templates/json/MOM_input.json @@ -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\" or $CONTINUE_RUN == True and $OCN_GRID in [\"gx1v6\", \"tx0.66v1\", \"tx2_3v2\", \"tx0.25v1\"]": true, + "else": false } }, "TEMP_SALT_Z_INIT_FILE": { @@ -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\" and $CONTINUE_RUN == False": "thickness_file", + "else": { + "$OCN_GRID == \"MISOMIP\"": "ISOMIP" + } + } + }, + "THICKNESS_FILE": { + "description": "The name of the thickness file", + "datatype": "string", + "value": { + "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'" } }, "SPONGE_CONFIG": { @@ -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\" and $CONTINUE_RUN == False": "file", + "else": { + "$OCN_GRID == \"MISOMIP\"": "ISOMIP" + } + } + }, + "TS_FILE": { + "description": "The initial condition file for the temperature and salinity.", + "datatype": "string", + "value": { + "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= 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\" and $CONTINUE_RUN == False": "Temp" + } + }, + "SALT_IC_VAR": { + "description": "The initial condition variable for the salinity.", + "datatype": "string", + "value": { + "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "Salt" + } + }, + "VELOCITY_CONFIG": { + "description": "A string that determines how the initial velocities are specified for a new run.", + "datatype": "string", + "value": { + "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "file" + } + }, + "VELOCITY_FILE": { + "description": "The name of the velocity initial condition file.", + "datatype": "string", + "value": { + "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= 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": { From 1da983f816f0804d3da1f5b73a89c26455bdd5f2 Mon Sep 17 00:00:00 2001 From: alperaltuntas Date: Thu, 4 Apr 2024 16:51:20 -0600 Subject: [PATCH 2/2] remove the unnecessary CONTINUE_RUN checks from hybrid IC-related params --- param_templates/MOM_input.yaml | 18 +++++++++--------- param_templates/json/MOM_input.json | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/param_templates/MOM_input.yaml b/param_templates/MOM_input.yaml index 73ae03e..5849ab0 100644 --- a/param_templates/MOM_input.yaml +++ b/param_templates/MOM_input.yaml @@ -526,7 +526,7 @@ Global: datatype: logical units: Boolean value: - $RUN_TYPE != "hybrid" or $CONTINUE_RUN == True and $OCN_GRID in ["gx1v6", "tx0.66v1", "tx2_3v2", "tx0.25v1"]: + $RUN_TYPE != "hybrid" and $OCN_GRID in ["gx1v6", "tx0.66v1", "tx2_3v2", "tx0.25v1"]: True else: False @@ -3006,7 +3006,7 @@ Global: USER - call a user modified routine." datatype: string value: - $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + $RUN_TYPE == "hybrid": "thickness_file" else: $OCN_GRID == "MISOMIP": "ISOMIP" @@ -3014,7 +3014,7 @@ Global: description: "The name of the thickness file" datatype: string value: - $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + $RUN_TYPE == "hybrid": = f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc' SPONGE_CONFIG: description: | @@ -3063,7 +3063,7 @@ Global: USER - call a user modified routine." datatype: string value: - $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + $RUN_TYPE == "hybrid": "file" else: $OCN_GRID == "MISOMIP": "ISOMIP" @@ -3071,28 +3071,28 @@ Global: description: "The initial condition file for the temperature and salinity." datatype: string value: - $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + $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" and $CONTINUE_RUN == False: "Temp" + $RUN_TYPE == "hybrid": "Temp" SALT_IC_VAR: description: "The initial condition variable for the salinity." datatype: string value: - $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: "Salt" + $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" and $CONTINUE_RUN == False: "file" + $RUN_TYPE == "hybrid": "file" VELOCITY_FILE: description: "The name of the velocity initial condition file." datatype: string value: - $RUN_TYPE == "hybrid" and $CONTINUE_RUN == False: + $RUN_TYPE == "hybrid": = f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc' AGE_IC_FILE: description: | diff --git a/param_templates/json/MOM_input.json b/param_templates/json/MOM_input.json index d39f49f..711d1a6 100644 --- a/param_templates/json/MOM_input.json +++ b/param_templates/json/MOM_input.json @@ -373,7 +373,7 @@ "datatype": "logical", "units": "Boolean", "value": { - "$RUN_TYPE != \"hybrid\" or $CONTINUE_RUN == True and $OCN_GRID in [\"gx1v6\", \"tx0.66v1\", \"tx2_3v2\", \"tx0.25v1\"]": true, + "$RUN_TYPE != \"hybrid\" and $OCN_GRID in [\"gx1v6\", \"tx0.66v1\", \"tx2_3v2\", \"tx0.25v1\"]": true, "else": false } }, @@ -2403,7 +2403,7 @@ "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": { - "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "thickness_file", + "$RUN_TYPE == \"hybrid\"": "thickness_file", "else": { "$OCN_GRID == \"MISOMIP\"": "ISOMIP" } @@ -2413,7 +2413,7 @@ "description": "The name of the thickness file", "datatype": "string", "value": { - "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'" + "$RUN_TYPE == \"hybrid\"": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'" } }, "SPONGE_CONFIG": { @@ -2442,7 +2442,7 @@ "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": { - "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "file", + "$RUN_TYPE == \"hybrid\"": "file", "else": { "$OCN_GRID == \"MISOMIP\"": "ISOMIP" } @@ -2452,35 +2452,35 @@ "description": "The initial condition file for the temperature and salinity.", "datatype": "string", "value": { - "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'" + "$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\" and $CONTINUE_RUN == False": "Temp" + "$RUN_TYPE == \"hybrid\"": "Temp" } }, "SALT_IC_VAR": { "description": "The initial condition variable for the salinity.", "datatype": "string", "value": { - "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "Salt" + "$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\" and $CONTINUE_RUN == False": "file" + "$RUN_TYPE == \"hybrid\"": "file" } }, "VELOCITY_FILE": { "description": "The name of the velocity initial condition file.", "datatype": "string", "value": { - "$RUN_TYPE == \"hybrid\" and $CONTINUE_RUN == False": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'" + "$RUN_TYPE == \"hybrid\"": "= f'./{$RUN_REFCASE}.mom6.r.{$RUN_REFDATE}-{$RUN_REFTOD}.nc'" } }, "AGE_IC_FILE": {