Skip to content

Commit

Permalink
Merge pull request #39 from xylar/split_parallel_exec
Browse files Browse the repository at this point in the history
Add a parallel executable for `ncremap`
  • Loading branch information
xylar authored May 31, 2021
2 parents e160f6e + 6fba911 commit 81acb1e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions docs/versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Documentation On GitHub
`v0.0.10`_ `0.0.10`_
`v0.0.11`_ `0.0.11`_
`v0.0.12`_ `0.0.12`_
`v0.0.13`_ `0.0.13`_
================ ===============

.. _`stable`: ../stable/index.html
Expand All @@ -22,6 +23,7 @@ Documentation On GitHub
.. _`v0.0.10`: ../0.0.10/index.html
.. _`v0.0.11`: ../0.0.11/index.html
.. _`v0.0.12`: ../0.0.12/index.html
.. _`v0.0.13`: ../0.0.13/index.html
.. _`master`: https://github.com/MPAS-Dev/pyremap/tree/master
.. _`0.0.6`: https://github.com/MPAS-Dev/pyremap/tree/0.0.6
.. _`0.0.7`: https://github.com/MPAS-Dev/pyremap/tree/0.0.7
Expand All @@ -30,3 +32,4 @@ Documentation On GitHub
.. _`0.0.10`: https://github.com/MPAS-Dev/pyremap/tree/0.0.10
.. _`0.0.11`: https://github.com/MPAS-Dev/pyremap/tree/0.0.11
.. _`0.0.12`: https://github.com/MPAS-Dev/pyremap/tree/0.0.12
.. _`0.0.13`: https://github.com/MPAS-Dev/pyremap/tree/0.0.13
2 changes: 1 addition & 1 deletion pyremap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

from pyremap.polar import get_polar_descriptor_from_file, get_polar_descriptor

__version_info__ = (0, 0, 12)
__version_info__ = (0, 0, 13)
__version__ = '.'.join(str(vi) for vi in __version_info__)
27 changes: 18 additions & 9 deletions pyremap/remapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def build_mapping_file(self, method='bilinear', additionalArgs=None,
esmf_parallel_exec : {'srun', 'mpirun}, optional
The name of the parallel executable to use to launch ESMF tools.
But default, 'mpirun' from the conda environment is used
By default, 'mpirun' from the conda environment is used
extrap_method : {'neareststod', 'nearestidavg','creep'}, optional
The method used to extrapolate unmapped destination locations
Expand Down Expand Up @@ -248,14 +248,13 @@ def build_mapping_file(self, method='bilinear', additionalArgs=None,

if esmf_parallel_exec is not None:
# use the specified parallel executable
parallel_args = esmf_parallel_exec.split(' ')

if 'srun' in esmf_parallel_exec:
parallel_args = [esmf_parallel_exec, '-n',
'{}'.format(mpiTasks)]
parallel_args.extend(['-n', '{}'.format(mpiTasks)])
else:
# presume mpirun syntax
parallel_args = [esmf_parallel_exec, '-np',
'{}'.format(mpiTasks)]
parallel_args.extend(['-np', '{}'.format(mpiTasks)])

elif 'CONDA_PREFIX' in os.environ and mpiTasks > 1:
# this is a conda environment, so we need to find out if esmf
Expand Down Expand Up @@ -330,7 +329,7 @@ def build_mapping_file(self, method='bilinear', additionalArgs=None,

def remap_file(self, inFileName, outFileName, variableList=None,
overwrite=False, renormalize=None, logger=None,
replaceMpasFill=False): # {{{
replaceMpasFill=False, parallel_exec=None): # {{{
"""
Given a source file defining either an MPAS mesh or a lat-lon grid and
a destination file or set of arrays defining a lat-lon grid, constructs
Expand Down Expand Up @@ -365,6 +364,10 @@ def remap_file(self, inFileName, outFileName, variableList=None,
from MPAS output). If this has been handled before the call,
replacing the fill value again may cause errors.
parallel_exec : {'srun'}, optional
The name of the parallel executable to use to launch ncremap.
By default, none is used.
Raises
------
OSError
Expand Down Expand Up @@ -399,9 +402,15 @@ def remap_file(self, inFileName, outFileName, variableList=None,
'Note: this presumes use of the conda-forge '
'channel.')

args = ['ncremap',
'-m', self.mappingFileName,
'--vrb=1']
if parallel_exec is not None:
# use the specified parallel executable
args = parallel_exec.split(' ')
else:
args = list()

args.extend(['ncremap',
'-m', self.mappingFileName,
'--vrb=1'])

regridArgs = []

Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "pyremap" %}
{% set version = "0.0.12" %}
{% set version = "0.0.13" %}

package:
name: {{ name|lower }}
Expand Down

0 comments on commit 81acb1e

Please sign in to comment.