Skip to content

generate square grid SCRIP files for coupling FastIsostasy to MALI#740

Draft
hollyhan wants to merge 2 commits into
MPAS-Dev:masterfrom
hollyhan:landice/fastisostasy-scripfile-tool
Draft

generate square grid SCRIP files for coupling FastIsostasy to MALI#740
hollyhan wants to merge 2 commits into
MPAS-Dev:masterfrom
hollyhan:landice/fastisostasy-scripfile-tool

Conversation

@hollyhan

@hollyhan hollyhan commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Add Python script to create square grid SCRIP files for
FastIsostasy MALI coupling

Summary

  • Add create_square_grid_scripfile.py tool to generate
    SCRIP-format files for FastIsostasy coupling
  • FastIsostasy requires a perfect square grid (nx × nx)
    for bedrock deformation coupling
  • Script reads MALI mesh SCRIP file, extracts domain
    bounds, and creates a square regular lat-lon grid
  • Enables users to generate mapping weight files with
    ESMF_RegridWeightGen

Motivation

FastIsostasy coupling in MALI requires two mapping weight
files:

  • mpas_to_fastisostasy.nc (MALI mesh → square grid)
  • fastisostasy_to_mpas.nc (square grid → MALI mesh)

The target grid must be a perfect square (code checks `nX

  • nX = nGridinmpas_li_bedtopo.F:1021-1027`). This
    script automates the creation of the required square grid
    SCRIP file.

Changes

  • New file: create_square_grid_scripfile.py
    • Reads MALI SCRIP file to determine domain extent
    • Creates nx × nx square grid with proper SCRIP format
    • Supports optional padding around domain
    • Includes usage documentation and example workflow

Usage Example

# Create 512×512 square grid for FastIsostasy
python create_square_grid_scripfile.py \
    --mali_scripfile mali_mesh.scripfile.nc \
    --nx 512 \
    --output fastisostasy_512x512.scripfile.nc

# Generate mapping weights with ESMF
ESMF_RegridWeightGen -s mali_mesh.scripfile.nc -d
fastisostasy_512x512.scripfile.nc \
    -w mpas_to_fastisostasy.nc -i --64bit_offset
--src_regional


Grid comparison:

┌─────┬──────────────┬──────────┬─────────────────────┐
│ nx  │     Lat      │  Memory  │      Use case       │
│     │  resolution  │          │                     │
├─────┼──────────────┼──────────┼─────────────────────┤
│ 128 │ ~24 km       │ Small    │ Quick testing       │
├─────┼──────────────┼──────────┼─────────────────────┤
│ 150 │ ~20 km       │ Small    │ Testing             │
├─────┼──────────────┼──────────┼─────────────────────┤
│ 256 │ ~12 km       │ Medium   │ Moderate runs       │
├─────┼──────────────┼──────────┼─────────────────────┤
│ 384 │ ~8 km        │ Large    │ Production          │
│     │              │          │ (stability limit)   │
├─────┼──────────────┼──────────┼─────────────────────┤
│ 512 │ ~6 km        │ Very     │ Too fine (unstable) │
│     │              │ large    │                     │
└─────┴──────────────┴──────────┴─────────────────────┘

Test Plan

- [ ] Run script on example MALI mesh SCRIP file
- [ ] Verify output SCRIP file has correct dimensions (nx
= ny)
- [ ] Generate weight files with ESMF_RegridWeightGen
- [ ] Test weight files in MALI run with
config_uplift_method='fastisostasy'

🤖 Generated with Claude Code

@hollyhan
hollyhan marked this pull request as draft July 17, 2026 19:20
@hollyhan
hollyhan requested a review from matthewhoffman July 17, 2026 19:21
@hollyhan

Copy link
Copy Markdown
Contributor Author

Hi @matthewhoffman,

This PR ready to be reviewed.

A sample test run result is shown below:

(e3sm-unified) hollyhan@login40:/pscratch/sd/h/hollyhan> python ~/scripfile_for_fastisostasy/create_square_grid_scripfile.py --mali_scripfile ~/scripfile_for_fastisostasy/relaxed_10yrs_4km.nc.scripfile --nx 384 --output fastisostasy_384x384.scripfile.nc
Reading MALI scripfile: /global/homes/h/hollyhan/scripfile_for_fastisostasy/relaxed_10yrs_4km.nc.scripfile
  Domain: lat [-89.93, -62.82]°
          lon [0.00, 360.00]°
  Longitude convention: [0, 360]
Creating 384x384 square grid:
  Resolution: dlat=0.0708°, dlon=0.9399°
  Total cells: 147456
Writing SCRIP file: fastisostasy_384x384.scripfile.nc
SUCCESS: Created fastisostasy_384x384.scripfile.nc

Next steps:
1. Generate weight files with ESMF_RegridWeightGen:
   # MALI to FastIsostasy
   ESMF_RegridWeightGen -s /global/homes/h/hollyhan/scripfile_for_fastisostasy/relaxed_10yrs_4km.nc.scripfile -d fastisostasy_384x384.scripfile.nc \
       -w mpas_to_fastisostasy.nc -i --64bit_offset --src_regional --dst_regional
   # FastIsostasy to MALI
   ESMF_RegridWeightGen -s fastisostasy_384x384.scripfile.nc -d /global/homes/h/hollyhan/scripfile_for_fastisostasy/relaxed_10yrs_4km.nc.scripfile \
       -w fastisostasy_to_mpas.nc -i --64bit_offset --src_regional --dst_regional

@matthewhoffman

Copy link
Copy Markdown
Member

@hollyhan , thanks for getting this rolling! I have a couple thoughts to run by you. Could we instead use the projected ISMIP diagnostic grid at 8km (or any resolution) rather than the custom regular grid produced by this PR? It seems like the approach in this PR will result in a somewhat inexact grid spacing, and it might be useful to have the GIA results on a standardized grid. If we did that, we could use the existing scrip file creation tool (https://github.com/MPAS-Dev/MPAS-Tools/blob/master/conda_package/mpas_tools/scrip/from_planar.py) and not need a specialized one just for this MALI application. What do you think?

@xylar , do you you have input on this?

@xylar xylar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me at a quick glance. Let me know if you want more specific feedback.

@xylar

xylar commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

do you you have input on this?

Maybe you meant feedback on your comment to Holly. If so, I agree that this tool might be redundant with ones we already have. It might be better to see if the existing tools work. And I agree that using a standard grid (e.g. ISMIP) might be best.

@hollyhan

hollyhan commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks so much, @matthewhoffman and @xylar for your comments!

Somehow it didn't appear to me I could have used the existing tool! I totally agree with you it might be best to use the ISMIP standardized grid. I'll close this PR upon testing the coupled MALI-FI simulation with based on the scrip file generated using the from_planar.py script.

@matthewhoffman

Copy link
Copy Markdown
Member

@hollyhan , that sounds good. Maybe it would make sense to put the FI set up entirely in the ismip7_run test case - there could be an option added there to use FI, and if true, it would set up the FI grid to match one of the standard ISMIP7 regular grids, and then generate the scrip and mapping files (similar to how the ismip6_run test case set up the SLM).

You could copy this function to the ismip7_run test case for setting up the regular grid:
https://github.com/MPAS-Dev/MPAS-Tools/pull/733/changes#diff-ad34211ba20a8ac13dfce99f110e5a7349da732d33ffb81b06aa542455ba541eR147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants