dvector_t Derived Type

type, public :: dvector_t


Contents

Source Code


Components

TypeVisibility AttributesNameInitial
integer, public :: len_init =8
integer, public :: len =0
integer, public :: len_max =16
real(kind=rp), public, dimension(:), allocatable:: buffer

Type-Bound Procedures

procedure, public :: delete => dvector_delete

  • public subroutine dvector_delete(this)

    Deletes a dvector. No access is allowed to this object after this call.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this

procedure, public :: clear => dvector_clear

  • public subroutine dvector_clear(this)

    Clears a dvector. Access allowed after a call to clear.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this

procedure, public :: get_val => dvector_get_val

  • public function dvector_get_val(this, i) result(res)

    Returns the ith element of a dvector.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(in) :: this
    integer, intent(in) :: i

    Return Value real(kind=rp)

procedure, public :: set_val => dvector_set_val

  • public subroutine dvector_set_val(this, i, val)

    Sets the value of the ith element of a dvector. No bounds check is performed.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this
    integer, intent(in) :: i
    real(kind=rp), intent(in) :: val

procedure, public :: get_data => dvector_get_data

  • public subroutine dvector_get_data(this, res, ibeg, iend)

    Returns a pointer to the underlying data of a dvector

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(in), target:: this
    real(kind=rp), intent(out), dimension(:), pointer:: res
    integer, intent(in), optional :: ibeg
    integer, intent(in), optional :: iend

procedure, public :: append => dvector_append

  • public subroutine dvector_append(this, val)

    Adds an element to the end of a dvector. Reallocation will take place if required.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this
    real(kind=rp), intent(in) :: val

procedure, public :: pop => dvector_pop

  • public function dvector_pop(this) result(val)

    Removes the last element and returns it. Calling this method on an empty list

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this

    Return Value real(kind=rp)

procedure, public :: resize => dvector_resize

  • public subroutine dvector_resize(this, new_size, ierr)

    Resizes a vector to a given size. Existing data is truncated if desired size is smaller than current size. Otherwise, the empty spaces are filled with zero.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this
    integer, intent(in) :: new_size
    integer, intent(out), optional :: ierr

procedure, public :: shrink_to_fit => dvector_shrink_to_fit

  • public subroutine dvector_shrink_to_fit(this, ierr)

    Releases additional memory to fit underlying data of a dvector to a size this%len_init.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this
    integer, intent(out), optional :: ierr

procedure, public :: sort => dvector_sort

  • public subroutine dvector_sort(this, order)

    Sorts a dvector in ascending order. If order is provided, it will contain the sorted indices. The size of order must be at least this%len.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this
    integer, intent(out), optional dimension(:):: order

procedure, public :: unique => dvector_unique

  • public subroutine dvector_unique(this)

    Sorts and removes all duplicate entries of a dvector. Note that the internal buffer size remains unchanged. To reduce the buffer size, call dvector_shrink_to_fit.

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(inout) :: this

procedure, public :: print => dvector_print

  • public subroutine dvector_print(this)

    Prints a dvector

    Arguments

    Type IntentOptional AttributesName
    class(dvector_t), intent(in) :: this

Source Code

type dvector_t
    integer :: len_init = 8 !Must be > 0
    integer :: len = 0
    integer :: len_max = 16 !Must be > len_init
    real(rp), dimension(:), allocatable :: buffer

    contains
        procedure :: delete => dvector_delete
        procedure :: clear => dvector_clear
        procedure :: get_val => dvector_get_val
        procedure :: set_val => dvector_set_val
        procedure :: get_data => dvector_get_data
        procedure :: append => dvector_append
        procedure :: pop => dvector_pop
        procedure :: resize => dvector_resize
        procedure :: shrink_to_fit => dvector_shrink_to_fit
        procedure :: sort => dvector_sort
        procedure :: unique => dvector_unique
        procedure :: print => dvector_print
end type dvector_t