Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compass/landice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from compass.landice.tests.koge_bugt_s import KogeBugtS
from compass.landice.tests.mesh_modifications import MeshModifications
from compass.landice.tests.mismipplus import MISMIPplus
from compass.landice.tests.slm import Slm
from compass.landice.tests.slm_circ_icesheet import SlmCircIcesheet
from compass.landice.tests.thwaites import Thwaites
from compass.mpas_core import MpasCore

Expand Down Expand Up @@ -50,5 +50,5 @@ def __init__(self):
self.add_test_group(KogeBugtS(mpas_core=self))
self.add_test_group(MeshModifications(mpas_core=self))
self.add_test_group(MISMIPplus(mpas_core=self))
self.add_test_group(Slm(mpas_core=self))
self.add_test_group(SlmCircIcesheet(mpas_core=self))
self.add_test_group(Thwaites(mpas_core=self))
17 changes: 0 additions & 17 deletions compass/landice/tests/slm/__init__.py

This file was deleted.

23 changes: 23 additions & 0 deletions compass/landice/tests/slm_circ_icesheet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from compass.landice.tests.slm_circ_icesheet.mesh_convergence import (
MeshConvergenceTest,
)
from compass.landice.tests.slm_circ_icesheet.smoke_test import SmokeTest
from compass.testgroup import TestGroup


class SlmCircIcesheet(TestGroup):
"""
This test group generates an idealized, circular ice sheet that has a
prescribed thickness evolution for testing coupling between MALI
and the Sea-Level Model.
"""
def __init__(self, mpas_core):
"""
mpas_core : compass.landice.Landice
the MPAS core that this test group belongs to
"""
super().__init__(mpas_core=mpas_core, name='slm_circ_icesheet')

self.add_test_case(
MeshConvergenceTest(test_group=self))
self.add_test_case(SmokeTest(test_group=self))
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from compass.landice.tests.slm.circ_icesheet.run_model import RunModel
from compass.landice.tests.slm.circ_icesheet.setup_mesh import SetupMesh
from compass.landice.tests.slm.circ_icesheet.visualize import Visualize
from compass.landice.tests.slm_circ_icesheet.run_model import RunModel
from compass.landice.tests.slm_circ_icesheet.setup_mesh import SetupMesh
from compass.landice.tests.slm_circ_icesheet.visualize import Visualize
from compass.testcase import TestCase


class CircIcesheetTest(TestCase):
class MeshConvergenceTest(TestCase):
"""
This test generates an idealized, circular ice sheet that has a
prescribed thickness evolution for testing coupling between MALI
and the Sea-Level Model.
This test uses the circular ice sheet test case to test the convergence
of the coupled MALI-SLM system with respect to mesh resolution of both
MALI and the SLM.
"""

def __init__(self, test_group):
Expand All @@ -17,11 +17,11 @@ def __init__(self, test_group):

Parameters
----------
test_group : compass.landice.tests.slm.Slm
test_group : compass.landice.tests.slm_circ_icesheet.SlmCircIcesheet
The test group that this test case belongs to
The resolution or type of mesh of the test case
"""
name = 'circ_icesheet'
name = 'mesh_convergence'
subdir = name
super().__init__(test_group=test_group, name=name,
subdir=subdir)
Expand Down Expand Up @@ -52,14 +52,11 @@ def configure(self):
ntasks = 512
else:
ntasks = 128
min_tasks = ntasks
min_tasks = 10
self.add_step(RunModel(test_case=self, res=res, nglv=nglv,
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=1,
name=f'mali{res}km_slm{nglv}'
'/run_model'))
step = Visualize(test_case=self)
self.add_step(step, run_by_default=True)

# no run() method is needed because we're doing the default: running all
# steps
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ topo_elev = -1500.0
# center of the domain
put_origin_on_a_cell = False

# Number of ESMF processes to use for interpolation between MALI and the SLM
esmf_procs = 128

# Config options for surface mass balance forcing
[smb_forcing]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class RunModel(Step):
A step for performing forward MALI runs as part of dome test cases.
"""

def __init__(self, test_case, res, nglv, ntasks, name='run_model',
subdir=None, min_tasks=None, openmp_threads=1):
def __init__(self, test_case, res, nglv, resource_package=None,
ntasks=None, name='run_model', subdir=None, min_tasks=None,
openmp_threads=1):
"""
Create a new test case

Expand All @@ -28,6 +29,10 @@ def __init__(self, test_case, res, nglv, ntasks, name='run_model',
nglv : str
Number of Gauss-Legendre nodes in latitude in the SLM grid

resource_package : str, optional
The resource package (module path) where namelist/streams/template
files live. If None, it is derived from the test_case module.

ntasks : int
the number of tasks the step would ideally use. If fewer tasks
are available on the system, the step will run on all available
Expand Down Expand Up @@ -55,13 +60,17 @@ def __init__(self, test_case, res, nglv, ntasks, name='run_model',
ntasks=ntasks, min_tasks=min_tasks,
openmp_threads=openmp_threads)

self.add_namelist_file(
'compass.landice.tests.slm.circ_icesheet', 'namelist.landice',
out_name='namelist.landice')
# determine resource package (module path to circ_icesheet)
if resource_package is None:
resource_package = test_case.__module__
self.resource_package = resource_package

# add namelist and streams from the circ_icesheet package
self.add_namelist_file(self.resource_package, 'namelist.landice',
out_name='namelist.landice')

self.add_streams_file(
'compass.landice.tests.slm.circ_icesheet', 'streams.landice',
out_name='streams.landice')
self.add_streams_file(self.resource_package, 'streams.landice',
out_name='streams.landice')

self.add_input_file(filename='landice_grid.nc',
target='../setup_mesh/landice_grid.nc')
Expand All @@ -88,13 +97,12 @@ def setup(self):
section = self.config['slm']
slm_input_root = section.get('slm_input_root').rstrip('/')

# change the sealevel namelist
template = Template(resources.read_text
('compass.landice.tests.slm',
'namelist.sealevel.template'))
text = template.render(
nglv=self.nglv,
slm_input_root=slm_input_root)
template = Template(
resources.read_text('compass.landice.tests.slm_circ_icesheet',
'namelist.sealevel.template')
)
text = template.render(nglv=self.nglv,
slm_input_root=slm_input_root)

# write out the namelist.sealevel file
file_slm_nl = os.path.join(self.work_dir, 'namelist.sealevel')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import shutil

import netCDF4
import numpy as np
from mpas_tools.io import write_netcdf
from mpas_tools.logging import check_call
Expand Down Expand Up @@ -305,8 +304,9 @@ def _create_smb_forcing_file(config, logger, mali_mesh_file, filename):
for t_index in range(len(t_array)):
yr = start_year + (t_index * dt_year)
xtime_str = f'{int(yr)}-01-01_00:00:00'.ljust(64)
xtime_char = netCDF4.stringtochar(np.array([xtime_str], 'S64'),
encoding='utf-8')
xtime_str_padded = xtime_str.ljust(64)[:64]
xtime_char = np.array(list(xtime_str_padded), dtype='S1')
xtime[t_index, :] = xtime_char
xtime[t_index, :] = xtime_char

smbfile.close()
Expand Down Expand Up @@ -375,6 +375,8 @@ def _build_mapping_files(config, logger, res, nglv, mali_mesh_file):
parallel_executable = config.get("parallel", "parallel_executable")
# split the parallel executable into constituents in case it includes flags
args = parallel_executable.split(' ')
nproc = config.getint("circ_icesheet", "esmf_procs")
args.extend(['-n', str(nproc)])
args.extend(['ESMF_RegridWeightGen',
'-s', mali_scripfile,
'-d', slm_scripfile,
Expand All @@ -386,6 +388,8 @@ def _build_mapping_files(config, logger, res, nglv, mali_mesh_file):
check_call(args, logger)

args = parallel_executable.split(' ')
nproc = config.getint("circ_icesheet", "esmf_procs")
args.extend(['-n', str(nproc)])
args.extend(['ESMF_RegridWeightGen',
'-s', slm_scripfile,
'-d', mali_scripfile,
Expand Down
59 changes: 59 additions & 0 deletions compass/landice/tests/slm_circ_icesheet/smoke_test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from compass.landice.tests.slm_circ_icesheet.run_model import RunModel
from compass.landice.tests.slm_circ_icesheet.setup_mesh import SetupMesh
from compass.landice.tests.slm_circ_icesheet.visualize import Visualize
from compass.testcase import TestCase


class SmokeTest(TestCase):
"""
A lightweight smoke test using the baseline circ_icesheet configuration.
"""
def __init__(self, test_group):
name = 'smoke_test'
subdir = name
super().__init__(test_group=test_group, name=name, subdir=subdir)

def configure(self):
config = self.config
section = config['circ_icesheet']
mali_res = section.getint('mali_res')

section = config['slm']
slm_nglv = section.getint('slm_nglv')

res = mali_res
nglv = slm_nglv

# setup mesh and run model using resources from circ_icesheet package
self.add_step(
SetupMesh(
test_case=self,
name='setup_mesh',
res=res,
nglv=nglv,
)
)

if (int(res) <= 16 and int(res) > 2):
ntasks = 256
elif (int(res) <= 2):
ntasks = 512
else:
ntasks = 128
min_tasks = 10

resource_package = (
'compass.landice.tests.slm_circ_icesheet.smoke_test'
)
self.add_step(
RunModel(
test_case=self,
res=res,
nglv=nglv,
resource_package=resource_package,
ntasks=ntasks,
min_tasks=min_tasks,
openmp_threads=1,
name='run_model',
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
&velocity_solver
config_velocity_solver = 'none'
/
&advection
config_thickness_advection = 'fo'
config_tracer_advection = 'none'
/
&solidearth
config_uplift_method = 'sealevelmodel'
config_slm_coupling_interval = 1
config_MALI_to_SLM_weights_file = 'mapping_file_mali_to_slm.nc'
config_SLM_to_MALI_weights_file = 'mapping_file_slm_to_mali.nc'
/
&calving
config_calving = 'none'
config_restore_calving_front = .false.
/
&thermal_solver
config_thermal_solver = 'none'
/
&iceshelf_melt
config_basal_mass_bal_float = 'none'
config_front_mass_bal_grounded = 'none'
/
&physical_parameters
config_ice_density = 910.0
config_ocean_density = 1028.0
config_sea_level = 0.0
config_dynamic_thickness = 10.0
/
&time_integration
config_dt = '0001-00-00_00:00:00'
config_time_integration = 'forward_euler'
config_adaptive_timestep = .false.
/
&time_management
config_do_restart = .false.
config_restart_timestamp_name = 'restart_timestamp'
config_start_time = '2015-01-01_00:00:00'
config_stop_time = '2017-01-01_00:00:00'
config_run_duration = 'none'
config_calendar_type = 'noleap'
/
&io
config_pio_stride = 128
/
&AM_globalStats
config_AM_globalStats_enable = .true.
config_AM_globalStats_compute_interval = 'output_interval'
config_AM_globalStats_stream_name = 'globalStatsOutput'
config_AM_globalStats_compute_on_startup = .true.
config_AM_globalStats_write_on_startup = .true.
/
Loading
Loading