FlatNDData Derived Type

type, public, extends(Object) :: FlatNDData

Flat representation of multidimensional data allowing for multidimensional indexing using vector notation - i.e. dataObj%getValue([1,2,3]) = someData(1,2,3). Allows for dimensionality agnostic implementations of various algorithms.


Components

Type Visibility Attributes Name Initial
logical, public :: userDefined = .false.

True only if user explicitly sets it to true

integer(kind=ik), private, allocatable, dimension(:) :: dims

Dimension sizes of each dimension

real(kind=rk), public, allocatable, dimension(:) :: data

Flattened data array (in Fortran order!)


Type-Bound Procedures

procedure, public :: isDefined => isDefinedObject

  • interface

    private pure module function isDefinedObject(this) result(defined)

    Getter for userDefined

    Arguments

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

    Return Value logical

procedure, public :: makeDefined => makeDefinedObject

  • interface

    private pure module subroutine makeDefinedObject(this)

    Set userDefined to .true.

    Arguments

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

procedure, public :: makeUndefined => makeUndefinedObject

  • interface

    private pure module subroutine makeUndefinedObject(this)

    Set userDefined to .false.

    Arguments

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

procedure, public :: getValue

  • interface

    private pure module function getValue(this, indexSet) result(val)

    Return multidimensional value for given indexSet (should match array dimension)

    Arguments

    Type IntentOptional Attributes Name
    class(FlatNDData), intent(in) :: this
    integer(kind=ik), intent(in), dimension(:) :: indexSet

    Return Value real(kind=rk)

procedure, public :: get1DSlice

  • interface

    private pure module function get1DSlice(this, indexSet, sliceIndex) result(val)

    Return 1D slice of data at dimension given by sliceIndex and with the other indices set to indexSet

    Arguments

    Type IntentOptional Attributes Name
    class(FlatNDData), intent(in) :: this
    integer(kind=ik), intent(in), dimension(:) :: indexSet
    integer(kind=ik), intent(in) :: sliceIndex

    Return Value real(kind=rk), allocatable, dimension(:)

procedure, public :: get1DSliceIndices

  • interface

    private pure module function get1DSliceIndices(this, indexSet, sliceIndex) result(val)

    Return 1D slice indices of data at dimension given by sliceIndex and with the other indices set to indexSet

    Arguments

    Type IntentOptional Attributes Name
    class(FlatNDData), intent(in) :: this
    integer(kind=ik), intent(in), dimension(:) :: indexSet
    integer(kind=ik), intent(in) :: sliceIndex

    Return Value integer(kind=ik), allocatable, dimension(:)

procedure, public :: getDims

  • interface

    private pure module function getDims(this) result(dims)

    Return shape of data stored

    Arguments

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

    Return Value integer(kind=ik), allocatable, dimension(:)

procedure, public :: init => initFlatNDData

  • interface

    private pure module subroutine initFlatNDData(this, array)

    Initializes the data based on a deferred rank input array

    Arguments

    Type IntentOptional Attributes Name
    class(FlatNDData), intent(inout) :: this
    real(kind=rk), intent(in), dimension(..) :: array

procedure, public :: directInit

  • interface

    private pure module subroutine directInit(this, array, dims)

    Initializes the data based on an already flat array. Requires dimensions/shape to be explicitly passed

    Arguments

    Type IntentOptional Attributes Name
    class(FlatNDData), intent(inout) :: this
    real(kind=rk), intent(in), dimension(:) :: array
    integer(kind=ik), intent(in), dimension(:) :: dims