From 402c05831737a2a0d36a8be7472cf7b3b496569c Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Wed, 23 Jun 2021 16:21:50 -0500 Subject: [PATCH] Add config option for number of inactive layers --- compass/ocean/tests/global_ocean/configure.py | 1 + compass/ocean/tests/global_ocean/mesh/qu240/qu240.cfg | 1 + compass/ocean/vertical/grid_1d.py | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/compass/ocean/tests/global_ocean/configure.py b/compass/ocean/tests/global_ocean/configure.py index 656dba2b90..8981e22a44 100644 --- a/compass/ocean/tests/global_ocean/configure.py +++ b/compass/ocean/tests/global_ocean/configure.py @@ -26,6 +26,7 @@ def configure_global_ocean(test_case, mesh, init=None): config.get('global_ocean', 'prefix'))) if init is not None and init.with_inactive_top_cells: + config.set('vertical_grid', 'inactive_top_cells', '1') config.set('vertical_grid', 'vert_levels', '{}'.format( config.getint('vertical_grid', 'vert_levels')+1)) diff --git a/compass/ocean/tests/global_ocean/mesh/qu240/qu240.cfg b/compass/ocean/tests/global_ocean/mesh/qu240/qu240.cfg index a6c2eacb2f..c44406d420 100644 --- a/compass/ocean/tests/global_ocean/mesh/qu240/qu240.cfg +++ b/compass/ocean/tests/global_ocean/mesh/qu240/qu240.cfg @@ -16,6 +16,7 @@ min_layer_thickness = 3.0 # The maximum layer thickness max_layer_thickness = 500.0 +inactive_top_cells = 0 # options for global ocean testcases [global_ocean] diff --git a/compass/ocean/vertical/grid_1d.py b/compass/ocean/vertical/grid_1d.py index f0c99fd820..9e9ca6e09c 100644 --- a/compass/ocean/vertical/grid_1d.py +++ b/compass/ocean/vertical/grid_1d.py @@ -46,6 +46,10 @@ def generate_1d_grid(config): bottom_depth = section.getfloat('bottom_depth') # renormalize to the requested range interfaces = (bottom_depth/interfaces[-1]) * interfaces + if config.has_option('vertical_grid', 'inactive_top_cells'): + offset = config.getint('vertical_grid', 'inactive_top_cells') + if offset > 0: + interfaces[offset:] = interfaces[:0-offset] return interfaces