Skip to content

Commit

Permalink
Add a step for writing reconstruction coefficients
Browse files Browse the repository at this point in the history
The coefficients are used to construct 3D Cartesian as well as
zonal and meridional components of a field at cell centers from
the normal component of the field at edges.
  • Loading branch information
xylar committed Oct 15, 2023
1 parent 030ddd4 commit ffc1eef
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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}')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config_run_duration = '0000_00:00:01'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<streams>

<stream name="coeffs_reconstruct"
type="output"
filename_template="coeffs_reconstruct.nc"
output_interval="0000_00:00:01"
reference_time="0001-01-01_00:00:00"
clobber_mode="truncate">

<var name="coeffs_reconstruct"/>
</stream>

</streams>

0 comments on commit ffc1eef

Please sign in to comment.