Source code for compass.ocean.tests.baroclinic_channel.rpe_test

from compass.testcase import TestCase
from compass.ocean.tests.baroclinic_channel.initial_state import InitialState
from compass.ocean.tests.baroclinic_channel.forward import Forward
from compass.ocean.tests.baroclinic_channel.rpe_test.analysis import Analysis
from compass.ocean.tests import baroclinic_channel


[docs] class RpeTest(TestCase): """ The reference potential energy (RPE) test case for the baroclinic channel test group performs a 20-day integration of the model forward in time at 5 different values of the viscosity at the given resolution. Attributes ---------- resolution : str The resolution of the test case """
[docs] def __init__(self, test_group, resolution): """ Create the test case Parameters ---------- test_group : compass.ocean.tests.baroclinic_channel.BaroclinicChannel The test group that this test case belongs to resolution : str The resolution of the test case """ name = 'rpe_test' subdir = f'{resolution}/{name}' super().__init__(test_group=test_group, name=name, subdir=subdir) self.resolution = resolution
[docs] def configure(self): """ Modify the configuration options for this test case. """ resolution = self.resolution config = self.config baroclinic_channel.configure(resolution, config) res_params = {'1km': {'ntasks': 144, 'min_tasks': 36}, '4km': {'ntasks': 36, 'min_tasks': 8}, '10km': {'ntasks': 8, 'min_tasks': 4}} if resolution not in res_params: raise ValueError( f'Unsupported resolution {resolution}. Supported values are: ' f'{list(res_params)}') params = res_params[resolution] self.add_step( InitialState(test_case=self, resolution=resolution)) nus = config.getlist('baroclinic_channel', 'viscosities', dtype=float) for index, nu in enumerate(nus): name = f'rpe_test_{index + 1}_nu_{int(nu)}' step = Forward( test_case=self, name=name, subdir=name, ntasks=params['ntasks'], min_tasks=params['min_tasks'], resolution=resolution, nu=float(nu)) step.add_namelist_file( 'compass.ocean.tests.baroclinic_channel.rpe_test', 'namelist.forward') step.add_streams_file( 'compass.ocean.tests.baroclinic_channel.rpe_test', 'streams.forward') self.add_step(step) self.add_step( Analysis(test_case=self, resolution=resolution, nus=nus))