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..867ff4b17d 100644 --- a/compass/ocean/vertical/grid_1d.py +++ b/compass/ocean/vertical/grid_1d.py @@ -22,17 +22,22 @@ def generate_1d_grid(config): interfaces : numpy.ndarray A 1D array of positive depths for layer interfaces in meters """ + offset = 0 + if config.has_option('vertical_grid', 'inactive_top_cells'): + offset = config.getint('vertical_grid', 'inactive_top_cells') + section = config['vertical_grid'] grid_type = section.get('grid_type') if grid_type == 'uniform': vert_levels = section.getint('vert_levels') - interfaces = _generate_uniform(vert_levels) + interfaces = _generate_uniform(vert_levels - offset) elif grid_type == 'tanh_dz': vert_levels = section.getint('vert_levels') min_layer_thickness = section.getfloat('min_layer_thickness') max_layer_thickness = section.getfloat('max_layer_thickness') bottom_depth = section.getfloat('bottom_depth') - interfaces = _create_tanh_dz_grid(vert_levels, bottom_depth, + interfaces = _create_tanh_dz_grid(vert_levels - offset, + bottom_depth, min_layer_thickness, max_layer_thickness) @@ -47,6 +52,9 @@ def generate_1d_grid(config): # renormalize to the requested range interfaces = (bottom_depth/interfaces[-1]) * interfaces + if config.has_option('vertical_grid', 'inactive_top_cells'): + interfaces = np.append(np.zeros((offset)),interfaces) + return interfaces