grow_r64 Subroutine

private subroutine grow_r64(a, need)

Real counterpart of grow_i32.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(inout), allocatable :: a(:)

Array.

integer(kind=int32), intent(in) :: need

Number of entries needed.


Source Code

   subroutine grow_r64(a, need)
      !! Real counterpart of `grow_i32`.
      ! Arguments
      real(real64), allocatable, intent(inout) :: a(:)
         !! Array.
      integer(int32), intent(in) :: need
         !! Number of entries needed.
      real(real64), allocatable :: tmp(:)
      integer(int32) :: cap
      if (.not. allocated(a)) then
         allocate (a(max(need, 64_int32)))
         return
      end if
      cap = int(size(a), int32)
      if (need <= cap) return
      allocate (tmp(max(need, 2*cap)))
      tmp(1:cap) = a
      call move_alloc(tmp, a)
   end subroutine grow_r64