Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions compass/landice/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,26 @@ def __guess_scrip_name(filename):

return f"{base_fn}.scrip.nc"

def convert_and_partition_scrip_file(scrip_filename, n_procs):
stem = os.path.splitext(scrip_filename)[0]
h5m_filename = f'{stem}.h5m'
part_filename = f'{stem}.p{n_procs}.h5m'

args = ['mbconvert', '-B', scrip_filename, h5m_filename]
check_call(args, logger=logger)

args = ['mbpart', n_procs, '-z', 'RCB', h5m_filename, part_filename]
check_call(args, logger=logger)

os.remove(h5m_filename)

return part_filename

logger = self.logger

source_scrip = __guess_scrip_name(os.path.basename(source_file))
weights_filename = "gridded_to_MPAS_weights.nc"
nProcs = str(nProcs)

# make sure variables is a list, encompasses the variables="all" case
if isinstance(variables, str):
Expand All @@ -1155,13 +1171,15 @@ def __guess_scrip_name(filename):

# Generate remapping weights
logger.info('generating gridded dataset -> MPAS weights')
args = [parallel_executable, '-n', nProcs, 'ESMF_RegridWeightGen',
'--source', source_scrip,
'--destination', mali_scrip,
'--weight', weights_filename,
'--method', 'conserve',
"--netcdf4",
"--dst_regional", "--src_regional", '--ignore_unmapped']
source_part = convert_and_partition_scrip_file(source_scrip, nProcs)
destination_part = convert_and_partition_scrip_file(mali_scrip, nProcs)
args = [parallel_executable, '-n', nProcs, 'mbtempest',
'--type', '5',
'--load', source_part,
'--load', destination_part,
'--file', weights_filename,
'--weights', '--gnomonic',
'--boxeps', '1e-9']
check_call(args, logger=logger)

# Perform actual interpolation using the weights
Expand Down
2 changes: 1 addition & 1 deletion compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion compass/landice/tests/crane/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ measures_filename = greenland_vel_mosaic500_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ measures_filename = greenland_vel_mosaic500_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ measures_filename = greenland_vel_mosaic500_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ measures_filename = greenland_vel_mosaic500_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ measures_filename = greenland_vel_mosaic500_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128
2 changes: 1 addition & 1 deletion docs/developers_guide/landice/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Humboldt mesh):
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

For mesh prototyping, it is a good idea to use `interpolate_data = False`,
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/antarctica.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ the mesh generation options are adjusted through the config file.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

mesh_gen
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/crane.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ the mesh generation options are adjusted through the config file.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

mesh_gen
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/greenland.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The other test cases do not use config options.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

smoke_test
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/humboldt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ the mesh generation options are adjusted through the config file.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

mesh_gen
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/isunnguata_sermia.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ the mesh generation options are adjusted through the config file.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

mesh_gen
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/kangerlussuaq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ the mesh generation options are adjusted through the config file.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

mesh_gen
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/koge_bugt_s.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ the mesh generation options are adjusted through the config file.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

mesh_gen
Expand Down
2 changes: 1 addition & 1 deletion docs/users_guide/landice/test_groups/thwaites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The other test cases do not use config options.
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
# number of processors to use for mbtempest
nProcs = 128

decomposition_test
Expand Down