diff --git a/compass/ocean/suites/pr.txt b/compass/ocean/suites/pr.txt index ed5bc7c90c..882a447fd6 100644 --- a/compass/ocean/suites/pr.txt +++ b/compass/ocean/suites/pr.txt @@ -15,6 +15,12 @@ ocean/global_ocean/QU240/PHC/restart_test ocean/global_ocean/QU240/PHC/decomp_test ocean/global_ocean/QU240/PHC/threads_test ocean/global_ocean/QU240/PHC/analysis_test +ocean/global_ocean/QU240/PHC/analysis_test +ocean/global_ocean/QU240/PHC/analysis_test +ocean/global_ocean/QU240/PHC/daily_analysis_restart +ocean/global_ocean/QU240/PHC/daily_model_restart +ocean/global_ocean/QU240/PHC/monthly_analysis_restart +ocean/global_ocean/QU240/PHC/monthly_model_restart ocean/global_ocean/QU240/PHC/dynamic_adjustment ocean/global_ocean/QU240/PHC/files_for_e3sm diff --git a/compass/ocean/suites/time_series_stats.txt b/compass/ocean/suites/time_series_stats.txt new file mode 100644 index 0000000000..3963e73054 --- /dev/null +++ b/compass/ocean/suites/time_series_stats.txt @@ -0,0 +1,8 @@ +ocean/global_ocean/QU240/mesh +ocean/global_ocean/QU240/PHC/init +ocean/global_ocean/QU240/PHC/daily_analysis_restart +ocean/global_ocean/QU240/PHC/daily_model_restart +ocean/global_ocean/QU240/PHC/monthly_analysis_restart +ocean/global_ocean/QU240/PHC/monthly_model_restart +ocean/global_ocean/QU240/PHC/daily_output_test +ocean/global_ocean/QU240/PHC/monthly_output_test diff --git a/compass/ocean/tests/global_ocean/__init__.py b/compass/ocean/tests/global_ocean/__init__.py index a394b3bf64..8e840fb9a1 100644 --- a/compass/ocean/tests/global_ocean/__init__.py +++ b/compass/ocean/tests/global_ocean/__init__.py @@ -18,6 +18,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.time_series_stats_restart_test import \ + TimeSeriesStatsRestartTest from compass.ocean.tests.global_ocean.monthly_output_test import \ MonthlyOutputTest from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM @@ -72,10 +74,26 @@ def __init__(self, mpas_core): DailyOutputTest( test_group=self, mesh=mesh, init=init, time_integrator=time_integrator)) + self.add_test_case( + TimeSeriesStatsRestartTest( + test_group=self, mesh=mesh, init=init, analysis='Daily', + with_analysis_restart=True)) + self.add_test_case( + TimeSeriesStatsRestartTest( + test_group=self, mesh=mesh, init=init, analysis='Daily', + with_analysis_restart=False)) self.add_test_case( MonthlyOutputTest( test_group=self, mesh=mesh, init=init, time_integrator=time_integrator)) + self.add_test_case( + TimeSeriesStatsRestartTest( + test_group=self, mesh=mesh, init=init, analysis='Monthly', + with_analysis_restart=True)) + self.add_test_case( + TimeSeriesStatsRestartTest( + test_group=self, mesh=mesh, init=init, analysis='Monthly', + with_analysis_restart=False)) dynamic_adjustment = QU240DynamicAdjustment( test_group=self, mesh=mesh, init=init, diff --git a/compass/ocean/tests/global_ocean/time_series_stats_restart_test/__init__.py b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/__init__.py new file mode 100644 index 0000000000..c82607f3bb --- /dev/null +++ b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/__init__.py @@ -0,0 +1,126 @@ +from compass.validate import compare_variables +from compass.ocean.tests.global_ocean.forward import ForwardTestCase, \ + ForwardStep + + +class TimeSeriesStatsRestartTest(ForwardTestCase): + """ + A test case to test bit-for-bit restart capabilities from the + TimeSeriesStats analysis members in E3SM. + + Attributes + ---------- + analysis : {'Daily', 'Monthly'} + The suffix for the ``timeSeriesStats`` analysis member to check. + + """ + + def __init__(self, test_group, mesh, init, analysis, + with_analysis_restart): + """ + 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 + + analysis : {'Daily', 'Monthly'} + The suffix for the ``timeSeriesStats`` analysis member to check. + + with_analysis_restart : bool + Whether to save a restart file from ``timeSeriesStats`` + """ + if with_analysis_restart: + name = f'{analysis.lower()}_analysis_restart' + else: + name = f'{analysis.lower()}_model_restart' + time_integrator = 'split_explicit' + super().__init__(test_group=test_group, mesh=mesh, init=init, + time_integrator=time_integrator, name=name) + module = self.__module__ + self.analysis = analysis + + output_interval = '0000-00-00_04:00:00' + + restart_filename = '../restarts/rst.0001-01-01_04.00.00.nc' + if with_analysis_restart: + analysis_restart_filename = \ + f'../restarts/rst.timeSeriesStats{analysis}.0001-01-01_04.00.00.nc' + analysis_restart_input_interval = 'initial_only' + analysis_restart_output_interval = 'stream:restart:output_interval' + else: + analysis_restart_filename = None + analysis_restart_input_interval = 'none' + analysis_restart_output_interval = 'none' + analysis_filename = \ + f'analysis_members/mpaso.hist.am.timeSeriesStats{analysis}.0001-01-01_04.00.00.nc' + + replacements = dict( + analysis=analysis, + output_interval=output_interval, + analysis_restart_input_interval=analysis_restart_input_interval, + analysis_restart_output_interval=analysis_restart_output_interval) + + namelist_options = { + f'config_AM_timeSeriesStats{analysis}_enable': '.true.', + f'config_AM_timeSeriesStats{analysis}_compute_on_startup': '.false.', + f'config_AM_timeSeriesStats{analysis}_write_on_startup': '.false.', + f'config_AM_timeSeriesStats{analysis}_compute_interval': "'00-00-00_01:00:00'", + f'config_AM_timeSeriesStats{analysis}_reset_intervals': "'00-00-00_04:00:00'", + f'config_AM_timeSeriesStats{analysis}_backward_output_offset': "'00-00-00_04:00:00'"} + + if not with_analysis_restart: + namelist_options[f'config_AM_timeSeriesStats{analysis}_restart_stream'] = "'none'" + + for part in ['full', 'restart']: + name = f'{part}_run' + step = ForwardStep(test_case=self, mesh=mesh, init=init, + time_integrator=time_integrator, name=name, + subdir=name, ntasks=4, openmp_threads=1) + + step.add_namelist_file(module, f'namelist.{part}') + step.add_namelist_options(namelist_options) + step.add_streams_file(module, 'streams.forward', + template_replacements=replacements) + if part == 'full': + step.add_output_file(restart_filename) + if analysis_restart_filename is not None: + step.add_output_file(analysis_restart_filename) + else: + step.add_input_file(restart_filename) + if analysis_restart_filename is not None: + step.add_input_file(analysis_restart_filename) + step.add_output_file(analysis_filename) + self.add_step(step) + + def validate(self): + """ + Test cases can override this method to perform validation of variables + and timers + """ + analysis = self.analysis + variables = [ + 'Time', 'Time_bnds', + f'time{analysis}_avg_normalVelocity', + f'time{analysis}_avg_ssh'] + + if analysis == 'Monthly': + variables.extend([ + f'time{analysis}_avg_activeTracers_temperature', + f'time{analysis}_avg_activeTracers_salinity', + f'time{analysis}_avg_layerThickness']) + + analysis_filename = \ + f'analysis_members/mpaso.hist.am.timeSeriesStats{analysis}.0001-01-01_04.00.00.nc' + + compare_variables( + test_case=self, variables=variables, + filename1=f'full_run/{analysis_filename}', + filename2=f'restart_run/{analysis_filename}') diff --git a/compass/ocean/tests/global_ocean/time_series_stats_restart_test/namelist.full b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/namelist.full new file mode 100644 index 0000000000..b9c81da623 --- /dev/null +++ b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/namelist.full @@ -0,0 +1,4 @@ +config_start_time = '0001-01-01_00:00:00' +config_run_duration = '08:00:00' +config_dt = '00:30:00' +config_do_restart = .false. diff --git a/compass/ocean/tests/global_ocean/time_series_stats_restart_test/namelist.restart b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/namelist.restart new file mode 100644 index 0000000000..b7c15dcb0a --- /dev/null +++ b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/namelist.restart @@ -0,0 +1,4 @@ +config_start_time = '0001-01-01_04:00:00' +config_run_duration = '04:00:00' +config_dt = '00:30:00' +config_do_restart = .true. diff --git a/compass/ocean/tests/global_ocean/time_series_stats_restart_test/streams.forward b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/streams.forward new file mode 100644 index 0000000000..fe00ac99b7 --- /dev/null +++ b/compass/ocean/tests/global_ocean/time_series_stats_restart_test/streams.forward @@ -0,0 +1,26 @@ + + + + + + + + + + + + +