ocean_diag_destroy Subroutine

private subroutine ocean_diag_destroy(this)

Type Bound

ocean_diag_t

Arguments

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

Calls

proc~~ocean_diag_destroy~~CallsGraph proc~ocean_diag_destroy ocean_diag_t%ocean_diag_destroy proc~diag_mask_destroy diag_mask_destroy proc~ocean_diag_destroy->proc~diag_mask_destroy

Variables

Type Visibility Attributes Name Initial
integer, private :: i

Source Code

   subroutine ocean_diag_destroy(this)
      class(ocean_diag_t), intent(inout) :: this
      integer :: i
      this%is_init = .false.
      if (allocated(this%vars)) then
         do i = 1, this%nvars
            if (allocated(this%vars(i)%output_buffer)) deallocate (this%vars(i)%output_buffer)
            if (allocated(this%vars(i)%layer_buffer)) deallocate (this%vars(i)%layer_buffer)
            if (allocated(this%vars(i)%accumulator)) deallocate (this%vars(i)%accumulator)
            if (allocated(this%vars(i)%mask)) then
               call diag_mask_destroy(this%vars(i)%mask)
               deallocate (this%vars(i)%mask)
            end if
            nullify (this%vars(i)%fill)
            nullify (this%vars(i)%remap)
         end do
         deallocate (this%vars)
      end if
      this%nvars = 0
      this%nvars_max = 0
      if (allocated(this%z_out)) deallocate (this%z_out)
      if (allocated(this%rho_out)) deallocate (this%rho_out)
      if (allocated(this%sigma_out)) deallocate (this%sigma_out)
      if (allocated(this%zstar_out)) deallocate (this%zstar_out)
      if (allocated(this%send_buf)) deallocate (this%send_buf)
      ! Host-only fp32 staging buffer for the single-precision diag stream
      ! (never device-mapped, so no exit_data pairing).  Normally released
      ! by `close_stream`; freed here too so a destroy without a close
      ! does not leak.
      if (allocated(this%nc_stream%stage)) deallocate (this%nc_stream%stage)
   end subroutine ocean_diag_destroy