From becbeaa53fbf81ae2337f55a19e043eade0b334e Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 11 Jul 2024 03:20:24 -0500 Subject: [PATCH] Only add metadata to forward runs when useful A lot of time is being taken to add metadata to output files during regression testing, even though that metadata will not be used by anyone and is not very useful. We only want to be adding metadata to mesh files, initial conditions, outputs from dynamic adjustment and files staged for use as initial conditions in E3SM. --- .../global_ocean/analysis_test/__init__.py | 2 +- .../daily_output_test/__init__.py | 2 +- .../global_ocean/decomp_test/__init__.py | 3 ++- .../dynamic_adjustment/__init__.py | 3 ++- .../write_coeffs_reconstruct/__init__.py | 2 +- compass/ocean/tests/global_ocean/forward.py | 22 ++++++++++++++----- .../monthly_output_test/__init__.py | 2 +- .../global_ocean/performance_test/__init__.py | 6 +++-- .../global_ocean/restart_test/__init__.py | 2 +- .../global_ocean/threads_test/__init__.py | 3 ++- 10 files changed, 31 insertions(+), 16 deletions(-) diff --git a/compass/ocean/tests/global_ocean/analysis_test/__init__.py b/compass/ocean/tests/global_ocean/analysis_test/__init__.py index 558e11ae6d..9d0bfa594c 100644 --- a/compass/ocean/tests/global_ocean/analysis_test/__init__.py +++ b/compass/ocean/tests/global_ocean/analysis_test/__init__.py @@ -45,7 +45,7 @@ def __init__(self, test_group, mesh, init, time_integrator): step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, ntasks=4, - openmp_threads=1) + openmp_threads=1, add_metadata=False) self.variables = { 'output.nc': diff --git a/compass/ocean/tests/global_ocean/daily_output_test/__init__.py b/compass/ocean/tests/global_ocean/daily_output_test/__init__.py index c068e36226..1434f53d9e 100644 --- a/compass/ocean/tests/global_ocean/daily_output_test/__init__.py +++ b/compass/ocean/tests/global_ocean/daily_output_test/__init__.py @@ -36,7 +36,7 @@ def __init__(self, test_group, mesh, init, time_integrator): step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, ntasks=4, - openmp_threads=1) + openmp_threads=1, add_metadata=False) module = self.__module__ step.add_output_file(filename='output.nc') diff --git a/compass/ocean/tests/global_ocean/decomp_test/__init__.py b/compass/ocean/tests/global_ocean/decomp_test/__init__.py index 3b6fa53163..db368a77a4 100644 --- a/compass/ocean/tests/global_ocean/decomp_test/__init__.py +++ b/compass/ocean/tests/global_ocean/decomp_test/__init__.py @@ -36,7 +36,8 @@ def __init__(self, test_group, mesh, init, time_integrator): name = '{}proc'.format(procs) step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, name=name, - subdir=name, ntasks=procs, openmp_threads=1) + subdir=name, ntasks=procs, openmp_threads=1, + add_metadata=False) step.add_output_file(filename='output.nc') self.add_step(step) diff --git a/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py b/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py index f7c29d7723..b4ea1fda18 100644 --- a/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py +++ b/compass/ocean/tests/global_ocean/dynamic_adjustment/__init__.py @@ -174,7 +174,8 @@ def _add_step(self, step_name, options, get_dt_from_min_res, time_integrator=time_integrator, name=step_name, subdir=step_name, land_ice_flux_mode=land_ice_flux_mode, - get_dt_from_min_res=get_dt_from_min_res) + get_dt_from_min_res=get_dt_from_min_res, + add_metadata=True) namelist_options = dict(shared_options) if previous_restart_filename is None: diff --git a/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/__init__.py b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/__init__.py index aad68b2adb..4d88be50e9 100644 --- a/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/__init__.py +++ b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/__init__.py @@ -31,7 +31,7 @@ def __init__(self, test_case, mesh, init): """ super().__init__(test_case=test_case, mesh=mesh, init=init, time_integrator='split_explicit_ab2', - name='write_coeffs_reconstruct') + name='write_coeffs_reconstruct', add_metadata=False) package = 'compass.ocean.tests.global_ocean.files_for_e3sm.' \ 'write_coeffs_reconstruct' diff --git a/compass/ocean/tests/global_ocean/forward.py b/compass/ocean/tests/global_ocean/forward.py index 22c4ca3ca3..67661b5ed9 100644 --- a/compass/ocean/tests/global_ocean/forward.py +++ b/compass/ocean/tests/global_ocean/forward.py @@ -39,7 +39,8 @@ class ForwardStep(Step): def __init__(self, test_case, mesh, time_integrator, init=None, name='forward', subdir=None, ntasks=None, min_tasks=None, openmp_threads=None, get_dt_from_min_res=True, - land_ice_flux_mode='pressure_only', **kwargs): + land_ice_flux_mode='pressure_only', add_metadata=True, + **kwargs): """ Create a new step @@ -75,18 +76,26 @@ def __init__(self, test_case, mesh, time_integrator, init=None, openmp_threads : int, optional the number of OpenMP threads the step will use - get_dt_from_min_res : bool - Whether to automatically compute `config_dt` and `config_btr_dt` - namelist options from the minimum resolution of the mesh + get_dt_from_min_res : bool, optional + Whether to automatically compute ``config_dt`` and + ``config_btr_dt`` namelist options from the minimum resolution of + the mesh land_ice_flux_mode : {'pressure_only', 'standalone', 'data'}, optional Whether to have no ice-shelf melt fluxes ("pressure_only"), prognostic melt ("standalone") or data melt from a satellite-derived climatology ("data"). + + add_metadata : bool, optional + Whether to add mesh and initial-condition metadata to output files + (assuming the ``add_metadata`` config option is also set to True). + This should be set to ``False`` for regression tests where the + metadata is unlikely to be used. """ self.mesh = mesh self.init = init self.time_integrator = time_integrator + self.add_metadata = add_metadata if min_tasks is None: min_tasks = ntasks super().__init__(test_case=test_case, name=name, subdir=subdir, @@ -213,8 +222,9 @@ def run(self): update_pio = self.config.getboolean('global_ocean', 'forward_update_pio') run_model(self, update_pio=update_pio) - add_mesh_and_init_metadata(self.outputs, self.config, - init_filename='init.nc') + if self.add_metadata: + add_mesh_and_init_metadata(self.outputs, self.config, + init_filename='init.nc') def _get_dts(self): """ diff --git a/compass/ocean/tests/global_ocean/monthly_output_test/__init__.py b/compass/ocean/tests/global_ocean/monthly_output_test/__init__.py index 1f8ed750f4..04bee17cca 100644 --- a/compass/ocean/tests/global_ocean/monthly_output_test/__init__.py +++ b/compass/ocean/tests/global_ocean/monthly_output_test/__init__.py @@ -35,7 +35,7 @@ def __init__(self, test_group, mesh, init, time_integrator): step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, ntasks=4, - openmp_threads=1) + openmp_threads=1, add_metadata=False) module = self.__module__ step.add_output_file(filename='output.nc') diff --git a/compass/ocean/tests/global_ocean/performance_test/__init__.py b/compass/ocean/tests/global_ocean/performance_test/__init__.py index f1afa06061..4d96dc1228 100644 --- a/compass/ocean/tests/global_ocean/performance_test/__init__.py +++ b/compass/ocean/tests/global_ocean/performance_test/__init__.py @@ -44,14 +44,16 @@ def __init__(self, test_group, mesh, init, time_integrator): step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, name=step_name, - land_ice_flux_mode=flux_mode) + land_ice_flux_mode=flux_mode, + add_metadata=False) step.add_streams_file(this_module, 'streams.wisc') step.add_output_file(filename='land_ice_fluxes.nc') step.add_output_file(filename='output.nc') self.add_step(step) else: step = ForwardStep(test_case=self, mesh=mesh, init=init, - time_integrator=time_integrator) + time_integrator=time_integrator, + add_metadata=False) step.add_output_file(filename='output.nc') self.add_step(step) diff --git a/compass/ocean/tests/global_ocean/restart_test/__init__.py b/compass/ocean/tests/global_ocean/restart_test/__init__.py index d81884b1d8..7076715924 100644 --- a/compass/ocean/tests/global_ocean/restart_test/__init__.py +++ b/compass/ocean/tests/global_ocean/restart_test/__init__.py @@ -45,7 +45,7 @@ def __init__(self, test_group, mesh, init, time_integrator): step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, name=name, subdir=name, ntasks=4, openmp_threads=1, - get_dt_from_min_res=False) + get_dt_from_min_res=False, add_metadata=False) suffix = '{}.{}'.format(time_integrator.lower(), part) step.add_namelist_file(module, 'namelist.{}'.format(suffix)) diff --git a/compass/ocean/tests/global_ocean/threads_test/__init__.py b/compass/ocean/tests/global_ocean/threads_test/__init__.py index 7cba0ebca1..913dc0d98d 100644 --- a/compass/ocean/tests/global_ocean/threads_test/__init__.py +++ b/compass/ocean/tests/global_ocean/threads_test/__init__.py @@ -37,7 +37,8 @@ def __init__(self, test_group, mesh, init, time_integrator): step = ForwardStep(test_case=self, mesh=mesh, init=init, time_integrator=time_integrator, name=name, subdir=name, ntasks=4, - openmp_threads=openmp_threads) + openmp_threads=openmp_threads, + add_metadata=False) step.add_output_file(filename='output.nc') self.add_step(step)