Skip to content

Commit

Permalink
Add a parallel exec for ncremap
Browse files Browse the repository at this point in the history
Also, split the parallel executable for ESMF_RegridWeightGen so
it can include flags as needed
  • Loading branch information
xylar committed May 31, 2021
1 parent e160f6e commit 1f168dd
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pyremap/remapper.py
Original file line number Diff line number Diff line change
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.
But 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

0 comments on commit 1f168dd

Please sign in to comment.