33from compass .ocean .tests .global_ocean .metadata import \
44 add_mesh_and_init_metadata
55from compass .model import run_model
6+ from compass .ocean .inactive_top_cells import remove_inactive_top_cells_output
67from compass .ocean .vertical .grid_1d import generate_1d_grid , write_1d_grid
78from compass .ocean .plot import plot_vertical_grid , plot_initial_state
89from mpas_tools .io import write_netcdf
@@ -141,6 +142,9 @@ def __init__(self, test_case, mesh, initial_condition, with_bgc,
141142 for file in ['initial_state.nc' , 'init_mode_forcing_data.nc' ]:
142143 self .add_output_file (filename = file )
143144
145+ if with_inactive_top_cells :
146+ self .add_output_file (filename = 'initial_state_crop.nc' )
147+
144148 def setup (self ):
145149 """
146150 Set up the test case in the work directory, including downloading any
@@ -157,6 +161,7 @@ def run(self):
157161 Run this step of the testcase
158162 """
159163 config = self .config
164+ logger = self .logger
160165 interfaces = generate_1d_grid (config = config )
161166
162167 write_1d_grid (interfaces = interfaces , out_filename = 'vertical_grid.nc' )
@@ -167,7 +172,6 @@ def run(self):
167172
168173 if self .with_inactive_top_cells :
169174
170- logger = self .logger
171175 logger .info (" * Updating minLevelCell for inactive top cells" )
172176
173177 in_filename = 'initial_state.nc'
@@ -181,10 +185,14 @@ def run(self):
181185 ds = ds .isel (Time = 0 )
182186
183187 if ('minLevelCell' in ds ):
184- minLevelCell = ds .minLevelCell + 1
188+ if config .has_option ('vertical_grid' , 'inactive_top_cells' ):
189+ offset = config .getint ('vertical_grid' , 'inactive_top_cells' )
190+ minLevelCell = ds .minLevelCell + offset
185191 ds_out ['minLevelCell' ] = minLevelCell
186192 else :
187193 logger .info (" - Streams missing for inactive top cells" )
194+
195+ remove_inactive_top_cells_output (in_filename , inactive_top_cells = offset )
188196
189197 write_netcdf (ds_out , out_filename )
190198 logger .info (" - Complete" )
0 commit comments