histpush_sub Subroutine

private subroutine histpush_sub(this, val)

Type Bound

history_stack_t

Arguments

Type IntentOptional Attributes Name
class(history_stack_t) :: this
type(vec4), intent(in) :: val

Source Code

    subroutine histpush_sub(this, val)

        class(history_stack_t) :: this
        type(vec4), intent(in) :: val
        
        type(vec4), allocatable :: tmp(:)

        if(.not. allocated(this%data) .or. size(this%data) == 0)then
            !allocate space if not yet allocated
            allocate(this%data(block_size))
        elseif(this%size == size(this%data))then
            allocate(tmp(size(this%data) + block_size))
            tmp(1:this%size) = this%data
            call move_alloc(tmp, this%data)
        end if

        this%size = this%size + 1
        this%data(this%size) = val

    end subroutine histpush_sub