Dellocate memory
subroutine overlap_dealloc()
!%%%%%%%%%%%%%%%%%%%%%
!! Dellocate memory
use w90_parameters, only: u_matrix, m_matrix, m_matrix_orig, &
a_matrix, u_matrix_opt, &
m_matrix_local, m_matrix_orig_local
use w90_io, only: io_error
implicit none
integer :: ierr
if (allocated(u_matrix_opt)) then
deallocate (u_matrix_opt, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating u_matrix_opt in overlap_dealloc')
end if
if (allocated(a_matrix)) then
deallocate (a_matrix, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating a_matrix in overlap_dealloc')
end if
if (on_root) then
if (allocated(m_matrix_orig)) then
deallocate (m_matrix_orig, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating m_matrix_orig in overlap_dealloc')
endif
endif
if (allocated(m_matrix_orig_local)) then
deallocate (m_matrix_orig_local, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating m_matrix_orig_local in overlap_dealloc')
endif
!~![ysl-b]
!~ if (allocated( ph_g)) then
!~ deallocate( ph_g, stat=ierr )
!~ if (ierr/=0) call io_error('Error deallocating ph_g in overlap_dealloc')
!~ endif
!~![ysl-e]
! if (on_root) then
! deallocate ( m_matrix, stat=ierr )
! if (ierr/=0) call io_error('Error deallocating m_matrix in overlap_dealloc')
! endif
! deallocate ( m_matrix_local, stat=ierr )
! if (ierr/=0) call io_error('Error deallocating m_matrix_local in overlap_dealloc')
! deallocate ( u_matrix, stat=ierr )
! if (ierr/=0) call io_error('Error deallocating u_matrix in overlap_dealloc')
if (on_root) then
if (allocated(m_matrix)) then
deallocate (m_matrix, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating m_matrix in overlap_dealloc')
endif
endif
if (allocated(m_matrix_local)) then
deallocate (m_matrix_local, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating m_matrix_local in overlap_dealloc')
endif
if (allocated(u_matrix)) then
deallocate (u_matrix, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating u_matrix in overlap_dealloc')
endif
return
end subroutine overlap_dealloc