Source code for compass.ocean.tests.baroclinic_channel

from compass.ocean.tests.baroclinic_channel.decomp_test import DecompTest
from compass.ocean.tests.baroclinic_channel.default import Default
from compass.ocean.tests.baroclinic_channel.restart_test import RestartTest
from compass.ocean.tests.baroclinic_channel.rpe_test import RpeTest
from compass.ocean.tests.baroclinic_channel.threads_test import ThreadsTest
from compass.testgroup import TestGroup

[docs]class BaroclinicChannel(TestGroup): """ A test group for baroclinic channel test cases """
[docs] def __init__(self, mpas_core): """ mpas_core : compass.MpasCore the MPAS core that this test group belongs to """ super().__init__(mpas_core=mpas_core, name='baroclinic_channel') for resolution in ['1km', '4km', '10km']: self.add_test_case( RpeTest(test_group=self, resolution=resolution)) for resolution in ['10km']: self.add_test_case( DecompTest(test_group=self, resolution=resolution)) self.add_test_case( Default(test_group=self, resolution=resolution)) self.add_test_case( RestartTest(test_group=self, resolution=resolution)) self.add_test_case( ThreadsTest(test_group=self, resolution=resolution))
[docs]def configure(resolution, config): """ Modify the configuration options for one of the baroclinic test cases Parameters ---------- resolution : str The resolution of the test case config : compass.config.CompassConfigParser Configuration options for this test case """ res_params = {'10km': {'nx': 16, 'ny': 58, # NB. 2/sqrt(3) due to hexagons 'dc': 10e3}, '4km': {'nx': 40, 'ny': 144, 'dc': 4e3}, '1km': {'nx': 160, 'ny': 578, 'dc': 1e3}} comment = {'nx': 'the number of mesh cells in the x direction', 'ny': 'the number of mesh cells in the y direction', 'dc': 'the distance between adjacent cell centers'} if resolution not in res_params: raise ValueError(f'Unsupported resolution {resolution}. Supported ' f'values are: {list(res_params)}') res_params = res_params[resolution] for param in res_params: config.set('baroclinic_channel', param, str(res_params[param]), comment=comment[param])