CalculationNode Derived Type

type, public, extends(Object) :: CalculationNode

Node class for the abstract calculation left child/right sibling tree. Each node has a reference to its leftmost child, its sibling to the immediate right, and to its parent.

Each node has a binary mode that is either additive or multiplicative, with multiplicative being the default. This mode is applied to the results of the nodes children, either multiplying or adding them.

Each node also has a constant (defaulting to 1 in multiplicative and 0 in additive mode), which is applied to the node's result.

An optional unary operation can be associated with each node, which is then applied to the node's result after the constant. The unary operation can be parameterized with real, integer, or logical parameters.

Finally, if a node doesn't have a child (it is a leaf), it must have a nonzero index associated with a passed RealArray(:) list of variables, with the associated values then treated as the missing child's result.


Components

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

True only if user explicitly sets it to true

type(CalculationNode), public, pointer :: leftChild => null()
type(CalculationNode), public, pointer :: rightSibling => null()
type(CalculationNode), public, pointer :: parent => null()
type(CalculationKernel), public :: kernel
procedure(realArrayFunctionGenParam), public, pointer, nopass :: unaryTransform => null()

Optional unary transformation


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 :: addChild

  • interface

    public module subroutine addChild(this, additiveMode, constant, leafVarIndex, unaryRealParams, unaryIntParams, unaryLogicalParams, unaryTransformTag)

    Initialize a child node of this node with given properties

    Arguments

    Type IntentOptional Attributes Name
    class(CalculationNode), intent(inout), target :: this
    logical, intent(in), optional :: additiveMode
    real(kind=rk), intent(in), optional :: constant
    integer(kind=ik), intent(in), optional :: leafVarIndex
    real(kind=rk), intent(in), optional, dimension(:) :: unaryRealParams
    integer(kind=ik), intent(in), optional, dimension(:) :: unaryIntParams
    logical, intent(in), optional, dimension(:) :: unaryLogicalParams
    character(len=*), intent(in), optional :: unaryTransformTag

procedure, public :: init => initNode

  • interface

    public module subroutine initNode(this, additiveMode, constant, leafVarIndex, unaryRealParams, unaryIntParams, unaryLogicalParams, unaryTransformTag)

    Calculation node initialization routine

    Arguments

    Type IntentOptional Attributes Name
    class(CalculationNode), intent(inout) :: this
    logical, intent(in), optional :: additiveMode
    real(kind=rk), intent(in), optional :: constant
    integer(kind=ik), intent(in), optional :: leafVarIndex
    real(kind=rk), intent(in), optional, dimension(:) :: unaryRealParams
    integer(kind=ik), intent(in), optional, dimension(:) :: unaryIntParams
    logical, intent(in), optional, dimension(:) :: unaryLogicalParams
    character(len=*), intent(in), optional :: unaryTransformTag

procedure, public :: evaluate => evaluateNode

  • interface

    public pure recursive module function evaluateNode(this, inputArray) result(res)

    Recursively evaluate nodes, using the inputArray variables for leaf values

    Arguments

    Type IntentOptional Attributes Name
    class(CalculationNode), intent(in) :: this
    type(RealArray), intent(in), dimension(:) :: inputArray

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

procedure, public :: destroy => destroyNode

  • interface

    public pure recursive module subroutine destroyNode(this)

    Arguments

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