Skip to content

Commit

Permalink
Merge pull request #489 from xylar/use_better_seaice_partitioning
Browse files Browse the repository at this point in the history
Add sea-ice graph partitioning to `files_for_e3sm` test case
  • Loading branch information
xylar authored Feb 18, 2023
2 parents 4c0acfb + 357a6f3 commit 688cc6d
Show file tree
Hide file tree
Showing 20 changed files with 1,096 additions and 907 deletions.
49 changes: 26 additions & 23 deletions compass/ocean/tests/global_ocean/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
from compass.testgroup import TestGroup

from compass.ocean.tests.global_ocean.mesh import Mesh
from compass.ocean.tests.global_ocean.mesh.qu240.dynamic_adjustment import \
QU240DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.ec30to60.dynamic_adjustment import \
EC30to60DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.arrm10to60.dynamic_adjustment \
import ARRM10to60DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.so12to60.dynamic_adjustment import \
SO12to60DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.wc14.dynamic_adjustment import \
WC14DynamicAdjustment
from compass.ocean.tests.global_ocean.analysis_test import AnalysisTest
from compass.ocean.tests.global_ocean.daily_output_test import DailyOutputTest
from compass.ocean.tests.global_ocean.decomp_test import DecompTest
from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM
from compass.ocean.tests.global_ocean.init import Init
from compass.ocean.tests.global_ocean.mesh import Mesh
from compass.ocean.tests.global_ocean.mesh.arrm10to60.dynamic_adjustment import ( # noqa: E501
ARRM10to60DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.ec30to60.dynamic_adjustment import (
EC30to60DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.qu240.dynamic_adjustment import (
QU240DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.so12to60.dynamic_adjustment import (
SO12to60DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.wc14.dynamic_adjustment import (
WC14DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.monthly_output_test import (
MonthlyOutputTest,
)
from compass.ocean.tests.global_ocean.performance_test import PerformanceTest
from compass.ocean.tests.global_ocean.restart_test import RestartTest
from compass.ocean.tests.global_ocean.decomp_test import DecompTest
from compass.ocean.tests.global_ocean.threads_test import ThreadsTest
from compass.ocean.tests.global_ocean.analysis_test import AnalysisTest
from compass.ocean.tests.global_ocean.daily_output_test import DailyOutputTest
from compass.ocean.tests.global_ocean.monthly_output_test import \
MonthlyOutputTest
from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM
from compass.ocean.tests.global_ocean.make_diagnostics_files import \
MakeDiagnosticsFiles
from compass.testgroup import TestGroup


class GlobalOcean(TestGroup):
Expand Down Expand Up @@ -226,5 +229,5 @@ def __init__(self, mpas_core):
test_group=self, mesh=mesh, init=init,
dynamic_adjustment=dynamic_adjustment))

# A test case for making diagnostics files from an existing mesh
self.add_test_case(MakeDiagnosticsFiles(test_group=self))
# A test case for making E3SM support files from an existing mesh
self.add_test_case(FilesForE3SM(test_group=self))
8 changes: 4 additions & 4 deletions compass/ocean/tests/global_ocean/files_for_e3sm/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ only a subset of the files needed for E3SM support of a new
ocean and sea-ice mesh.
***********************************************************

After running run.py, the directory assembled_files is populated with links.
The directory structure is identical to the E3SM inputdata and diagnostics
directories found here:
After running "compass run", the directory assembled_files is populated with
links. The directory structure is identical to the E3SM inputdata and
diagnostics directories found here:
https://web.lcrc.anl.gov/public/e3sm/

E3SM members should NOT attempt to upload these files. The files produced here
are only a subset of those needed to support a new mesh in E3SM and should not
be uploaded on their own. E3SM experts who know how to produce the other
coupling files may upload these files along with other required datasets to the
LCRC server.
LCRC server.
131 changes: 73 additions & 58 deletions compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import os

from compass.io import symlink, package_path
from compass.testcase import TestCase
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_initial_condition \
import OceanInitialCondition
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_initial_condition \
import SeaiceInitialCondition
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_graph_partition \
import OceanGraphPartition
from compass.io import package_path, symlink
from compass.ocean.tests.global_ocean.configure import configure_global_ocean
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostic_maps import (
DiagnosticMaps,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostic_masks import (
DiagnosticMasks,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.e3sm_to_cmip_maps import (
E3smToCmipMaps,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_graph_partition import ( # noqa: E501
OceanGraphPartition,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_initial_condition import ( # noqa: E501
OceanInitialCondition,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.scrip import Scrip
from compass.ocean.tests.global_ocean.files_for_e3sm.e3sm_to_cmip_maps import \
E3smToCmipMaps
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostics_files \
import DiagnosticsFiles
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_graph_partition import ( # noqa: E501
SeaiceGraphPartition,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_initial_condition import ( # noqa: E501
SeaiceInitialCondition,
)
from compass.ocean.tests.global_ocean.forward import get_forward_subdir
from compass.ocean.tests.global_ocean.configure import configure_global_ocean
from compass.testcase import TestCase


class FilesForE3SM(TestCase):
Expand All @@ -34,12 +45,9 @@ class FilesForE3SM(TestCase):
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment
The test case that performs dynamic adjustment to dissipate
fast-moving waves from the initial condition
restart_filename : str
A restart file from the end of the dynamic adjustment test case to use
as the basis for an E3SM initial condition
"""
def __init__(self, test_group, mesh, init, dynamic_adjustment):
""" # noqa: E501
def __init__(self, test_group, mesh=None, init=None,
dynamic_adjustment=None):
"""
Create test case for creating a global MPAS-Ocean mesh
Expand All @@ -48,62 +56,69 @@ def __init__(self, test_group, mesh, init, dynamic_adjustment):
test_group : compass.ocean.tests.global_ocean.GlobalOcean
The global ocean test group that this test case belongs to
mesh : compass.ocean.tests.global_ocean.mesh.Mesh
mesh : compass.ocean.tests.global_ocean.mesh.Mesh, optional
The test case that produces the mesh for this run
init : compass.ocean.tests.global_ocean.init.Init
init : compass.ocean.tests.global_ocean.init.Init, optional
The test case that produces the initial condition for this run
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment, optional
The test case that performs dynamic adjustment to dissipate
fast-moving waves from the initial condition
"""
""" # noqa: E501
name = 'files_for_e3sm'
time_integrator = dynamic_adjustment.time_integrator
subdir = get_forward_subdir(init.init_subdir, time_integrator, name)
if dynamic_adjustment is not None:
time_integrator = dynamic_adjustment.time_integrator
subdir = get_forward_subdir(
init.init_subdir, time_integrator, name)
else:
subdir = name

super().__init__(test_group=test_group, name=name, subdir=subdir)
self.mesh = mesh
self.init = init
self.dynamic_adjustment = dynamic_adjustment

restart_filename = os.path.join(
'..', 'dynamic_adjustment',
dynamic_adjustment.restart_filenames[-1])
self.restart_filename = restart_filename

self.add_step(
OceanInitialCondition(test_case=self,
restart_filename=restart_filename))

self.add_step(
OceanGraphPartition(test_case=self, mesh=mesh,
restart_filename=restart_filename))

self.add_step(
SeaiceInitialCondition(
test_case=self, restart_filename=restart_filename,
with_ice_shelf_cavities=mesh.with_ice_shelf_cavities))

self.add_step(
Scrip(
test_case=self, restart_filename=restart_filename,
with_ice_shelf_cavities=mesh.with_ice_shelf_cavities))

self.add_step(
E3smToCmipMaps(
test_case=self, restart_filename=restart_filename))

self.add_step(
DiagnosticsFiles(
test_case=self, restart_filename=restart_filename,
with_ice_shelf_cavities=mesh.with_ice_shelf_cavities))
self.add_step(OceanInitialCondition(test_case=self))
self.add_step(OceanGraphPartition(test_case=self))
self.add_step(SeaiceInitialCondition(test_case=self))
self.add_step(SeaiceGraphPartition(test_case=self))
self.add_step(Scrip(test_case=self))
self.add_step(E3smToCmipMaps(test_case=self))
self.add_step(DiagnosticMaps(test_case=self))
self.add_step(DiagnosticMasks(test_case=self))

def configure(self):
"""
Modify the configuration options for this test case
"""
configure_global_ocean(test_case=self, mesh=self.mesh, init=self.init)
mesh = self.mesh
init = self.init
dynamic_adjustment = self.dynamic_adjustment
config = self.config
work_dir = self.work_dir

if mesh is not None:
configure_global_ocean(test_case=self, mesh=mesh,
init=init)
package = 'compass.ocean.tests.global_ocean.files_for_e3sm'
with package_path(package, 'README') as target:
symlink(str(target), '{}/README'.format(self.work_dir))
symlink(str(target), f'{work_dir}/README')

if mesh is not None:
config.set('files_for_e3sm', 'with_ice_shelf_cavities',
f'{mesh.with_ice_shelf_cavities}')

mesh_path = mesh.get_cull_mesh_path()
graph_filename = os.path.join(
self.base_work_dir, mesh_path, 'culled_graph.info')
graph_filename = os.path.abspath(graph_filename)
config.set('files_for_e3sm', 'graph_filename', graph_filename)

if dynamic_adjustment is not None:
restart_filename = os.path.join(
work_dir, '..', 'dynamic_adjustment',
dynamic_adjustment.restart_filenames[-1])
restart_filename = os.path.abspath(restart_filename)
config.set('files_for_e3sm', 'ocean_restart_filename',
restart_filename)
Loading

0 comments on commit 688cc6d

Please sign in to comment.