Skip to content

Generalized Indices: MPP_REDISTRIBUTE#1886

Open
abrooks1085 wants to merge 10 commits into
NOAA-GFDL:mainfrom
abrooks1085:feature/general-indices-redistribute
Open

Generalized Indices: MPP_REDISTRIBUTE#1886
abrooks1085 wants to merge 10 commits into
NOAA-GFDL:mainfrom
abrooks1085:feature/general-indices-redistribute

Conversation

@abrooks1085

@abrooks1085 abrooks1085 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description
This PR adds generalized storage-layout support to MPP_REDISTRIBUTE for 2D–5D fields. Callers may pass an optional axis_to_storage mapping, defined as:

axis_to_storage(logical_axis) = storage_dimension

For example, axis_to_storage = (/3,1,2/) means logical x, y, and z are stored in dimensions 3, 1, and 2, respectively.

The redistribute wrappers now pass this mapping through to the low-level pack/unpack logic, which maps logical domain bounds onto the correct storage dimensions before accessing field data. For 4D and 5D fields, extra dimensions are handled as repeated contiguous 3D chunks instead of being collapsed onto the third dimension, avoiding the previous assumption that storage dimension 3 is always logical z.

How Has This Been Tested?
amdbox + intel

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@uramirez8707 uramirez8707 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just minor comments regarding the new argument name. Looks good to me otherwise.

Comment thread mpp/include/mpp_do_redistribute.fh Outdated
Comment thread mpp/include/mpp_update_domains2D.fh Outdated
logical, intent(in), optional :: complete, free
integer, intent(in), optional :: list_size
integer, intent(in), optional :: position
integer, intent(in), optional :: axis_to_dim_in(3)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please document this new arguments.

Can we make it consistent with the other subroutines? I think we used dim_order.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I’ll add documentation for the new argument.

I also agree that this should be consistent across the MPP interfaces. While reviewing this, I found that dim_order is ambiguous because it has been used in different senses. In mpp_redistribute, the mapping is from logical axis to storage dimension:

axis_to_storage(logical_axis) = storage_dimension

For example, axis_to_storage = (/3,1,2/) means logical x, y, and z are stored in dimensions 3, 1, and 2.

The current pelist gather/scatter implementation uses dim_order in the opposite direction internally, mapping storage dimension to logical axis. To avoid exposing two conventions, I’m renaming the public argument to axis_to_storage for redistribute and will update pelist gather/scatter to use the same public convention, converting internally to the reverse map where needed. This should also make the interface consistent with @J-Lentz’s group update PR.

Comment thread mpp/include/mpp_update_domains2D.fh Outdated
Comment thread mpp/include/mpp_update_domains2D.fh Outdated
Comment thread mpp/include/mpp_update_domains2D.fh Outdated
abrooks1085 and others added 7 commits June 23, 2026 13:34
Pass field addresses, chunk counts, and shape metadata through the
generalized redistribute register path instead of constructing rank-specific
array aliases in the wrappers. Higher-rank fields are handled as contiguous
3D chunks in the shared do_redistribute implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants