From c42de61f23961c1dd05b8e515b05ea33e45759b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 15:58:01 +0000 Subject: [PATCH 1/6] Initial plan From 4d77ec136288d74cb8e17639e4780651a8c30a9e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:01:56 +0000 Subject: [PATCH 2/6] Use mbtempest for landice mesh_gen conservative remapping Agent-Logs-Url: https://github.com/MPAS-Dev/compass/sessions/e852577b-c2c5-4453-9fb1-c3856049bf6c Co-authored-by: trhille <17446278+trhille@users.noreply.github.com> --- compass/landice/mesh.py | 30 ++++++++++++++----- .../tests/antarctica/mesh_gen/mesh_gen.cfg | 2 +- .../landice/tests/crane/mesh_gen/mesh_gen.cfg | 2 +- .../tests/greenland/mesh_gen/mesh_gen.cfg | 2 +- .../tests/humboldt/mesh_gen/mesh_gen.cfg | 2 +- .../isunnguata_sermia/mesh_gen/mesh_gen.cfg | 2 +- .../tests/kangerlussuaq/mesh_gen/mesh_gen.cfg | 2 +- .../tests/koge_bugt_s/mesh_gen/mesh_gen.cfg | 2 +- .../tests/thwaites/mesh_gen/mesh_gen.cfg | 2 +- docs/developers_guide/landice/framework.rst | 2 +- .../landice/test_groups/antarctica.rst | 2 +- .../users_guide/landice/test_groups/crane.rst | 2 +- .../landice/test_groups/greenland.rst | 2 +- .../landice/test_groups/humboldt.rst | 2 +- .../landice/test_groups/isunnguata_sermia.rst | 2 +- .../landice/test_groups/kangerlussuaq.rst | 2 +- .../landice/test_groups/koge_bugt_s.rst | 2 +- .../landice/test_groups/thwaites.rst | 2 +- 18 files changed, 40 insertions(+), 24 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index bb5f36c43f..5b45d95705 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1132,10 +1132,24 @@ def __guess_scrip_name(filename): return f"{base_fn}.scrip.nc" + def __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) + + 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 +1169,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 = __partition_scrip_file(source_scrip, nProcs) + destination_part = __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 From 30bae1794d0b16a9570fbb8372900e59820f0732 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:03:12 +0000 Subject: [PATCH 3/6] Handle nProcs type robustly in mbtempest partition helper Agent-Logs-Url: https://github.com/MPAS-Dev/compass/sessions/e852577b-c2c5-4453-9fb1-c3856049bf6c Co-authored-by: trhille <17446278+trhille@users.noreply.github.com> --- compass/landice/mesh.py | 1 + 1 file changed, 1 insertion(+) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index 5b45d95705..df802b0877 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1133,6 +1133,7 @@ def __guess_scrip_name(filename): return f"{base_fn}.scrip.nc" def __partition_scrip_file(scrip_filename, n_procs): + n_procs = str(n_procs) stem = os.path.splitext(scrip_filename)[0] h5m_filename = f'{stem}.h5m' part_filename = f'{stem}.p{n_procs}.h5m' From 5f0301a3622870d8306e21cc94aeacdc33a21eca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:04:17 +0000 Subject: [PATCH 4/6] Refine local helper naming in landice remap workflow Agent-Logs-Url: https://github.com/MPAS-Dev/compass/sessions/e852577b-c2c5-4453-9fb1-c3856049bf6c Co-authored-by: trhille <17446278+trhille@users.noreply.github.com> --- compass/landice/mesh.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index df802b0877..ec2c32c2fb 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1132,7 +1132,7 @@ def __guess_scrip_name(filename): return f"{base_fn}.scrip.nc" - def __partition_scrip_file(scrip_filename, n_procs): + def _partition_scrip_file(scrip_filename, n_procs): n_procs = str(n_procs) stem = os.path.splitext(scrip_filename)[0] h5m_filename = f'{stem}.h5m' @@ -1170,8 +1170,8 @@ def __partition_scrip_file(scrip_filename, n_procs): # Generate remapping weights logger.info('generating gridded dataset -> MPAS weights') - source_part = __partition_scrip_file(source_scrip, nProcs) - destination_part = __partition_scrip_file(mali_scrip, nProcs) + source_part = _partition_scrip_file(source_scrip, nProcs) + destination_part = _partition_scrip_file(mali_scrip, nProcs) args = [parallel_executable, '-n', nProcs, 'mbtempest', '--type', '5', '--load', source_part, From d22653880f919cd759309b0a66e964bbec33b935 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:05:39 +0000 Subject: [PATCH 5/6] Clean temporary h5m files in mbtempest remap setup Agent-Logs-Url: https://github.com/MPAS-Dev/compass/sessions/e852577b-c2c5-4453-9fb1-c3856049bf6c Co-authored-by: trhille <17446278+trhille@users.noreply.github.com> --- compass/landice/mesh.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index ec2c32c2fb..e1c479cd84 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1132,7 +1132,7 @@ def __guess_scrip_name(filename): return f"{base_fn}.scrip.nc" - def _partition_scrip_file(scrip_filename, n_procs): + def _convert_and_partition_scrip_file(scrip_filename, n_procs): n_procs = str(n_procs) stem = os.path.splitext(scrip_filename)[0] h5m_filename = f'{stem}.h5m' @@ -1144,6 +1144,9 @@ def _partition_scrip_file(scrip_filename, n_procs): args = ['mbpart', n_procs, '-z', 'RCB', h5m_filename, part_filename] check_call(args, logger=logger) + if os.path.exists(h5m_filename): + os.remove(h5m_filename) + return part_filename logger = self.logger @@ -1170,8 +1173,8 @@ def _partition_scrip_file(scrip_filename, n_procs): # Generate remapping weights logger.info('generating gridded dataset -> MPAS weights') - source_part = _partition_scrip_file(source_scrip, nProcs) - destination_part = _partition_scrip_file(mali_scrip, nProcs) + 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, From 4473f5c5462a1e06cdfeabc518ca43cf5856f375 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:06:49 +0000 Subject: [PATCH 6/6] Polish helper usage in landice mbtempest remap path Agent-Logs-Url: https://github.com/MPAS-Dev/compass/sessions/e852577b-c2c5-4453-9fb1-c3856049bf6c Co-authored-by: trhille <17446278+trhille@users.noreply.github.com> --- compass/landice/mesh.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compass/landice/mesh.py b/compass/landice/mesh.py index e1c479cd84..e35c2ecfdd 100644 --- a/compass/landice/mesh.py +++ b/compass/landice/mesh.py @@ -1132,8 +1132,7 @@ def __guess_scrip_name(filename): return f"{base_fn}.scrip.nc" - def _convert_and_partition_scrip_file(scrip_filename, n_procs): - n_procs = str(n_procs) + 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' @@ -1144,8 +1143,7 @@ def _convert_and_partition_scrip_file(scrip_filename, n_procs): args = ['mbpart', n_procs, '-z', 'RCB', h5m_filename, part_filename] check_call(args, logger=logger) - if os.path.exists(h5m_filename): - os.remove(h5m_filename) + os.remove(h5m_filename) return part_filename @@ -1173,8 +1171,8 @@ def _convert_and_partition_scrip_file(scrip_filename, n_procs): # Generate remapping weights logger.info('generating gridded dataset -> MPAS weights') - source_part = _convert_and_partition_scrip_file(source_scrip, nProcs) - destination_part = _convert_and_partition_scrip_file(mali_scrip, nProcs) + 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,