Deallocate the gs2_diagnostics module-level arrays
subroutine deallocate_arrays
use mp, only: proc0
use gs2_heating, only: del_htype
use diagnostics_fluxes, only: finish_diagnostics_fluxes
use diagnostics_kinetic_energy_transfer, only: finish_diagnostics_kinetic_energy_transfer
implicit none
if (write_heating) then
call del_htype (h)
call del_htype (h_hist)
call del_htype (hk_hist)
call del_htype (hk)
end if
call finish_diagnostics_fluxes()
call finish_diagnostics_kinetic_energy_transfer()
if (allocated(h_hist)) deallocate (h_hist, hk_hist, hk)
if (allocated(j_ext_hist)) deallocate (j_ext_hist)
if (proc0 .and. allocated(omegahist)) deallocate (omegahist)
if (allocated(pflux_tormom)) deallocate (pflux_tormom)
if (allocated(pflux_avg)) deallocate (pflux_avg, qflux_avg, heat_avg, vflux_avg)
if (allocated(omega)) deallocate(omega, omegaavg)
if (proc0 .and. allocated(conv_heat)) deallocate (conv_heat)
if (proc0 .and. allocated(domega)) deallocate(domega)
end subroutine deallocate_arrays