subroutine deallocate_sparse_matrix_int(sparse_mat)
type(sparse_matrix_int), intent(inout), allocatable :: sparse_mat(:)
integer :: i, ierr
if (allocated(sparse_mat)) then
do i = 1, size(sparse_mat)
if (allocated(sparse_mat(i)%elements)) then
deallocate(sparse_mat(i)%elements, stat=ierr)
if (ierr /= 0) write(stdout, '("Error when deallocating sparse matrix elements array:",1X,i8)') ierr
end if
if (allocated(sparse_mat(i)%positions)) then
deallocate(sparse_mat(i)%positions, stat=ierr)
if (ierr /= 0) write(stdout, '("Error when deallocating sparse matrix positions array:",1X,i8)') ierr
end if
end do
deallocate(sparse_mat, stat=ierr)
if (ierr /= 0) write(stdout, '("Error when deallocating sparse matrix array:",1X,i8)') ierr
end if
end subroutine deallocate_sparse_matrix_int