MPAS-Dev / MPAS-Model

Repository for MPAS models and shared framework releases.
235 stars 312 forks source link

Check for active packages for variables in prewrite_reindex #1118

Closed mgduda closed 10 months ago

mgduda commented 11 months ago

This PR modifies the prewrite_reindex routine to check for active packages before reindexing fields in an output stream.

The MPAS_stream_mgr_write routine contains calls to the routines prewrite_reindex and postwrite_reindex to translate between local and global indices for any mesh indexing fields that are being written by a stream. In cases where an indexing field is present in a stream but contains no active packages, that field will not actually be written, and it is therefore not necessary to convert its indices to global indices and back to local indices.

This PR adds two new pool arguments to the prewrite_reindex routine so that it can determine when an indexing field is not active and avoid any reindexing.

No package checks are needed in the postwrite_reindex routine, since only indexing fields that have associated *_save pointers (e.g., cellsOnCell_save) undergo global-to-local index translation, and these *_save pointers are all nullified in the prewrite_reindex routine and then set only if their associated indexing fields are active.

Note that converting the indices for inactive indexing fields from local to global and then back to local indices is not a problem from a correctness perspective, but doing so results in unnecessary computation and data movement. In that sense, the changes in this PR are an optimization only.

mgduda commented 10 months ago

@dimomatt After some thinking, I realized that we don't actually need package checks in the postwrite_reindex routine, and so I've force-pushed changes to this PR branch to remove code changes to that routine.