Deallocate PFASST level deallocate flat buffers for communcition deallocate nodes, flags, and integration matrices deallocate solution and function storage
destroy the sweeper
deallocate misc. arrays
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pf_level_t), | intent(inout) | :: | lev | level to destroy |
||
integer | :: | nlevels | number of pfasst levels |
subroutine pf_level_destroy(lev,nlevels)
use pf_mod_quadrature
class(pf_level_t), intent(inout) :: lev !! level to destroy
integer :: nlevels !! number of pfasst levels
integer :: npieces !! local copy of number of function pieces
if (.not. lev%allocated) return
!> deallocate flat buffers for communcition
deallocate(lev%send)
deallocate(lev%recv)
!> deallocate nodes, flags, and integration matrices
deallocate(lev%nodes)
deallocate(lev%nflags)
call pf_destroy_sdcmats(lev%sdcmats)
deallocate(lev%sdcmats)
!> deallocate solution and function storage
npieces = lev%ulevel%sweeper%npieces
if ((lev%index < nlevels) .and. allocated(lev%tauQ)) then
call lev%ulevel%factory%destroy_array(lev%tauQ, lev%nnodes-1, lev%index, lev%shape)
end if
call lev%ulevel%factory%destroy_array(lev%Q, lev%nnodes, lev%index, lev%shape)
call lev%ulevel%factory%destroy_array(lev%Fflt, lev%nnodes*npieces, lev%index, lev%shape)
call lev%ulevel%factory%destroy_array(lev%I, lev%nnodes-1, lev%index, lev%shape)
call lev%ulevel%factory%destroy_array(lev%R, lev%nnodes-1, lev%index, lev%shape)
call lev%ulevel%factory%destroy_array(lev%pFflt, lev%nnodes*npieces, lev%index, lev%shape)
if (lev%index < nlevels) then
call lev%ulevel%factory%destroy_array(lev%pQ, lev%nnodes, lev%index, lev%shape)
end if
call lev%ulevel%factory%destroy_single(lev%qend, lev%index, lev%shape)
call lev%ulevel%factory%destroy_single(lev%q0, lev%index, lev%shape)
!> destroy the sweeper
call lev%ulevel%sweeper%destroy(lev)
!> deallocate misc. arrays
if (allocated(lev%shape)) then
deallocate(lev%shape)
end if
if (allocated(lev%tmat)) then
deallocate(lev%tmat)
end if
if (allocated(lev%rmat)) then
deallocate(lev%rmat)
end if
end subroutine pf_level_destroy