ocean_diag_bytes Function

private pure function ocean_diag_bytes(this) result(nbytes)

Counted allocatable footprint of the diagnostics slot: the flat remap-level arrays, the host NetCDF staging buffer, AND the per-variable registry buffers (0 when unallocated). One arr_bytes term per array — add a term here when a new allocatable joins the type; new diag_var_t buffers go in diag_var_bytes.

Type Bound

ocean_diag_t

Arguments

Type IntentOptional Attributes Name
class(ocean_diag_t), intent(in) :: this

Return Value integer(kind=int64)


Calls

proc~~ocean_diag_bytes~~CallsGraph proc~ocean_diag_bytes ocean_diag_t%ocean_diag_bytes interface~arr_bytes arr_bytes proc~ocean_diag_bytes->interface~arr_bytes proc~diag_var_bytes diag_var_t%diag_var_bytes proc~ocean_diag_bytes->proc~diag_var_bytes proc~arr_bytes_i1 arr_bytes_i1 interface~arr_bytes->proc~arr_bytes_i1 proc~arr_bytes_i2 arr_bytes_i2 interface~arr_bytes->proc~arr_bytes_i2 proc~arr_bytes_i3 arr_bytes_i3 interface~arr_bytes->proc~arr_bytes_i3 proc~arr_bytes_l1 arr_bytes_l1 interface~arr_bytes->proc~arr_bytes_l1 proc~arr_bytes_l2 arr_bytes_l2 interface~arr_bytes->proc~arr_bytes_l2 proc~arr_bytes_l3 arr_bytes_l3 interface~arr_bytes->proc~arr_bytes_l3 proc~arr_bytes_r1 arr_bytes_r1 interface~arr_bytes->proc~arr_bytes_r1 proc~arr_bytes_r2 arr_bytes_r2 interface~arr_bytes->proc~arr_bytes_r2 proc~arr_bytes_r3 arr_bytes_r3 interface~arr_bytes->proc~arr_bytes_r3 proc~arr_bytes_r4 arr_bytes_r4 interface~arr_bytes->proc~arr_bytes_r4 proc~diag_var_bytes->interface~arr_bytes proc~diag_mask_bytes diag_mask_t%diag_mask_bytes proc~diag_var_bytes->proc~diag_mask_bytes proc~diag_mask_bytes->interface~arr_bytes

Variables

Type Visibility Attributes Name Initial
integer, private :: i

Source Code

   pure function ocean_diag_bytes(this) result(nbytes)
      !! Counted allocatable footprint of the diagnostics slot: the flat
      !! remap-level arrays, the host NetCDF staging buffer, AND the
      !! per-variable registry buffers (0 when unallocated).  One
      !! arr_bytes term per array — add a term here when a new allocatable
      !! joins the type; new `diag_var_t` buffers go in `diag_var_bytes`.
      class(ocean_diag_t), intent(in) :: this
      integer(int64) :: nbytes
      integer :: i
      nbytes = arr_bytes(this%z_out) &
               + arr_bytes(this%rho_out) &
               + arr_bytes(this%sigma_out) &
               + arr_bytes(this%zstar_out) &
               + arr_bytes(this%send_buf)
      ! `nc_stream%stage` is real32, which `arr_bytes` (real(wp) only) does
      ! not cover — counted inline at 4 bytes/element.  Unallocated on the
      ! default double-precision diag stream.
      if (allocated(this%nc_stream%stage)) then
         nbytes = nbytes + 4_int64*int(size(this%nc_stream%stage), int64)
      end if
      ! Registry: `nvars` live entries out of `nvars_max` capacity — the
      ! tail slots past `nvars` are default-initialised and unallocated,
      ! but bound the loop by `nvars` anyway so the term tracks what is
      ! actually registered (and mapped).
      if (allocated(this%vars)) then
         do i = 1, min(this%nvars, size(this%vars))
            nbytes = nbytes + this%vars(i)%bytes()
         end do
      end if
   end function ocean_diag_bytes