From 67ab4ad97a69ef391219912000990e87788f8af6 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Sun, 8 Oct 2023 12:08:41 +0200 Subject: [PATCH] Add config options to control init topo smoothing Up to now, topography smoothing has been disabled in MPAS-Ocean init mode. This merge adds config options to control it (the number of iterations and the weight of a cell vs. its neighbors in each iteration). By default, topography smoothing is still off. --- .../ocean/tests/global_ocean/global_ocean.cfg | 5 +++++ .../tests/global_ocean/init/initial_state.py | 18 +++++++++++++++--- .../tests/global_ocean/init/namelist.init | 1 - 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/compass/ocean/tests/global_ocean/global_ocean.cfg b/compass/ocean/tests/global_ocean/global_ocean.cfg index 9d032e857a..a2c0b75504 100644 --- a/compass/ocean/tests/global_ocean/global_ocean.cfg +++ b/compass/ocean/tests/global_ocean/global_ocean.cfg @@ -47,6 +47,11 @@ btr_dt_per_km = 1.5 # Maximum allowed Haney number for configurations with ice-shelf cavities rx1_max = 20 +# the number of iterations of topography smoothing +topo_smooth_iterations = 0 +# the weight given to the central cell during each iteration of smoothing, +# where the n cellsOnCell (neighbors) are given a weight (1-weight)/n. +topo_smooth_weight = 0.9 # number of cores to use init_ntasks = 36 diff --git a/compass/ocean/tests/global_ocean/init/initial_state.py b/compass/ocean/tests/global_ocean/init/initial_state.py index d9ea96eedf..82c6d76c2f 100644 --- a/compass/ocean/tests/global_ocean/init/initial_state.py +++ b/compass/ocean/tests/global_ocean/init/initial_state.py @@ -139,9 +139,21 @@ def setup(self): Get resources at setup from config options """ self._get_resources() - rx1_max = self.config.getfloat('global_ocean', 'rx1_max') - self.add_namelist_options({'config_rx1_max': f'{rx1_max}'}, - mode='init') + section = self.config['global_ocean'] + rx1_max = section.getfloat('rx1_max') + topo_smooth_iterations = section.getint('topo_smooth_iterations') + topo_smooth_weight = section.getfloat('topo_smooth_weight') + + options = { + 'config_rx1_max': + f'{rx1_max}', + 'config_global_ocean_topography_smooth_iterations': + f'{topo_smooth_iterations}', + 'config_global_ocean_topography_smooth_weight': + f'{topo_smooth_weight}', + } + + self.add_namelist_options(options, mode='init') def constrain_resources(self, available_resources): """ diff --git a/compass/ocean/tests/global_ocean/init/namelist.init b/compass/ocean/tests/global_ocean/init/namelist.init index aa4b5efc83..1661fe08c6 100644 --- a/compass/ocean/tests/global_ocean/init/namelist.init +++ b/compass/ocean/tests/global_ocean/init/namelist.init @@ -53,4 +53,3 @@ config_global_ocean_depth_conversion_factor = 1.0 config_global_ocean_minimum_depth = 10 config_global_ocean_deepen_critical_passages = .false. config_block_decomp_file_prefix = 'graph.info.part.' -config_global_ocean_topography_smooth_iterations = 0