Skip to content

Fix bug in determining when decompositions can be reused by the SMIOL library #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/framework/mpas_io.F
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,28 @@ subroutine MPAS_io_set_var_indices(handle, fieldname, indices, ierr)
end if
end do
#endif
#ifdef MPAS_SMIOL_SUPPORT
!
! For the SMIOL library, only the size of the outermost (decomposed) dimension
! must match, and the sizes of any inner dimensions do not need to be checked.
! Since the dimensionality of fields may vary, previously created decopositions
! always store the size of the decomposed dimension at decomphandle % dims(1)
! rather than at decomphandle % dims(ndims)
!
if (.not. field_cursor % fieldhandle % has_unlimited_dim) then
if (decomp_cursor % decomphandle % dims(1) /= &
field_cursor % fieldhandle % dims(field_cursor % fieldhandle % ndims) % dimsize) then
decomp_cursor => decomp_cursor % next
cycle DECOMP_LOOP
end if
else
if (decomp_cursor % decomphandle % dims(1) /= &
field_cursor % fieldhandle % dims(field_cursor % fieldhandle % ndims - 1) % dimsize) then
decomp_cursor => decomp_cursor % next
cycle DECOMP_LOOP
end if
end if
#endif

if (size(decomp_cursor % decomphandle % indices) /= size(indices)) then
!call mpas_log_write('We do not have the same number of indices in this decomposition...')
Expand Down Expand Up @@ -1660,6 +1682,11 @@ subroutine MPAS_io_set_var_indices(handle, fieldname, indices, ierr)
#endif

#ifdef MPAS_SMIOL_SUPPORT
! Save the size of the outermost (decomposed) dimension for the field for use in
! subsequent calls to MPAS_io_set_var_indices when checking whether this
! decomposition can be reused for other fields
new_decomp % decomphandle % dims(1) = field_cursor % fieldhandle % dims(ndims) % dimsize

allocate(smiol_indices(size(indices)))
smiol_indices(:) = int(indices(:), kind=SMIOL_offset_kind) - 1_SMIOL_offset_kind ! SMIOL indices are 0-based
smiol_n_compute_elements = size(indices,kind=SMIOL_offset_kind)
Expand Down