Guarantee that pool has at least needed elements, growing it by poolGrowth when it must
reallocate. Existing contents are NOT preserved: every caller re-establishes the array
contents after resizing (the solution through the AMR transfer, the geometry through
GenerateFromMesh, everything else by being written before it is read), so copying the old
data would be wasted bandwidth.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=prec), | intent(inout), | pointer, contiguous | :: | pool(:) | ||
| integer, | intent(in) | :: | needed |
subroutine EnsurePool(pool,needed)
!! Guarantee that pool has at least `needed` elements, growing it by poolGrowth when it must
!! reallocate. Existing contents are NOT preserved: every caller re-establishes the array
!! contents after resizing (the solution through the AMR transfer, the geometry through
!! GenerateFromMesh, everything else by being written before it is read), so copying the old
!! data would be wasted bandwidth.
implicit none
real(prec),pointer,contiguous,intent(inout) :: pool(:)
integer,intent(in) :: needed
! Local
integer :: capacity
if(associated(pool)) then
if(size(pool) >= needed) return
deallocate(pool)
endif
capacity = max(needed,int(real(needed,prec)*poolGrowth))
allocate(pool(1:capacity))
endsubroutine EnsurePool