Skip to content

Refactor get_coordinate_field interface to use AspectMap (issue #4481)#4484

Merged
tclune merged 1 commit intointegration/conservative-regriddingfrom
feature/issue-4481-improve-get-coordinate-field-interface
Mar 4, 2026
Merged

Refactor get_coordinate_field interface to use AspectMap (issue #4481)#4484
tclune merged 1 commit intointegration/conservative-regriddingfrom
feature/issue-4481-improve-get-coordinate-field-interface

Conversation

@tclune
Copy link
Collaborator

@tclune tclune commented Mar 4, 2026

Summary

Refactors the get_coordinate_field() interface to accept an AspectMap instead of individual scalar parameters, making it robust to future additions of new StateItemAspect subclasses.

Changes

  • Abstract interface: Changed aspects parameter from individual scalars (geom, units, typekind) to class(*) to avoid circular module dependencies between vertical_grid/ and generic3g/
  • Implementations: Updated ModelVerticalGrid, FixedLevelsVerticalGrid, and BasicVerticalGrid to use select type to convert class(*) to AspectMap
  • Call site: Updated VerticalGridAspect::make_transform() to build and pass AspectMap with all necessary aspects
  • Tests: Updated Test_ModelVerticalGrid.pf and Test_VerticalGridManager.pf to use new interface

Key Design Decisions

  • class(*) used in abstract interface to break circular dependency
  • VerticalGridAspect added by callee (not caller) to avoid Fortran aliasing constraints (it contains pointer to this)
  • physical_dimension kept as separate parameter since it is derived information computed from comparing source/destination vertical grids

Testing

  • Build succeeded with NAG compiler
  • MAPL.generic3g.tests: All tests passed (100%)
  • MAPL.vertical_grid.tests: 47/48 tests passed (1 unrelated failure)

Fixes #4481

@tclune tclune requested a review from a team as a code owner March 4, 2026 18:25
@tclune tclune added 📈 MAPL3 MAPL 3 Related Changelog Skip Skips the Changelog Enforcer 0 Diff The changes in this pull request have verified to be zero-diff with the target branch. labels Mar 4, 2026
This commit addresses issue #4481 by refactoring the get_coordinate_field()
interface to accept an AspectMap instead of individual scalar parameters
(geom, units, typekind). This makes the interface robust to future changes
when new StateItemAspect subclasses are added.

Key changes:
- Abstract interface now accepts aspects parameter as class(*) to avoid
  circular module dependencies between vertical_grid/ and generic3g/
- Implementations use select type to convert class(*) to AspectMap
- Callee now adds VerticalGridAspect internally to avoid Fortran aliasing
  issues (VerticalGridAspect contains pointer to 'this')
- physical_dimension remains a separate parameter as it's derived information
  computed from comparing source/destination vertical grids
- Call site in VerticalGridAspect::make_transform() updated to build and
  pass AspectMap containing GEOM, TYPEKIND, UNITS, UNGRIDDED_DIMS,
  ATTRIBUTES, and CLASS aspects
- Tests updated to reflect new interface

This eliminates the fragile unpack/repack pattern where callers extracted
individual aspects from an AspectMap, passed them as scalars, and then the
callee had to repack them back into aspects.
@tclune tclune force-pushed the feature/issue-4481-improve-get-coordinate-field-interface branch from ade81a3 to 35c3f30 Compare March 4, 2026 20:10
@tclune tclune merged commit 7874e00 into integration/conservative-regridding Mar 4, 2026
32 of 33 checks passed
@tclune tclune deleted the feature/issue-4481-improve-get-coordinate-field-interface branch March 4, 2026 20:49
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. Changelog Skip Skips the Changelog Enforcer 📈 MAPL3 MAPL 3 Related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant