Skip to content

Feature/wjiang/cs to loc - #5251

Open
weiyuan-jiang wants to merge 6 commits into
developfrom
feature/wjiang/cs_to_loc
Open

Feature/wjiang/cs to loc#5251
weiyuan-jiang wants to merge 6 commits into
developfrom
feature/wjiang/cs_to_loc

Conversation

@weiyuan-jiang

Copy link
Copy Markdown
Contributor

Types of change(s)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Trivial change (affects only documentation or cleanup)
  • Refactor (no functional changes, no api changes)

Checklist

  • Tested this change with a run of GEOSgcm
  • Ran the Unit Tests (make tests)

Description

Related Issue

- Register LocStreamGeomFactory in GeomManager singleton initialize()
  (was only registered in the unused new_GeomManager() constructor)
- Support ESMF_GEOMTYPE_LOCSTREAM in FieldBundleSet
- Implement LocStreamGeomFactory make_file_metadata (loc dim + lon/lat
  coordinate variables), previously a stub
- Dispatch componentDriverGridComp internal-state init on geomtype
  to support LocStream (rank-1) geometries in addition to Grid

Verified against MAPL.geom.tests, MAPL.regridder_mgr.tests, and all
existing MAPL3G_Comp_Test_case* cases (no regressions).

Known remaining gaps (see follow-up issue):
- Generic Aspect-based coupling extension does not converge when
  regridding into a LocStream target
- FieldPointerUtilities::clone() is ESMF_Grid-only
Root cause: FieldBundleGet's internal get_geom() helper only
handled ESMF_GEOMTYPE_GRID; for any other geomtype (e.g.
LocStream) it silently left the geom argument untouched instead
of failing loudly, because the caller only invokes it when
has_geom is true but never checks whether geom was actually
populated. This meant GeomAspect update_from_payload kept
reading back the stale source geom from a regrid-transform
output field bundle instead of the newly-regridded destination
(LocStream) geom, so GeomAspect matches() never succeeded and
StateRegistry_Extensions extend() looped until hitting the
MAX_ITERATIONS=10 cap ("StateItem extensions for v_pt did not
converge").

Fix: add a LOCSTREAM branch to FieldBundleGet get_geom(),
mirroring the GRID branch and the LOCSTREAM branch already
added to FieldBundleSet.

Also wire up NEAREST_STOD as a supported regrid method string in
RoutehandleParam (previously only bilinear/conserve were
serializable via ESMF_Info), since CubedSphere to LocStream
regridding should use nearest-neighbor-to-destination-point,
not bilinear/conservative.

Verified: MAPL.geom.tests, MAPL.regridder_mgr.tests, all
MAPL.generic.* pFUnit suites, and all 35 MAPL3G_Comp_Test_case*
tests pass. Manually verified against a CubedSphere to LocStream
coupling reproduction case that the convergence loop is gone
(RUN_MODE=CompareImportsToReference/GenerateExports across two
componentDriverGridComp instances now successfully completes
generic coupling initialize; the only remaining failure is the
already-tracked, separate FieldPointerUtilities clone()
ESMF_Grid-only gap in FILL_DEF constant fill, unrelated to
coupling).
FieldPointerUtilities::clone() unconditionally called
ESMF_FieldGet(x, grid=grid, ...) followed by
ESMF_GridGet(grid, dimCount=grid_rank, ...), which only works
for ESMF_Grid fields.  Any field on a non-Grid geometry
(LocStream, Mesh, XGrid) caused an ESMF runtime abort.

Fix: retrieve the field geometry via ESMF_FieldGet(geom=) and
obtain the dimension count generically through ESMF_GeomGet.
For the ESMF_INDEX_USER and non-USER branches, dispatch on
is_grid to pick the correct ESMF_FieldCreate overload:
  - Grid path: extract the concrete ESMF_Grid with
    ESMF_GeomGet(grid=) and pass staggerloc (Grid-only).
  - Non-Grid path: pass the ESMF_Geom directly; omit
    staggerloc (not a valid argument for that overload).

Verified: all 70 ctest tests pass including a new manual
CubedSphere->LocStream coupling reproduction case (two
componentDriverGridComp instances, FILL_DEF constant fill on
CS, CompareImportsToReference on LocStream with
regrid: NEAREST_STOD in ExtData).
Two-step component-testing-framework test exercising the full
CubedSphere -> LocStream regridding pipeline:

  Step 1 (cap1): GCM1 on CubedSphere(c12, 6 PETs) runs in
  GenerateExports mode, filling field E_1 with a constant 17.0.
  History writes the field to test.nc4 on the native CS grid.

  Step 2 (cap2): GCM2 on a 24-point LocStream (lon/lat spread
  globally) runs in CompareImportsToReference mode.  ExtData
  reads test.nc4 and regrids E_1 to the LocStream using
  NEAREST_STOD (nearest-neighbor-to-destination-point, the
  correct method for Grid->LocStream).  Because the source
  field is a spatial constant (17.0), nearest-neighbor
  interpolation preserves the value exactly, so the
  CompareImportsToReference check passes.

This test would have been impossible without the five LocStream
infrastructure fixes on this branch:
  1. GeomManager::initialize() missing LocStreamGeomFactory
  2. FieldBundleSet unsupported geomtype for LocStream
  3. LocStreamGeomFactory::make_file_metadata stub
  4. FieldBundleGet::get_geom() missing LocStream branch
     (aspect-extension convergence fix)
  5. FieldClone/clone() ESMF_Grid-only (this commit's prereq)
@weiyuan-jiang weiyuan-jiang added 🎁 New Feature This is a new feature 0 Diff The changes in this pull request have verified to be zero-diff with the target branch. 📈 MAPL3 MAPL 3 Related labels Jul 13, 2026
@weiyuan-jiang

Copy link
Copy Markdown
Contributor Author

Only nearest method to reggrid from CubedSphere to Locstream is used

@weiyuan-jiang weiyuan-jiang removed the 🎁 New Feature This is a new feature label Jul 16, 2026
@weiyuan-jiang
weiyuan-jiang marked this pull request as ready for review July 16, 2026 15:17
@weiyuan-jiang
weiyuan-jiang requested a review from a team as a code owner July 16, 2026 15:17
@weiyuan-jiang
weiyuan-jiang requested a review from bena-nasa July 16, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 Diff The changes in this pull request have verified to be zero-diff with the target branch. 📈 MAPL3 MAPL 3 Related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant