tem_appendDp1dArray Subroutine

private subroutine tem_appendDp1dArray(Array, Position, Value)

append an entry to an allocatable array 1d with double precision If the array is too small, reallocate with double size


Type IntentOptional Attributes Name
real(kind=rk), intent(inout), allocatable :: Array(:)

array to append value to

integer, intent(in) :: Position

position the value is appended to

real(kind=rk), intent(in) :: Value

value to append

Called by

proc~~tem_appenddp1darray~~CalledByGraph proc~tem_appenddp1darray tem_appendDp1dArray interface~append~11 append interface~append~11->proc~tem_appenddp1darray proc~tem_findelement tem_findElement proc~tem_findelement->interface~append~11 proc~tem_findelement->proc~tem_findelement proc~tem_findpath tem_findPath proc~tem_findpath->interface~append~11 proc~tem_findpath->proc~tem_findpath proc~tem_calc_vrtx_coord tem_calc_vrtx_coord proc~tem_calc_vrtx_coord->interface~append~11 proc~tem_unify_vrtx tem_unify_vrtx proc~tem_calc_vrtx_coord->proc~tem_unify_vrtx proc~tem_unify_vrtx->interface~append~11 proc~hvs_output_init hvs_output_init proc~hvs_output_init->proc~tem_calc_vrtx_coord proc~tem_init_tracker tem_init_tracker proc~tem_init_tracker->proc~hvs_output_init


Source Code

Source Code

  subroutine tem_appendDp1dArray(Array, Position, Value )
    ! ---------------------------------------------------------------------------
    !> array to append value to
    real(kind=rk),intent(inout), allocatable :: Array(:)
    !> position the value is appended to
    integer,intent(in) :: Position
    !> value to append
    real(kind=rk),intent(in) :: Value
    ! ---------------------------------------------------------------------------
    real(kind=rk),allocatable :: tempArray(:)
    integer :: ArraySize,ierr, NewSize
    logical :: sizeZero
    ! ---------------------------------------------------------------------------

    ! Get size of array
    ArraySize = size(Array,1)
    ! Compare position, where to store with size
    if(Position .gt. ArraySize) then ! If position is larger than size
      sizeZero = .false.
      if( ArraySize .eq. 0) then
         ArraySize = 1
         sizeZero  = .true.
      NewSize = max(ArraySize*2, Position)
      ! allocate temporary array with double size
      ! Copy to temp array
      if( .not. sizeZero ) tempArray(1:ArraySize) = Array(1:ArraySize)

      ! Deallocate Array
      ! Reallocate Array
      Array(1:ArraySize) = tempArray(1:ArraySize)
      ! Deallocate temp array
      if(ierr .ne. 0) Write(*,*) 'Error in reallocating array'

    Array(Position) = Value

  end subroutine tem_appendDp1dArray