Skip to content

Commit

Permalink
Merge pull request #843 from xylar/reduce-metadata-in-tests
Browse files Browse the repository at this point in the history
Only add metadata to forward runs when useful
  • Loading branch information
xylar authored Jul 11, 2024
2 parents 498e3f2 + becbeaa commit a9c70f8
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion compass/ocean/tests/global_ocean/analysis_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion compass/ocean/tests/global_ocean/decomp_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 16 additions & 6 deletions compass/ocean/tests/global_ocean/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 4 additions & 2 deletions compass/ocean/tests/global_ocean/performance_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compass/ocean/tests/global_ocean/restart_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion compass/ocean/tests/global_ocean/threads_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a9c70f8

Please sign in to comment.