Skip to content

Commit

Permalink
Add new monthly_output_test on QU240 mesh
Browse files Browse the repository at this point in the history
This can be used to test the `timeSeriesStatsMonthly` analysis
member.
  • Loading branch information
xylar committed Jun 17, 2022
1 parent 5584b9d commit 57d23ab
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compass/ocean/tests/global_ocean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from compass.ocean.tests.global_ocean.threads_test import ThreadsTest
from compass.ocean.tests.global_ocean.analysis_test import AnalysisTest
from compass.ocean.tests.global_ocean.daily_output_test import DailyOutputTest
from compass.ocean.tests.global_ocean.monthly_output_test import \
MonthlyOutputTest
from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM
from compass.ocean.tests.global_ocean.make_diagnostics_files import \
MakeDiagnosticsFiles
Expand Down Expand Up @@ -68,6 +70,10 @@ def __init__(self, mpas_core):
DailyOutputTest(
test_group=self, mesh=mesh, init=init,
time_integrator=time_integrator))
self.add_test_case(
MonthlyOutputTest(
test_group=self, mesh=mesh, init=init,
time_integrator=time_integrator))

dynamic_adjustment = QU240DynamicAdjustment(
test_group=self, mesh=mesh, init=init,
Expand Down
64 changes: 64 additions & 0 deletions compass/ocean/tests/global_ocean/monthly_output_test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from compass.validate import compare_variables
from compass.ocean.tests.global_ocean.forward import ForwardTestCase, \
ForwardStep


class MonthlyOutputTest(ForwardTestCase):
"""
A test case to test the output for the TimeSeriesStatMonthly analysis
member in E3SM.
"""

def __init__(self, test_group, mesh, init, time_integrator):
"""
Create test case
Parameters
----------
test_group : compass.ocean.tests.global_ocean.GlobalOcean
The global ocean test group that this test case 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
time_integrator : {'split_explicit', 'RK4'}
The time integrator to use for the forward run
"""
super().__init__(test_group=test_group, mesh=mesh, init=init,
time_integrator=time_integrator,
name='monthly_output_test')

step = ForwardStep(test_case=self, mesh=mesh, init=init,
time_integrator=time_integrator, cores=4,
threads=1)

module = self.__module__
step.add_output_file(filename='output.nc')
step.add_output_file(
filename='analysis_members/'
'mpaso.hist.am.timeSeriesStatsMonthly.0001-01-01.nc')
step.add_namelist_file(module, 'namelist.forward')
if mesh.mesh_name in ['QU240', 'QUwISC240']:
# a shorter time step is needed to prevent crashes
step.add_namelist_options(dict(config_dt='00:30:00'))
step.add_streams_file(module, 'streams.forward')
self.add_step(step)

def validate(self):
"""
Test cases can override this method to perform validation of variables
and timers
"""
variables = [
'timeMonthly_avg_activeTracers_temperature',
'timeMonthly_avg_activeTracers_salinity',
'timeMonthly_avg_layerThickness', 'timeMonthly_avg_normalVelocity',
'timeMonthly_avg_ssh']

compare_variables(
test_case=self, variables=variables,
filename1='forward/analysis_members/'
'mpaso.hist.am.timeSeriesStatsMonthly.0001-01-01.nc')
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config_run_duration = '0000-01-00_00:00:00'
config_AM_timeSeriesStatsMonthly_enable = .true.
config_AM_timeSeriesStatsMonthly_restart_stream = 'none'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<streams>

<stream name="timeSeriesStatsMonthlyOutput"
type="output"
precision="double"
filename_template="analysis_members/mpaso.hist.am.timeSeriesStatsMonthly.$Y-$M-$D.nc"
output_interval="00-01-00_00:00:00"
clobber_mode="truncate">
</stream>

</streams>

0 comments on commit 57d23ab

Please sign in to comment.