From 3c5aa9821d01e7094252c4c899a46c5b58d2d7f4 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Mon, 18 Nov 2019 10:59:50 +0100 Subject: [PATCH] Modify examples to show use of multiple MPI tasks --- examples/make_mpas_to_Antarctic_stereo_mapping.py | 5 +++-- examples/make_mpas_to_lat_lon_mapping.py | 2 +- examples/remap_stereographic.py | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/make_mpas_to_Antarctic_stereo_mapping.py b/examples/make_mpas_to_Antarctic_stereo_mapping.py index d555fc5..0d1b077 100755 --- a/examples/make_mpas_to_Antarctic_stereo_mapping.py +++ b/examples/make_mpas_to_Antarctic_stereo_mapping.py @@ -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) diff --git a/examples/make_mpas_to_lat_lon_mapping.py b/examples/make_mpas_to_lat_lon_mapping.py index da13483..8c76153 100755 --- a/examples/make_mpas_to_lat_lon_mapping.py +++ b/examples/make_mpas_to_lat_lon_mapping.py @@ -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) diff --git a/examples/remap_stereographic.py b/examples/remap_stereographic.py index 149a539..ff5cd6c 100755 --- a/examples/remap_stereographic.py +++ b/examples/remap_stereographic.py @@ -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 @@ -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)