diff --git a/compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py b/compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py index 5bbe6c2851..72ab2abef3 100644 --- a/compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py +++ b/compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py @@ -38,6 +38,9 @@ from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_mesh import ( # noqa: E501 SeaiceMesh, ) +from compass.ocean.tests.global_ocean.files_for_e3sm.write_coeffs_reconstruct import ( # noqa: E501 + WriteCoeffsReconstruct, +) from compass.ocean.tests.global_ocean.forward import get_forward_subdir from compass.testcase import TestCase @@ -115,6 +118,10 @@ def __init__(self, test_group, mesh=None, init=None, self.add_step(RemapIcebergClimatology( test_case=self)) + if mesh is not None and init is not None: + self.add_step(WriteCoeffsReconstruct( + test_case=self, mesh=mesh, init=init)) + def configure(self): """ Modify the configuration options for this test case 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 new file mode 100644 index 0000000000..00cb3610b4 --- /dev/null +++ b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/__init__.py @@ -0,0 +1,56 @@ +import os + +from compass.io import symlink +from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501 + FilesForE3SMStep, +) +from compass.ocean.tests.global_ocean.forward import ForwardStep + + +class WriteCoeffsReconstruct(ForwardStep, FilesForE3SMStep): + """ + A step for writing out ``coeffs_reconstruct`` for a given MPAS mesh + """ + + def __init__(self, test_case, mesh, init): + """ + Create a new step + + Parameters + ---------- + test_case : compass.TestCase + The test case this step belongs to + + mesh : compass.ocean.tests.global_ocean.mesh.Mesh + The test case that produces the mesh for this run + + init : compass.ocean.tests.global_ocean.init.Init + The test case that produces the initial condition for this run + """ + super().__init__(test_case=test_case, mesh=mesh, init=init, + time_integrator='split_explicit', + name='write_coeffs_reconstruct') + + package = 'compass.ocean.tests.global_ocean.files_for_e3sm.' \ + 'write_coeffs_reconstruct' + + self.add_namelist_file(package, 'namelist.reconstruct') + self.add_streams_file(package, 'streams.reconstruct') + + def run(self): + """ + Run this step of the testcase + """ + super().run() + + reconstruct_dir = \ + '../assembled_files/diagnostics/mpas_analysis/reconstruct' + try: + os.makedirs(reconstruct_dir) + except FileExistsError: + pass + + reconstruct_filename = f'{self.mesh_short_name}_coeffs_reconstruct.nc' + # make links in diagnostics directory + symlink(os.path.abspath('coeffs_reconstruct.nc'), + f'{reconstruct_dir}/{reconstruct_filename}') diff --git a/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/namelist.reconstruct b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/namelist.reconstruct new file mode 100644 index 0000000000..991b7ca114 --- /dev/null +++ b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/namelist.reconstruct @@ -0,0 +1 @@ +config_run_duration = '0000_00:00:01' diff --git a/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/streams.reconstruct b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/streams.reconstruct new file mode 100644 index 0000000000..bf88ca7c7c --- /dev/null +++ b/compass/ocean/tests/global_ocean/files_for_e3sm/write_coeffs_reconstruct/streams.reconstruct @@ -0,0 +1,13 @@ + + + + + + + +