diff --git a/compass/landice/tests/ismip7_run/custom_job_script.py b/compass/landice/tests/ismip7_run/custom_job_script.py
new file mode 100644
index 0000000000..b834c49f61
--- /dev/null
+++ b/compass/landice/tests/ismip7_run/custom_job_script.py
@@ -0,0 +1,66 @@
+import os
+from importlib import resources
+
+import numpy as np
+from jinja2 import Template
+
+
+def write_custom_job_script(config, section, work_dir, job_name, ntasks):
+ """
+ Write ``job_script.custom.sh``, which runs MALI directly from the run
+ directory with a user-supplied environment, if requested in the config
+
+ Parameters
+ ----------
+ config : compass.config.CompassConfigParser
+ Configuration options for the test case
+
+ section : str
+ The config section with the ``custom_job_script`` and
+ ``custom_job_env_cmds`` options
+
+ work_dir : str
+ The work directory where the job script should be written
+
+ job_name : str
+ The name of the batch job
+
+ ntasks : int
+ The number of MPI tasks for the model run
+ """
+ option = config.get(section, 'custom_job_script')
+ if option == 'None':
+ return
+ if option != 'custom':
+ raise ValueError(f"[{section}] custom_job_script must be 'None' or "
+ f"'custom', not '{option}'")
+
+ env_cmds = config.get(section, 'custom_job_env_cmds')
+ if env_cmds == 'None':
+ raise ValueError(f"[{section}] custom_job_env_cmds must be set when "
+ f"custom_job_script = custom")
+
+ if config.has_option('parallel', 'account'):
+ account = config.get('parallel', 'account')
+ else:
+ account = ''
+
+ if config.has_option('parallel', 'constraints'):
+ constraint = config.getlist('parallel', 'constraints')[0]
+ else:
+ constraint = ''
+
+ cores_per_node = config.getint('parallel', 'cores_per_node')
+ nodes = int(np.ceil(ntasks / cores_per_node))
+
+ model = os.path.basename(config.get('executables', 'model'))
+
+ template = Template(resources.read_text(
+ 'compass.landice.tests.ismip7_run', 'job_script_custom.template'))
+ text = template.render(
+ job_name=job_name, account=account, nodes=f'{nodes}',
+ constraint=constraint, env_cmds=env_cmds, ntasks=ntasks, model=model,
+ parallel_executable=config.get('parallel', 'parallel_executable'))
+
+ with open(os.path.join(work_dir, 'job_script.custom.sh'), 'w') as handle:
+ handle.write(text)
diff --git a/compass/landice/tests/ismip7_run/ismip7_ais/albany_input.yaml b/compass/landice/tests/ismip7_run/ismip7_ais/albany_input.yaml
index e301472436..534ac25fa7 100644
--- a/compass/landice/tests/ismip7_run/ismip7_ais/albany_input.yaml
+++ b/compass/landice/tests/ismip7_run/ismip7_ais/albany_input.yaml
@@ -9,7 +9,7 @@ ANONYMOUS:
Regularization Value: 1.0e-4
LandIce BCs:
BC 0:
- Cubrature Degree: 8
+ Cubature Degree: 8
Basal Friction Coefficient:
Type: Power Law
Power Exponent: 0.33333333333
diff --git a/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais.cfg b/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais.cfg
index 04defefb4c..c84890a8e2 100644
--- a/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais.cfg
+++ b/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais.cfg
@@ -38,16 +38,6 @@ reference_surface_path = NotAvailable
# Path to the region mask file
region_mask_path = NotAvailable
-# Path to the ocean thermal forcing climatology file for CTRL2015 runs.
-# This is the constant-climate 30-year mean (2000-2029) thermal forcing.
-# User has to supply if running ctrl experiments.
-ctrl_tf_climatology_path = NotAvailable
-
-# Path to the atmosphere climatology files for CTRL2015 runs.
-# Directory containing constant-climate SMB, temperature, etc.
-# User has to supply if running ctrl experiments.
-ctrl_atm_climatology_path = NotAvailable
-
# Path to OCX (observationally constrained experiment) forcing.
# User has to supply if running the ocx experiment.
ocx_forcing_path = NotAvailable
@@ -104,5 +94,16 @@ fastiso_mask_filename = None
# Note: for now, resolution finer than 8 km yield numerically unstable results
fastiso_res_km = 8
+# Optionally write job_script.custom.sh, which runs the MALI executable
+# directly (in addition to the standard compass job_script.sh).
+# Options: None (no custom script) or custom
+custom_job_script = None
+
+# Environment commands for the custom job script, as a single line, e.g.
+# "source /path/to/modules.sh; export LD_LIBRARY_PATH=/path/lib:$$LD_LIBRARY_PATH"
+# Write each literal $ as $$ so the config parser does not interpolate it.
+# Required if custom_job_script = custom
+custom_job_env_cmds = None
+
[parallel]
parallel_executable = srun --label --cpu-bind=cores
diff --git a/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais_test.cfg b/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais_test.cfg
index be38585e1d..da4e2d9be5 100644
--- a/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais_test.cfg
+++ b/compass/landice/tests/ismip7_run/ismip7_ais/ismip7_ais_test.cfg
@@ -38,16 +38,6 @@ reference_surface_path = /global/cfs/cdirs/m4288/users/trhille/ISMIP7/forcing/AI
# Path to the region mask file
region_mask_path = /global/cfs/cdirs/fanssie/MALI_projects/ISMIP6-2300/initial_conditions/AIS_4to20km_20230105/AIS_4to20km_r01_20220907.regionMask_ismip6.nc
-# Path to the ocean thermal forcing climatology file for CTRL2015 runs.
-# This is the constant-climate 30-year mean (2000-2029) thermal forcing.
-# User has to supply if running ctrl experiments.
-ctrl_tf_climatology_path = NotAvailable
-
-# Path to the atmosphere climatology files for CTRL2015 runs.
-# Directory containing constant-climate SMB, temperature, etc.
-# User has to supply if running ctrl experiments.
-ctrl_atm_climatology_path = NotAvailable
-
# Path to OCX (observationally constrained experiment) forcing.
# User has to supply if running the ocx experiment.
ocx_forcing_path = NotAvailable
diff --git a/compass/landice/tests/ismip7_run/ismip7_ais/namelist.landice b/compass/landice/tests/ismip7_run/ismip7_ais/namelist.landice
index 498f0b8ebe..b2c127bc8e 100644
--- a/compass/landice/tests/ismip7_run/ismip7_ais/namelist.landice
+++ b/compass/landice/tests/ismip7_run/ismip7_ais/namelist.landice
@@ -65,7 +65,6 @@
config_adaptive_timestep_include_DCFL = .false.
config_adaptive_timestep_force_interval = '0000-01-00_00:00:00'
config_timeaveraging_interval = '0001-00-00_00:00:00'
- config_enable_timeAvgRestarts = .false.
config_do_restart = .true.
config_restart_timestamp_name = 'restart_timestamp'
diff --git a/compass/landice/tests/ismip7_run/ismip7_ais/set_up_experiment.py b/compass/landice/tests/ismip7_run/ismip7_ais/set_up_experiment.py
index 362f836367..d89030b177 100644
--- a/compass/landice/tests/ismip7_run/ismip7_ais/set_up_experiment.py
+++ b/compass/landice/tests/ismip7_run/ismip7_ais/set_up_experiment.py
@@ -6,9 +6,12 @@
from jinja2 import Template
from compass.job import write_job_script
+from compass.landice.tests.ismip7_run.custom_job_script import (
+ write_custom_job_script,
+)
from compass.landice.tests.ismip7_run.gia_options import parse_gia_model
from compass.load_script import symlink_load_script
-from compass.model import make_graph_file, run_model
+from compass.model import make_graph_file, partition, run_model
from compass.step import Step
@@ -93,9 +96,6 @@ def setup(self): # noqa: C901
if scenario == 'ocx':
ocx_forcing_path = section.get('ocx_forcing_path')
forcing_dir = ocx_forcing_path
- elif scenario == 'ctrl':
- # Control run uses climatology forcing
- forcing_dir = None # handled separately below
else:
# Standard ESM-driven experiment
forcing_dir = os.path.join(forcing_basepath,
@@ -117,160 +117,91 @@ def setup(self): # noqa: C901
os.path.basename(reference_surface_path)))
# --- Find and symlink forcing files ---
- if scenario == 'ctrl':
- # Control run: use climatology files
- ctrl_tf_path = section.get('ctrl_tf_climatology_path')
- ctrl_atm_path = section.get('ctrl_atm_climatology_path')
- tf_fname = os.path.split(ctrl_tf_path)[-1]
- os.symlink(ctrl_tf_path,
+ atm_dir = os.path.join(forcing_dir, 'atmosphere')
+ ocean_dir = os.path.join(forcing_dir, 'ocean_thermal_forcing')
+
+ # SMB forcing
+ smb_search = os.path.join(atm_dir, '*SMB_*.nc')
+ smb_list = glob.glob(smb_search)
+ print(f" Found {len(smb_list)} SMB files before filtering")
+ smb_list = [f for f in smb_list if 'gradient' not in f]
+ print(f" Found {len(smb_list)} SMB files after removing "
+ f"gradients")
+ # Filter by mesh name to handle directories with multiple meshes
+ smb_list = [f for f in smb_list if mesh_name in f]
+ print(f" Found {len(smb_list)} SMB files after mesh filter: "
+ f"{smb_list}")
+ if len(smb_list) == 1:
+ smb_fname = os.path.split(smb_list[0])[-1]
+ os.symlink(smb_list[0],
+ os.path.join(self.work_dir, smb_fname))
+ else:
+ sys.exit(f"ERROR: Expected 1 SMB file matching mesh "
+ f"{mesh_name} at {smb_search}, found "
+ f"{len(smb_list)}: {smb_list}")
+
+ # Temperature forcing
+ temp_search = os.path.join(atm_dir, '*temperature_*.nc')
+ temp_list = glob.glob(temp_search)
+ temp_list = [f for f in temp_list if 'gradient' not in f]
+ # Filter by mesh name to handle directories with multiple meshes
+ temp_list = [f for f in temp_list if mesh_name in f]
+ if len(temp_list) == 1:
+ temp_fname = os.path.split(temp_list[0])[-1]
+ os.symlink(temp_list[0],
+ os.path.join(self.work_dir, temp_fname))
+ else:
+ sys.exit(f"ERROR: Expected 1 temperature file matching mesh "
+ f"{mesh_name} at {temp_search}, found "
+ f"{len(temp_list)}")
+
+ # Runoff forcing (optional — may not exist for all experiments)
+ runoff_search = os.path.join(atm_dir, '*runoff_*.nc')
+ runoff_list = glob.glob(runoff_search)
+ # Filter by mesh name to handle directories with multiple meshes
+ runoff_list = [f for f in runoff_list if mesh_name in f]
+ runoff_fname = ''
+ if len(runoff_list) == 1:
+ runoff_fname = os.path.split(runoff_list[0])[-1]
+ os.symlink(runoff_list[0],
+ os.path.join(self.work_dir, runoff_fname))
+
+ # SMB gradient (lapse rate)
+ smb_grad_search = os.path.join(atm_dir, '*SMB_gradient_*.nc')
+ smb_grad_list = glob.glob(smb_grad_search)
+ # Filter by mesh name to handle directories with multiple meshes
+ smb_grad_list = [f for f in smb_grad_list if mesh_name in f]
+ smb_grad_fname = ''
+ if len(smb_grad_list) == 1:
+ smb_grad_fname = os.path.split(smb_grad_list[0])[-1]
+ os.symlink(smb_grad_list[0],
+ os.path.join(self.work_dir, smb_grad_fname))
+
+ # Temperature gradient (lapse rate)
+ temp_grad_search = os.path.join(atm_dir,
+ '*temperature_gradient_*.nc')
+ temp_grad_list = glob.glob(temp_grad_search)
+ # Filter by mesh name to handle directories with multiple meshes
+ temp_grad_list = [f for f in temp_grad_list if mesh_name in f]
+ temp_grad_fname = ''
+ if len(temp_grad_list) == 1:
+ temp_grad_fname = os.path.split(temp_grad_list[0])[-1]
+ os.symlink(temp_grad_list[0],
+ os.path.join(self.work_dir, temp_grad_fname))
+
+ # Thermal forcing
+ tf_search = os.path.join(ocean_dir, '*3dThermalForcing_*.nc')
+ tf_list = glob.glob(tf_search)
+ # Filter by mesh name to handle directories with multiple meshes
+ tf_list = [f for f in tf_list if mesh_name in f]
+ if len(tf_list) == 1:
+ tf_fname = os.path.split(tf_list[0])[-1]
+ os.symlink(tf_list[0],
os.path.join(self.work_dir, tf_fname))
-
- # Find atmosphere climatology files
- smb_files = glob.glob(os.path.join(ctrl_atm_path, '*SMB*.nc'))
- smb_files = [f for f in smb_files if 'gradient' not in f]
- # Filter by mesh name to handle directories with multiple meshes
- smb_files = [f for f in smb_files if mesh_name in f]
- if len(smb_files) == 1:
- smb_fname = os.path.split(smb_files[0])[-1]
- os.symlink(smb_files[0],
- os.path.join(self.work_dir, smb_fname))
- else:
- sys.exit(f"ERROR: Expected 1 SMB climatology file matching "
- f"mesh {mesh_name} in {ctrl_atm_path}, found "
- f"{len(smb_files)}")
-
- temp_files = glob.glob(
- os.path.join(ctrl_atm_path, '*temperature*.nc'))
- temp_files = [f for f in temp_files if 'gradient' not in f]
- # Filter by mesh name to handle directories with multiple meshes
- temp_files = [f for f in temp_files if mesh_name in f]
- if len(temp_files) == 1:
- temp_fname = os.path.split(temp_files[0])[-1]
- os.symlink(temp_files[0],
- os.path.join(self.work_dir, temp_fname))
- else:
- sys.exit(f"ERROR: Expected 1 temperature climatology file "
- f"matching mesh {mesh_name} in {ctrl_atm_path}, "
- f"found {len(temp_files)}")
-
- runoff_files = glob.glob(
- os.path.join(ctrl_atm_path, '*runoff*.nc'))
- # Filter by mesh name to handle directories with multiple meshes
- runoff_files = [f for f in runoff_files if mesh_name in f]
- if len(runoff_files) == 1:
- runoff_fname = os.path.split(runoff_files[0])[-1]
- os.symlink(runoff_files[0],
- os.path.join(self.work_dir, runoff_fname))
- else:
- runoff_fname = '' # runoff may not exist for ctrl
-
- smb_grad_files = glob.glob(
- os.path.join(ctrl_atm_path, '*SMB_gradient*.nc'))
- # Filter by mesh name to handle directories with multiple meshes
- smb_grad_files = [f for f in smb_grad_files if mesh_name in f]
- smb_grad_fname = ''
- if len(smb_grad_files) == 1:
- smb_grad_fname = os.path.split(smb_grad_files[0])[-1]
- os.symlink(smb_grad_files[0],
- os.path.join(self.work_dir, smb_grad_fname))
-
- temp_grad_files = glob.glob(
- os.path.join(ctrl_atm_path, '*temperature_gradient*.nc'))
- # Filter by mesh name to handle directories with multiple meshes
- temp_grad_files = [f for f in temp_grad_files if mesh_name in f]
- temp_grad_fname = ''
- if len(temp_grad_files) == 1:
- temp_grad_fname = os.path.split(temp_grad_files[0])[-1]
- os.symlink(temp_grad_files[0],
- os.path.join(self.work_dir, temp_grad_fname))
-
else:
- # Standard or OCX experiment: find forcing in forcing_dir
- atm_dir = os.path.join(forcing_dir, 'atmosphere')
- ocean_dir = os.path.join(forcing_dir, 'ocean_thermal_forcing')
-
- # SMB forcing
- smb_search = os.path.join(atm_dir, '*SMB_*.nc')
- smb_list = glob.glob(smb_search)
- print(f" Found {len(smb_list)} SMB files before filtering")
- smb_list = [f for f in smb_list if 'gradient' not in f]
- print(f" Found {len(smb_list)} SMB files after removing "
- f"gradients")
- # Filter by mesh name to handle directories with multiple meshes
- smb_list = [f for f in smb_list if mesh_name in f]
- print(f" Found {len(smb_list)} SMB files after mesh filter: "
- f"{smb_list}")
- if len(smb_list) == 1:
- smb_fname = os.path.split(smb_list[0])[-1]
- os.symlink(smb_list[0],
- os.path.join(self.work_dir, smb_fname))
- else:
- sys.exit(f"ERROR: Expected 1 SMB file matching mesh "
- f"{mesh_name} at {smb_search}, found "
- f"{len(smb_list)}: {smb_list}")
-
- # Temperature forcing
- temp_search = os.path.join(atm_dir, '*temperature_*.nc')
- temp_list = glob.glob(temp_search)
- temp_list = [f for f in temp_list if 'gradient' not in f]
- # Filter by mesh name to handle directories with multiple meshes
- temp_list = [f for f in temp_list if mesh_name in f]
- if len(temp_list) == 1:
- temp_fname = os.path.split(temp_list[0])[-1]
- os.symlink(temp_list[0],
- os.path.join(self.work_dir, temp_fname))
- else:
- sys.exit(f"ERROR: Expected 1 temperature file matching mesh "
- f"{mesh_name} at {temp_search}, found "
- f"{len(temp_list)}")
-
- # Runoff forcing (optional — may not exist for all experiments)
- runoff_search = os.path.join(atm_dir, '*runoff_*.nc')
- runoff_list = glob.glob(runoff_search)
- # Filter by mesh name to handle directories with multiple meshes
- runoff_list = [f for f in runoff_list if mesh_name in f]
- runoff_fname = ''
- if len(runoff_list) == 1:
- runoff_fname = os.path.split(runoff_list[0])[-1]
- os.symlink(runoff_list[0],
- os.path.join(self.work_dir, runoff_fname))
-
- # SMB gradient (lapse rate)
- smb_grad_search = os.path.join(atm_dir, '*SMB_gradient_*.nc')
- smb_grad_list = glob.glob(smb_grad_search)
- # Filter by mesh name to handle directories with multiple meshes
- smb_grad_list = [f for f in smb_grad_list if mesh_name in f]
- smb_grad_fname = ''
- if len(smb_grad_list) == 1:
- smb_grad_fname = os.path.split(smb_grad_list[0])[-1]
- os.symlink(smb_grad_list[0],
- os.path.join(self.work_dir, smb_grad_fname))
-
- # Temperature gradient (lapse rate)
- temp_grad_search = os.path.join(atm_dir,
- '*temperature_gradient_*.nc')
- temp_grad_list = glob.glob(temp_grad_search)
- # Filter by mesh name to handle directories with multiple meshes
- temp_grad_list = [f for f in temp_grad_list if mesh_name in f]
- temp_grad_fname = ''
- if len(temp_grad_list) == 1:
- temp_grad_fname = os.path.split(temp_grad_list[0])[-1]
- os.symlink(temp_grad_list[0],
- os.path.join(self.work_dir, temp_grad_fname))
-
- # Thermal forcing
- tf_search = os.path.join(ocean_dir, '*3dThermalForcing_*.nc')
- tf_list = glob.glob(tf_search)
- # Filter by mesh name to handle directories with multiple meshes
- tf_list = [f for f in tf_list if mesh_name in f]
- if len(tf_list) == 1:
- tf_fname = os.path.split(tf_list[0])[-1]
- os.symlink(tf_list[0],
- os.path.join(self.work_dir, tf_fname))
- else:
- sys.exit(f"ERROR: Expected 1 TF file matching mesh "
- f"{mesh_name} at {tf_search}, found "
- f"{len(tf_list)}: {tf_list}")
+ sys.exit(f"ERROR: Expected 1 TF file matching mesh "
+ f"{mesh_name} at {tf_search}, found "
+ f"{len(tf_list)}: {tf_list}")
# --- Find shelf collapse (calving) mask from ismip7_forcing
# fracture Path C ---
@@ -295,18 +226,8 @@ def setup(self): # noqa: C901
mask_fname = ''
# --- Set up streams ---
- # Determine forcing interval
- if scenario == 'ctrl':
- forcing_interval_monthly = 'initial_only'
- forcing_interval_annual = 'initial_only'
- elif is_historical:
- # Historical: read forcing at each interval
- forcing_interval_monthly = '0000-01-00_00:00:00'
- forcing_interval_annual = '0001-00-00_00:00:00'
- else:
- # Projections
- forcing_interval_monthly = '0000-01-00_00:00:00'
- forcing_interval_annual = '0001-00-00_00:00:00'
+ forcing_interval_monthly = '0000-01-00_00:00:00'
+ forcing_interval_annual = '0001-00-00_00:00:00'
stream_replacements = {
'input_file_init_cond': init_cond_fname if is_historical
@@ -481,6 +402,9 @@ def setup(self): # noqa: C901
make_graph_file(mesh_filename=init_cond_path,
graph_filename=os.path.join(self.work_dir,
'graph.info'))
+ # the job script runs MALI directly, so partition now
+ partition(self.ntasks, self.config, self.logger,
+ graph_file=os.path.join(self.work_dir, 'graph.info'))
symlink_load_script(self.work_dir)
@@ -495,6 +419,11 @@ def setup(self): # noqa: C901
pre_run_commands=pre_run_cmd,
post_run_commands=post_run_cmd)
+ write_custom_job_script(self.config, 'ismip7_run_ais',
+ work_dir=self.work_dir,
+ job_name=f'{self.exp}_ais',
+ ntasks=self.ntasks)
+
self.add_model_as_input()
def run(self):
diff --git a/compass/landice/tests/ismip7_run/ismip7_ais/streams.landice.template b/compass/landice/tests/ismip7_run/ismip7_ais/streams.landice.template
index 3b241f685a..e3f9fe09ae 100644
--- a/compass/landice/tests/ismip7_run/ismip7_ais/streams.landice.template
+++ b/compass/landice/tests/ismip7_run/ismip7_ais/streams.landice.template
@@ -13,7 +13,7 @@
filename_interval="output_interval"
clobber_mode="overwrite"
precision="double"
- output_interval="0001-00-00_00:00:00"
+ output_interval="0000-03-00_00:00:00"
reference_time="2000-01-01_00:00:00"
filename_template="rst.$Y-$M-$D.nc"
input_interval="initial_only"
@@ -82,23 +82,14 @@
-
-
-
-
-
-
-
+
+
.nc). Symlink the whole
- # series and address it with a $Y filename_template plus a
- # filename_interval so MALI advances across chunk files.
- for tf_path in tf_3d_list:
- tf_base = os.path.split(tf_path)[-1]
- os.symlink(tf_path,
- os.path.join(self.work_dir, tf_base))
- start_years = []
- for f in tf_3d_list:
- match = re.search(r'_(\d{4})\.nc$',
- os.path.split(f)[-1])
- if not match:
+ sys.exit(f"ERROR: Expected 1 temperature file at "
+ f"{temp_search}, found {len(temp_list)}")
+
+ runoff_search = os.path.join(atm_dir, '*runoff_*.nc')
+ runoff_list = glob.glob(runoff_search)
+ runoff_fname = ''
+ if len(runoff_list) == 1:
+ runoff_fname = os.path.split(runoff_list[0])[-1]
+ os.symlink(runoff_list[0],
+ os.path.join(self.work_dir, runoff_fname))
+
+ smb_grad_search = os.path.join(atm_dir, '*SMB_gradient_*.nc')
+ smb_grad_list = glob.glob(smb_grad_search)
+ smb_grad_fname = ''
+ if len(smb_grad_list) == 1:
+ smb_grad_fname = os.path.split(smb_grad_list[0])[-1]
+ os.symlink(smb_grad_list[0],
+ os.path.join(self.work_dir, smb_grad_fname))
+
+ temp_grad_search = os.path.join(atm_dir,
+ '*temperature_gradient_*.nc')
+ temp_grad_list = glob.glob(temp_grad_search)
+ temp_grad_fname = ''
+ if len(temp_grad_list) == 1:
+ temp_grad_fname = os.path.split(temp_grad_list[0])[-1]
+ os.symlink(temp_grad_list[0],
+ os.path.join(self.work_dir, temp_grad_fname))
+
+ # GrIS thermal forcing: always 2D, plus 3D when
+ # use_3d_thermal_forcing is true (see build_3d_thermal_forcing
+ # in landice/ismip7_forcing/ocean_thermal)
+
+ # 2D thermal forcing (always)
+ tf_2d_search = os.path.join(ocean_dir, '*2dThermalForcing_*.nc')
+ tf_2d_list = sorted(glob.glob(tf_2d_search))
+ if len(tf_2d_list) != 1:
+ sys.exit(f"ERROR: Expected 1 2D TF file at {tf_2d_search}, "
+ f"found {len(tf_2d_list)}")
+ tf_fname = os.path.split(tf_2d_list[0])[-1]
+ os.symlink(tf_2d_list[0],
+ os.path.join(self.work_dir, tf_fname))
+
+ # 3D thermal forcing (optional, only with use_3d_thermal_forcing)
+ if use_3d_thermal_forcing:
+ tf_3d_search = os.path.join(ocean_dir, '*3dThermalForcing_*.nc')
+ tf_3d_list = sorted(glob.glob(tf_3d_search))
+ if len(tf_3d_list) == 0:
+ sys.exit(f"ERROR: Expected at least 1 3D TF file at "
+ f"{tf_3d_search}, found 0")
+ # 3D TF is written one file per N-year block, named by the
+ # block start year (..._.nc). Symlink the whole
+ # series and address it with a $Y filename_template plus a
+ # filename_interval so MALI advances across chunk files.
+ for tf_path in tf_3d_list:
+ tf_base = os.path.split(tf_path)[-1]
+ os.symlink(tf_path,
+ os.path.join(self.work_dir, tf_base))
+ start_years = []
+ for f in tf_3d_list:
+ match = re.search(r'_(\d{4})\.nc$',
+ os.path.split(f)[-1])
+ if not match:
+ sys.exit(
+ f"ERROR: 3D thermal forcing file does not "
+ f"match expected pattern *_YYYY.nc: {f}")
+ start_years.append(int(match.group(1)))
+ start_years = sorted(start_years)
+ if len(set(start_years)) != len(start_years):
+ sys.exit(
+ f"ERROR: Multiple 3D thermal forcing files share a "
+ f"start year in {ocean_dir}. Keep only one version "
+ f"of the 3D TF series in this directory.")
+ # Align the stream's file boundaries with the first chunk
+ tf_3d_reference_time = f"{start_years[0]:04d}-01-01_00:00:00"
+ sample = os.path.split(tf_3d_list[0])[-1]
+ tf_3d_fname = re.sub(r'_\d{4}\.nc$', '_$Y.nc', sample)
+ if len(start_years) > 1:
+ interval_years = start_years[1] - start_years[0]
+ # Validate uniform spacing across all chunks
+ for i in range(2, len(start_years)):
+ spacing = start_years[i] - start_years[i - 1]
+ if spacing != interval_years:
sys.exit(
- f"ERROR: 3D thermal forcing file does not "
- f"match expected pattern *_YYYY.nc: {f}")
- start_years.append(int(match.group(1)))
- start_years = sorted(start_years)
- sample = os.path.split(tf_3d_list[0])[-1]
- tf_3d_fname = re.sub(r'_\d{4}\.nc$', '_$Y.nc', sample)
- if len(start_years) > 1:
- interval_years = start_years[1] - start_years[0]
- # Validate uniform spacing across all chunks
- for i in range(2, len(start_years)):
- spacing = start_years[i] - start_years[i - 1]
- if spacing != interval_years:
- sys.exit(
- f"ERROR: 3D thermal forcing chunk years "
- f"are not uniformly spaced. Expected "
- f"interval {interval_years} years, but "
- f"chunks {start_years[i - 1]} and "
- f"{start_years[i]} are {spacing} years "
- f"apart.")
- tf_3d_filename_interval = \
- f"{interval_years:04d}-00-00_00:00:00"
- else:
- tf_3d_fname = ''
+ f"ERROR: 3D thermal forcing chunk years "
+ f"are not uniformly spaced. Expected "
+ f"interval {interval_years} years, but "
+ f"chunks {start_years[i - 1]} and "
+ f"{start_years[i]} are {spacing} years "
+ f"apart.")
+ tf_3d_filename_interval = \
+ f"{interval_years:04d}-00-00_00:00:00"
+ else:
+ tf_3d_fname = ''
# --- Set up streams ---
- if scenario == 'ctrl':
- forcing_interval_monthly = 'initial_only'
- forcing_interval_annual = 'initial_only'
- forcing_interval_TF = 'initial_only'
- else:
- forcing_interval_monthly = '0000-01-00_00:00:00'
- forcing_interval_annual = '0001-00-00_00:00:00'
- # GrIS thermal forcing (2D and 3D) is monthly. The annual
- # cadence only applies to Antarctica, whose ISMIP7 3D forcing is
- # provided annually.
- forcing_interval_TF = forcing_interval_monthly
+ forcing_interval_monthly = '0000-01-00_00:00:00'
+ forcing_interval_annual = '0001-00-00_00:00:00'
+ # GrIS thermal forcing (2D and 3D) is monthly. The annual
+ # cadence only applies to Antarctica, whose ISMIP7 3D forcing is
+ # provided annually.
+ forcing_interval_TF = forcing_interval_monthly
stream_replacements = {
'input_file_init_cond': init_cond_fname if is_historical
@@ -317,6 +251,7 @@ def setup(self): # noqa: C901
'forcing_interval_annual': forcing_interval_annual,
'forcing_interval_TF': forcing_interval_TF,
'tf_3d_filename_interval': tf_3d_filename_interval,
+ 'tf_3d_reference_time': tf_3d_reference_time,
'use_3d_thermal_forcing': use_3d_thermal_forcing,
}
@@ -383,6 +318,9 @@ def setup(self): # noqa: C901
make_graph_file(mesh_filename=init_cond_path,
graph_filename=os.path.join(self.work_dir,
'graph.info'))
+ # the job script runs MALI directly, so partition now
+ partition(self.ntasks, self.config, self.logger,
+ graph_file=os.path.join(self.work_dir, 'graph.info'))
symlink_load_script(self.work_dir)
@@ -397,6 +335,11 @@ def setup(self): # noqa: C901
pre_run_commands=pre_run_cmd,
post_run_commands=post_run_cmd)
+ write_custom_job_script(self.config, 'ismip7_run_gris',
+ work_dir=self.work_dir,
+ job_name=f'{self.exp}_gris',
+ ntasks=self.ntasks)
+
self.add_model_as_input()
def run(self):
diff --git a/compass/landice/tests/ismip7_run/ismip7_gris/streams.landice.template b/compass/landice/tests/ismip7_run/ismip7_gris/streams.landice.template
index 348ae99e7f..4fd37cc186 100644
--- a/compass/landice/tests/ismip7_run/ismip7_gris/streams.landice.template
+++ b/compass/landice/tests/ismip7_run/ismip7_gris/streams.landice.template
@@ -13,7 +13,7 @@
filename_interval="output_interval"
clobber_mode="overwrite"
precision="double"
- output_interval="0001-00-00_00:00:00"
+ output_interval="0000-03-00_00:00:00"
reference_time="2000-01-01_00:00:00"
filename_template="rst.$Y-$M-$D.nc"
input_interval="initial_only"
@@ -78,7 +78,7 @@
filename_template="{{ input_file_TF_3d_forcing }}"
filename_interval="{{ tf_3d_filename_interval }}"
input_interval="{{ forcing_interval_TF }}"
- reference_time="2000-01-01_00:00:00"
+ reference_time="{{ tf_3d_reference_time }}"
runtime_format="single_file">
@@ -144,6 +144,21 @@
+
+
+
+
+
+
+
+
+
_``, with
+``qos=debug`` and a 30-minute wall time (edit the script for production
+runs). Nodes come from ``ntasks`` and ``cores_per_node``. The script archives
+any existing logs, runs ``custom_job_env_cmds``, and calls
+`` -n ./landice_model``, so the executable is
+the one linked in the run directory (compass's own MALI or the one given with
+``-p`` to ``compass setup``). Write each literal ``$`` in
+``custom_job_env_cmds`` as ``$$``, since the config parser interpolates
+``$``. ``ismip7_gris_pm_production.cfg`` enables this option.
+
.. _landice_ismip7_run_forcing_streams:
Forcing Streams
@@ -288,8 +313,9 @@ ISMIP7 uses more forcing fields than ISMIP6, at mixed temporal resolutions:
* ``ismip6shelfMelt_deltaT``, ``ismip6shelfMelt_basin``,
``ismip6shelfMelt_gamma0`` — melt parameterization coefficients
-For CTRL2015 experiments, all forcing intervals are set to
-``initial_only`` (constant climate).
+The CTRL2015 experiments use the same forcing layout and forcing
+intervals as the other experiments, with forcing taken from
+``{forcing_basepath}/{model}_ctrl``.
.. _landice_ismip7_run_mask_calving: