Read this tile’s (nx, ny, nz_src) window of a 3D T/S variable
(the file holds the WHOLE grid; the window starts at global cell
(io+1, jo+1)) with a start/count read, permuting from the file’s
Fortran storage order. On an undecomposed grid the window is the
whole variable.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ncid | |||
| integer, | intent(in) | :: | varid | |||
| real(kind=wp), | intent(out) | :: | dst(nx,ny,nz_src) | |||
| integer, | intent(in) | :: | nx | |||
| integer, | intent(in) | :: | ny | |||
| integer, | intent(in) | :: | nz_src | |||
| logical, | intent(in) | :: | needs_transpose | |||
| integer, | intent(in) | :: | io |
Global offsets of the tile ( |
||
| integer, | intent(in) | :: | jo |
Global offsets of the tile ( |
||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a read failure when present; absent behaves as
today ( |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private, | allocatable | :: | buf(:,:,:) | |||
| integer, | private | :: | i | ||||
| integer, | private | :: | j | ||||
| integer, | private | :: | k |
subroutine read_field_xyz(ncid, varid, dst, nx, ny, nz_src, needs_transpose, & io, jo, ierr) !! Read this tile's `(nx, ny, nz_src)` window of a 3D T/S variable !! (the file holds the WHOLE grid; the window starts at global cell !! `(io+1, jo+1)`) with a start/count read, permuting from the file's !! Fortran storage order. On an undecomposed grid the window is the !! whole variable. integer, intent(in) :: ncid, varid, nx, ny, nz_src logical, intent(in) :: needs_transpose integer, intent(in) :: io, jo !! Global offsets of the tile (`grid%i/j_offset_global`). real(wp), intent(out) :: dst(nx, ny, nz_src) integer, intent(out), optional :: ierr !! Non-zero on a read failure when present; absent behaves as !! today (`error stop`). integer :: i, j, k real(wp), allocatable :: buf(:, :, :) if (needs_transpose) then ! File is (z, y, x) in Fortran order. allocate (buf(nz_src, ny, nx)) call nc_get_var_slab_3d(ncid, varid, [1, jo + 1, io + 1], [nz_src, ny, nx], buf, ierr) if (present(ierr)) then if (ierr /= 0) then deallocate (buf) return end if end if do k = 1, nz_src do j = 1, ny do i = 1, nx dst(i, j, k) = buf(k, j, i) end do end do end do else ! File is (x, y, z) in Fortran order — direct read of the window. call nc_get_var_slab_3d(ncid, varid, [io + 1, jo + 1, 1], [nx, ny, nz_src], dst, ierr) end if if (allocated(buf)) deallocate (buf) end subroutine read_field_xyz