column Derived Type

type, public :: column


Components

Type Visibility Attributes Name Initial
complex(kind=rk), private, dimension(:), allocatable :: ccol
character(len=:), private, dimension(:), allocatable :: charcol
integer, public :: dtype = 0
integer(kind=ik), private, dimension(:), allocatable :: icol
logical, private :: initialized = .false.
logical, private, dimension(:), allocatable :: lcol
integer, public :: n
real(kind=rk), private, dimension(:), allocatable :: rcol

Type-Bound Procedures

procedure, public :: changec => change_col_complex

  • private subroutine change_col_complex(this, i, val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: i
    complex(kind=rk), intent(in) :: val

procedure, public :: changech => change_col_character

  • private subroutine change_col_character(this, i, val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: i
    character(len=*), intent(in) :: val

procedure, public :: changei => change_col_integer

  • private subroutine change_col_integer(this, i, val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: i
    integer(kind=ik), intent(in) :: val

procedure, public :: changel => change_col_logical

  • private subroutine change_col_logical(this, i, val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: i
    logical, intent(in) :: val

procedure, public :: changer => change_col_real

  • private subroutine change_col_real(this, i, val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: i
    real(kind=rk), intent(in) :: val

procedure, private :: col_constructor_character

  • private subroutine col_constructor_character(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    character(len=*), intent(in), dimension(:) :: dcol

procedure, private :: col_constructor_complex

  • private subroutine col_constructor_complex(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    complex(kind=rk), intent(in), dimension(:) :: dcol

procedure, private :: col_constructor_integer

  • private subroutine col_constructor_integer(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer(kind=ik), intent(in), dimension(:) :: dcol

procedure, private :: col_constructor_logical

  • private subroutine col_constructor_logical(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    logical, intent(in), dimension(:) :: dcol

procedure, private :: col_constructor_real

  • private subroutine col_constructor_real(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    real(kind=rk), intent(in), dimension(:) :: dcol

procedure, public :: destroy => col_destructor

  • private subroutine col_destructor(this)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this

procedure, public :: emptyc => col_constructor_alloc_complex

procedure, public :: emptych => col_constructor_alloc_character

  • private subroutine col_constructor_alloc_character(this, n, len)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: n
    integer, intent(in), optional :: len

procedure, public :: emptyi => col_constructor_alloc_integer

procedure, public :: emptyl => col_constructor_alloc_logical

procedure, public :: emptyr => col_constructor_alloc_real

  • private subroutine col_constructor_alloc_real(this, n)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer, intent(in) :: n

procedure, private :: get_from_col_character

  • private pure function get_from_col_character(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value character(len=:), dimension(:), allocatable

procedure, private :: get_from_col_complex

  • private pure function get_from_col_complex(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value complex(kind=rk), dimension(this % n)

procedure, private :: get_from_col_integer

  • private pure function get_from_col_integer(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value integer(kind=ik), dimension(this % n)

procedure, private :: get_from_col_logical

  • private pure function get_from_col_logical(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value logical, dimension(this % n)

procedure, private :: get_from_col_real

  • private pure function get_from_col_real(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value real(kind=rk), dimension(this % n)

procedure, private :: get_single_col_character

  • private pure function get_single_col_character(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value character(len=:), allocatable

procedure, private :: get_single_col_complex

  • private pure function get_single_col_complex(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value complex(kind=rk)

procedure, private :: get_single_col_integer

  • private pure function get_single_col_integer(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value integer(kind=ik)

procedure, private :: get_single_col_logical

  • private pure function get_single_col_logical(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value logical

procedure, private :: get_single_col_real

  • private pure function get_single_col_real(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value real(kind=rk)

procedure, public :: get_type => get_from_col_dtype

  • private pure function get_from_col_dtype(this) result(dtype)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value integer

generic, public :: getc => get_from_col_complex, get_single_col_complex

  • private pure function get_from_col_complex(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value complex(kind=rk), dimension(this % n)

  • private pure function get_single_col_complex(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value complex(kind=rk)

generic, public :: getch => get_from_col_character, get_single_col_character

  • private pure function get_from_col_character(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value character(len=:), dimension(:), allocatable

  • private pure function get_single_col_character(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value character(len=:), allocatable

generic, public :: geti => get_from_col_integer, get_single_col_integer

  • private pure function get_from_col_integer(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value integer(kind=ik), dimension(this % n)

  • private pure function get_single_col_integer(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value integer(kind=ik)

generic, public :: getl => get_from_col_logical, get_single_col_logical

  • private pure function get_from_col_logical(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value logical, dimension(this % n)

  • private pure function get_single_col_logical(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value logical

generic, public :: getr => get_from_col_real, get_single_col_real

  • private pure function get_from_col_real(this) result(col)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this

    Return Value real(kind=rk), dimension(this % n)

  • private pure function get_single_col_real(this, i) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(in) :: this
    integer, intent(in) :: i

    Return Value real(kind=rk)

  • private subroutine col_constructor_real(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    real(kind=rk), intent(in), dimension(:) :: dcol
  • private subroutine col_constructor_integer(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    integer(kind=ik), intent(in), dimension(:) :: dcol
  • private subroutine col_constructor_logical(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    logical, intent(in), dimension(:) :: dcol
  • private subroutine col_constructor_character(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    character(len=*), intent(in), dimension(:) :: dcol
  • private subroutine col_constructor_complex(this, dcol)

    Arguments

    Type IntentOptional Attributes Name
    class(column), intent(inout) :: this
    complex(kind=rk), intent(in), dimension(:) :: dcol

Source Code

    type :: column
        private

        integer, public :: dtype = 0 ! no type
        integer, public :: n ! elements in column

        ! arrays to hold data
        ! only one (associated with dtype) will ever be allocated
        real(rk), dimension(:), allocatable :: rcol
        integer(ik), dimension(:), allocatable :: icol
        logical, dimension(:), allocatable :: lcol
        character(len=:), dimension(:), allocatable :: charcol
        complex(rk), dimension(:), allocatable :: ccol

        logical :: initialized = .false.

    contains
        private

        ! empty constructors
        procedure, public :: emptyr => col_constructor_alloc_real
        procedure, public :: emptyi => col_constructor_alloc_integer
        procedure, public :: emptyl => col_constructor_alloc_logical
        procedure, public :: emptych => col_constructor_alloc_character
        procedure, public :: emptyc => col_constructor_alloc_complex

        ! constructor/setter combo
        procedure :: col_constructor_real, &
            col_constructor_integer, &
            col_constructor_logical, &
            col_constructor_character, &
            col_constructor_complex
        generic, public :: new => col_constructor_real, &
            col_constructor_integer, &
            col_constructor_logical, &
            col_constructor_character, &
            col_constructor_complex
        ! destructor
        procedure, public :: destroy => col_destructor

        ! get data type
        procedure, public :: get_type => get_from_col_dtype

        ! get either whole column as array or single value
        procedure :: get_from_col_real, &
            get_from_col_integer, &
            get_from_col_logical, &
            get_from_col_character, &
            get_from_col_complex
        procedure :: get_single_col_real, &
            get_single_col_integer, &
            get_single_col_logical, &
            get_single_col_character, &
            get_single_col_complex
        generic, public :: getr => get_from_col_real, get_single_col_real
        generic, public :: geti => get_from_col_integer, get_single_col_integer
        generic, public :: getl => get_from_col_logical, get_single_col_logical
        generic, public :: getch => get_from_col_character, get_single_col_character
        generic, public :: getc => get_from_col_complex, get_single_col_complex

        ! Give element new value (setter)
        procedure, public :: changer => change_col_real
        procedure, public :: changei => change_col_integer
        procedure, public :: changel => change_col_logical
        procedure, public :: changech => change_col_character
        procedure, public :: changec => change_col_complex

    end type column