expand_ga_point Subroutine

private subroutine expand_ga_point(me, pos, length)


Type IntentOptional AttributesName
type(grw_pointarray_type) :: me
integer, intent(in), optional :: pos
integer, intent(in), optional :: length

optional length to expand the array

Called by

proc~~expand_ga_point~~CalledByGraph proc~expand_ga_point expand_ga_point interface~expand~32 expand interface~expand~32->proc~expand_ga_point proc~placeat_ga_point_vec placeat_ga_point_vec proc~placeat_ga_point_vec->interface~expand~32 proc~placeat_ga_point placeat_ga_point proc~placeat_ga_point->interface~expand~32 proc~append_ga_point append_ga_point proc~append_ga_point->interface~expand~32 proc~append_ga_point_vec append_ga_point_vec proc~append_ga_point_vec->interface~expand~32 interface~append~35 append interface~append~35->proc~append_ga_point interface~append~35->proc~append_ga_point_vec interface~placeat~22 placeat interface~placeat~22->proc~placeat_ga_point_vec interface~placeat~22->proc~placeat_ga_point


Source Code

Source Code

  subroutine expand_ga_point(me, pos, length)
    type(grw_pointarray_type) :: me !< array to resize
    integer, intent(in), optional :: pos !< optional predefined position
    !> optional length to expand the array
    integer, intent(in), optional :: length

    type(tem_point_type), allocatable :: swpval(:)
    integer :: explen, ii

    explen = 0
    ! increase the container by the requested length of double it
    if( present(length) ) then
      explen = max( length, minlength )
      ! set the global minimum length, if doubling would be smaller than that
      explen = max(me%containersize, minlength)
    end if

    ! if a position is given, increase the container to at least the size to
    ! fit the position.
    if( present(pos) ) explen = max(explen, pos-me%containersize)

    ! if the current size plus explen exceeds the max container size,
    ! reduce the size to the max container size.
    if( (huge(me%containersize) - explen) <= me%containersize) then
      ! set max container size
      me%containersize = huge(me%containersize)
      ! set the new container size
      me%containersize = me%containersize + explen
    end if

    if ( me%nvals > 0 ) then
      do ii = 1, me%nvals
        swpval(ii) = me%val(ii)
      end do
      call move_alloc( swpval, me%val )
    else ! me%nvals == 0
      if ( allocated(me%val) ) deallocate( me%val )
      allocate( me%val(me%containersize) )
    end if

  end subroutine expand_ga_point