Skip to content

Commit

Permalink
Modify examples to show use of multiple MPI tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Nov 18, 2019
1 parent d6fe8ba commit 3c5aa98
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/make_mpas_to_Antarctic_stereo_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
projection='antarctic')
outGridName = outDescriptor.meshName

mappingFileName = 'map_{}_to_{}.nc'.format(inGridName, outGridName)
mappingFileName = 'map_{}_to_{}_conserve.nc'.format(inGridName, outGridName)

remapper = Remapper(inDescriptor, outDescriptor, mappingFileName)

remapper.build_mapping_file(method='bilinear')
# conservative remapping with 4 MPI tasks (using mpirun)
remapper.build_mapping_file(method='conserve', mpiTasks=4)

outFileName = 'temp_{}.nc'.format(outGridName)
ds = xarray.open_dataset(inGridFileName)
Expand Down
2 changes: 1 addition & 1 deletion examples/make_mpas_to_lat_lon_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
outDescriptor = get_lat_lon_descriptor(dLon=0.5, dLat=0.5)
outGridName = outDescriptor.meshName

mappingFileName = 'map_{}_to_{}.nc'.format(inGridName, outGridName)
mappingFileName = 'map_{}_to_{}_bilinear.nc'.format(inGridName, outGridName)


remapper = Remapper(inDescriptor, outDescriptor, mappingFileName)
Expand Down
12 changes: 10 additions & 2 deletions examples/remap_stereographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@
help="Output file name")
parser.add_argument('-r', dest='resolution', required=True, type=float,
help="Output resolution")
parser.add_argument('-m', dest='method', required=False, default="bilinear",
help="Method: {'bilinear', 'neareststod', 'conserve'}")
parser.add_argument('-t', dest='mpiTasks', required=False, type=int, default=1,
help="Number of MPI tasks (default = 1)")
args = parser.parse_args()


if args.method not in ['bilinear', 'neareststod', 'conserve']:
raise ValueError('Unexpected method {}'.format(args.method))

dsIn = xarray.open_dataset(args.inFileName)

x = dsIn.x.values
Expand Down Expand Up @@ -56,11 +63,12 @@
outDescriptor = ProjectionGridDescriptor.create(projection, xOut, yOut,
outMeshName)

mappingFileName = 'map_{}_to_{}.nc'.format(inMeshName, outMeshName)
mappingFileName = 'map_{}_to_{}_{}.nc'.format(inMeshName, outMeshName,
args.method)

remapper = Remapper(inDescriptor, outDescriptor, mappingFileName)

remapper.build_mapping_file(method='bilinear')
remapper.build_mapping_file(method=args.method, mpiTasks=args.mpiTasks)

dsOut = remapper.remap(dsIn, renormalizationThreshold=0.01)
dsOut.to_netcdf(args.outFileName)

0 comments on commit 3c5aa98

Please sign in to comment.