read_field_xyz Subroutine

private 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.

Arguments

Type IntentOptional 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 (grid%i/j_offset_global).

integer, intent(in) :: jo

Global offsets of the tile (grid%i/j_offset_global).

integer, intent(out), optional :: ierr

Non-zero on a read failure when present; absent behaves as today (error stop).


Calls

proc~~read_field_xyz~~CallsGraph proc~read_field_xyz read_field_xyz proc~nc_get_var_slab_3d nc_get_var_slab_3d proc~read_field_xyz->proc~nc_get_var_slab_3d nf90_get_var nf90_get_var proc~nc_get_var_slab_3d->nf90_get_var proc~nc_check nc_check proc~nc_get_var_slab_3d->proc~nc_check nf90_strerror nf90_strerror proc~nc_check->nf90_strerror proc~fail fail proc~nc_check->proc~fail error error proc~fail->error proc~error_ring_push error_ring_push proc~fail->proc~error_ring_push

Called by

proc~~read_field_xyz~~CalledByGraph proc~read_field_xyz read_field_xyz proc~seed_ts_from_zfile seed_ts_from_zfile proc~seed_ts_from_zfile->proc~read_field_xyz proc~seed_zinit_overlay seed_zinit_overlay proc~seed_zinit_overlay->proc~seed_ts_from_zfile proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_zinit_overlay proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private, allocatable :: buf(:,:,:)
integer, private :: i
integer, private :: j
integer, private :: k

Source Code

   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