Skip to content

Commit d25a96e

Browse files
Fixup
* test case name * cleanup in setup_mesh & run_model * set MALI/SLM coupling interval to 1 year Case sets up and runs without error after this change, but I have not checked correctness yet.
1 parent 67c5425 commit d25a96e

5 files changed

Lines changed: 16 additions & 21 deletions

File tree

compass/landice/tests/slm/circ_icesheet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, test_group):
2121
The test group that this test case belongs to
2222
The resolution or type of mesh of the test case
2323
"""
24-
name = 'circular_icesheet_test'
24+
name = 'circ_icesheet'
2525
subdir = name
2626
super().__init__(test_group=test_group, name=name,
2727
subdir=subdir)

compass/landice/tests/slm/circ_icesheet/namelist.landice

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/
88
&solidearth
99
config_uplift_method = 'sealevelmodel'
10-
config_slm_coupling_interval = 5
10+
config_slm_coupling_interval = 1
1111
config_MALI_to_SLM_weights_file = 'mapping_file_mali_to_slm.nc'
1212
config_SLM_to_MALI_weights_file = 'mapping_file_slm_to_mali.nc'
1313
/

compass/landice/tests/slm/circ_icesheet/run_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, test_case, res, nglv, ntasks, name='run_model',
7777
'mapping_file_slm_to_mali.nc')
7878
self.add_model_as_input()
7979

80-
self.add_output_file(filename='output.nc')
80+
self.add_output_file(filename='output/output.nc')
8181

8282
def setup(self):
8383
os.makedirs(os.path.join(self.work_dir, 'OUTPUT_SLM/'),

compass/landice/tests/slm/circ_icesheet/setup_mesh.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import os
22
import shutil
33

4-
import mpas_tools.io
54
import netCDF4
65
import numpy as np
76
from mpas_tools.io import write_netcdf
87
from mpas_tools.logging import check_call
9-
from mpas_tools.mesh.conversion import cull
8+
from mpas_tools.mesh.conversion import convert, cull
109
from mpas_tools.planar_hex import make_planar_hex_mesh
1110
from mpas_tools.scrip.from_mpas import scrip_from_mpas
1211
from mpas_tools.translate import center, translate
@@ -72,30 +71,24 @@ def run(self):
7271
# factor of 2/sqrt(3) because of hexagonal mesh
7372
ny = max(2 * int(0.5 * ly * (2. / np.sqrt(3)) / dc + 0.5), 4)
7473

75-
mpas_tools.io.default_format = 'NETCDF4'
76-
mpas_tools.io.default_engine = 'netcdf4'
77-
7874
# call the mesh creation function
7975
dsMesh = make_planar_hex_mesh(nx=nx, ny=ny, dc=dc,
8076
nonperiodic_x=True,
8177
nonperiodic_y=True)
8278
dsMesh = cull(dsMesh, logger=logger)
83-
# adding the time dimension is needed for netcdf4 formatting to work
84-
dsMesh['xtime'] = ('Time', ['2015-01-01_00:00:00'.ljust(64)])
79+
dsMesh = convert(dsMesh, logger=logger)
8580
# translating the mesh center to x=0 & y=0
8681
center(dsMesh)
8782
# shift the center to a quarter or radius
8883
shift = 200000.0
8984
print(f'shifting the center by {shift} meters')
9085
translate(dsMesh, shift, shift)
9186

92-
fname_culled = 'culled_mesh_before_cdf5.nc'
93-
write_netcdf(dsMesh, fname_culled)
94-
args = ['ncks', '-O', '-5', fname_culled, 'mpas_grid.nc']
95-
check_call(args, logger=logger)
87+
fname_mpas = 'mpas_grid.nc'
88+
write_netcdf(dsMesh, fname_mpas)
9689

9790
levels = 3
98-
args = ['create_landice_grid_from_generic_MPAS_grid.py',
91+
args = ['create_landice_grid_from_generic_mpas_grid',
9992
'-i', 'mpas_grid.nc',
10093
'-o', 'landice_grid.nc',
10194
'-l', str(levels)]
@@ -115,7 +108,7 @@ def run(self):
115108
_build_mapping_files(config, logger, self.res, self.nglv,
116109
mali_mesh_file='landice_grid.nc')
117110

118-
os.remove(fname_culled)
111+
os.remove(fname_mpas)
119112

120113

121114
def _setup_circsheet_initial_conditions(config, logger, filename):
@@ -294,13 +287,13 @@ def _create_smb_forcing_file(config, logger, mali_mesh_file, filename):
294287
if (Rt < 0):
295288
Rt = 0.0
296289
sfcMassBal[t, :] = 0.0
297-
print(f'At time {start_year+dt_year*t}, \
290+
print(f'At time {start_year + dt_year * t}, \
298291
new radius will be {Rt} km')
299292
else:
300293
indx = np.where(r >= Rt)[0]
301294
sfcMassBal[t, indx] = smb
302-
print(f'At time {start_year+dt_year*t}, \
303-
new radius will be {Rt/1000} km')
295+
print(f'At time {start_year + dt_year * t}, \
296+
new radius will be {Rt / 1000} km')
304297
smbfile.variables['sfcMassBal'][:, :] = sfcMassBal[:, :]
305298

306299
# add xtime variable
@@ -361,12 +354,12 @@ def _build_mapping_files(config, logger, res, nglv, mali_mesh_file):
361354
args = ['ncremap',
362355
'-g', slm_scripfile,
363356
'-G',
364-
f'latlon={slm_nglv},{2*int(slm_nglv)}#lat_typ=gss#lat_drc=n2s']
357+
f'latlon={slm_nglv},{2 * int(slm_nglv)}#lat_typ=gss#lat_drc=n2s']
365358

366359
check_call(args, logger=logger)
367360

368361
# adjust the lat-lon values
369-
args = ['set_lat_lon_fields_in_planar_grid.py',
362+
args = ['set_lat_lon_fields_in_planar_grid',
370363
'--file', mali_mesh_file,
371364
'--proj', 'ais-bedmap2-sphere']
372365

compass/landice/tests/slm/namelist.sealevel.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@
6464

6565

6666
/
67+
68+
! end of file

0 commit comments

Comments
 (0)