Skip to content

Commit

Permalink
Merge pull request #559 from xylar/fix_seaice_partitioning
Browse files Browse the repository at this point in the history
Make mapping file for sea-ice partitioning in compass
  • Loading branch information
xylar authored Mar 12, 2023
2 parents fcf6a7e + 6f42063 commit 54c1d78
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: conda/recipe

# Can run individually with `pre-commit run isort --all-files`
- repo: https://github.com/PyCQA/isort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import xarray as xr
from mpas_tools.logging import check_call
from pyremap import MpasMeshDescriptor, Remapper

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
Expand All @@ -28,7 +29,8 @@ def __init__(self, test_case):
The test case this step belongs to
""" # noqa: E501

super().__init__(test_case, name='seaice_graph_partition')
super().__init__(test_case, name='seaice_graph_partition', ntasks=36,
min_tasks=1)

for filename in ['icePresent_QU60km_polar.nc',
'seaice_QU60km_polar.nc']:
Expand Down Expand Up @@ -65,11 +67,22 @@ def run(self):
logger.info(f'Creating graph files between {np.amin(cores)} and '
f'{np.amax(cores)}')

mapping_filename = _make_mapping_file(
in_mesh_filename='seaice_QU60km_polar.nc',
in_mesh_name='QU60km',
out_mesh_filename='restart.nc',
out_mesh_name=self.mesh_short_name,
ntasks=self.ntasks,
config=self.config,
logger=logger,
method='bilinear')

args = ['prepare_seaice_partitions',
'-i', 'seaice_QU60km_polar.nc',
'-p', 'icePresent_QU60km_polar.nc',
'-m', 'restart.nc',
'-o', '.']
'-o', '.',
'-w', mapping_filename]
check_call(args, logger)

args = ['create_seaice_partitions',
Expand All @@ -87,3 +100,23 @@ def run(self):
for file in files:
symlink(os.path.abspath(file),
f'{self.seaice_inputdata_dir}/{file}')


def _make_mapping_file(in_mesh_filename, in_mesh_name, out_mesh_filename,
out_mesh_name, ntasks, config, logger,
method):

parallel_executable = config.get('parallel', 'parallel_executable')

mapping_file_name = f'map_{in_mesh_name}_to_{out_mesh_name}_{method}.nc'

in_descriptor = MpasMeshDescriptor(in_mesh_filename, in_mesh_name)
out_descriptor = MpasMeshDescriptor(out_mesh_filename, out_mesh_name)

remapper = Remapper(in_descriptor, out_descriptor, mapping_file_name)

remapper.build_mapping_file(method=method, mpiTasks=ntasks,
tempdir='.', logger=logger,
esmf_parallel_exec=parallel_executable)

return mapping_file_name
2 changes: 1 addition & 1 deletion conda/compass_env/spec-file.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mache=1.10.0
{% endif %}
matplotlib-base
metis
mpas_tools=0.17.0
mpas_tools=0.19.0
nco
netcdf4=*=nompi_*
numpy
Expand Down
2 changes: 1 addition & 1 deletion conda/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ requirements:
- mache 1.10.0
- matplotlib-base
- metis
- mpas_tools 0.17.0
- mpas_tools 0.19.0
- nco
- netcdf4 * nompi_*
- numpy
Expand Down

0 comments on commit 54c1d78

Please sign in to comment.