diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index bb5f36c43f..e35c2ecfdd 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -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): @@ -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 diff --git a/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg b/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg index 2bd37b74b9..5858deeca1 100644 --- a/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg index 5bd3630dc5..f03d9b704f 100644 --- a/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/crane/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg b/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg index c1b7250a50..fbd7c616db 100644 --- a/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg index 1f3791019c..d7fae0db4d 100644 --- a/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/humboldt/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg index c432495dae..2a681b9b32 100644 --- a/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/isunnguata_sermia/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg index b609542dc8..75bb45d907 100644 --- a/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/kangerlussuaq/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg index e4afcbba1d..f39623c48b 100644 --- a/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/koge_bugt_s/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg index a21fcb0461..334867e4e6 100644 --- a/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg +++ b/compass/landice/tests/thwaites/mesh_gen/mesh_gen.cfg @@ -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 diff --git a/docs/developers_guide/landice/framework.rst b/docs/developers_guide/landice/framework.rst index 9749cf7200..a3a123626a 100644 --- a/docs/developers_guide/landice/framework.rst +++ b/docs/developers_guide/landice/framework.rst @@ -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`, diff --git a/docs/users_guide/landice/test_groups/antarctica.rst b/docs/users_guide/landice/test_groups/antarctica.rst index 115d7ade26..03c9384612 100644 --- a/docs/users_guide/landice/test_groups/antarctica.rst +++ b/docs/users_guide/landice/test_groups/antarctica.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/crane.rst b/docs/users_guide/landice/test_groups/crane.rst index 2e8166e68a..fdc56e9987 100644 --- a/docs/users_guide/landice/test_groups/crane.rst +++ b/docs/users_guide/landice/test_groups/crane.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/greenland.rst b/docs/users_guide/landice/test_groups/greenland.rst index 03a0dcb875..8bc9695903 100644 --- a/docs/users_guide/landice/test_groups/greenland.rst +++ b/docs/users_guide/landice/test_groups/greenland.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/humboldt.rst b/docs/users_guide/landice/test_groups/humboldt.rst index 4afe4a04d4..9f1460b5c1 100644 --- a/docs/users_guide/landice/test_groups/humboldt.rst +++ b/docs/users_guide/landice/test_groups/humboldt.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst index 30ab9e92de..7504eecd56 100644 --- a/docs/users_guide/landice/test_groups/isunnguata_sermia.rst +++ b/docs/users_guide/landice/test_groups/isunnguata_sermia.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/kangerlussuaq.rst b/docs/users_guide/landice/test_groups/kangerlussuaq.rst index c00130390a..686588db86 100644 --- a/docs/users_guide/landice/test_groups/kangerlussuaq.rst +++ b/docs/users_guide/landice/test_groups/kangerlussuaq.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/koge_bugt_s.rst b/docs/users_guide/landice/test_groups/koge_bugt_s.rst index 5053982d64..6f4af7e87d 100644 --- a/docs/users_guide/landice/test_groups/koge_bugt_s.rst +++ b/docs/users_guide/landice/test_groups/koge_bugt_s.rst @@ -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 diff --git a/docs/users_guide/landice/test_groups/thwaites.rst b/docs/users_guide/landice/test_groups/thwaites.rst index bcb9dee15e..6f95311d72 100644 --- a/docs/users_guide/landice/test_groups/thwaites.rst +++ b/docs/users_guide/landice/test_groups/thwaites.rst @@ -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