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 | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_diag_t), | intent(in) | :: | this |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i |
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