mimic_stack_entry Derived Type

type, public :: mimic_stack_entry

Class representing the call stack entry


Contents

Source Code


Components

TypeVisibilityAttributesNameInitial
character(len=:), private, allocatable:: name

Name of the entry (procedure)

type(mimic_stack_entry), private, dimension(:), pointer:: children=> null()

Nested entries (internal calls)

type(mimic_stack_entry), private, pointer:: parent=> null()

Pointer to the parent entry

integer, private :: num_children =0

Number of nested entries

real(kind=dp), private, dimension(:), allocatable:: start_times

Array of times of start of the procedure

real(kind=dp), private, dimension(:), allocatable:: end_times

Array of times of finish of the procedure

integer, private :: num_calls

Total number of calls

integer, private :: hash

Hash identifier


Constructor

public interface mimic_stack_entry

  • public function init_entry(name, hash, num_calls, parent) result(entry)

    Initializer of a stack entry

    Arguments

    TypeIntentOptionalAttributesName
    character(len=*), intent(in) :: name

    Name of a function

    integer, intent(in) :: hash

    Hash ID

    integer, intent(in) :: num_calls

    Current number of calls

    type(mimic_stack_entry), pointer:: parent

    Parent entry

    Return Value type(mimic_stack_entry)


Type-Bound Procedures

procedure, public :: increment => increment_entry

  • public subroutine increment_entry(this)

    Add new start time to the entry

    Arguments

    TypeIntentOptionalAttributesName
    class(mimic_stack_entry), intent(inout) :: this

procedure, public :: print => print_entry

  • public recursive subroutine print_entry(this, level)

    Recursive function printing timing of the entry and its children

    Arguments

    TypeIntentOptionalAttributesName
    class(mimic_stack_entry), intent(inout) :: this
    integer, intent(in) :: level

Source Code

    type :: mimic_stack_entry
        private
        !> Name of the entry (procedure)
        character(len=:), allocatable :: name
        !> Nested entries (internal calls)
        type(mimic_stack_entry), dimension(:), pointer :: children => null()
        !> Pointer to the parent entry
        type(mimic_stack_entry), pointer :: parent => null()
        !> Number of nested entries
        integer :: num_children = 0
        !> Array of times of start of the procedure
        real(dp), dimension(:), allocatable :: start_times
        !> Array of times of finish of the procedure
        real(dp), dimension(:), allocatable :: end_times
        !> Total number of calls
        integer :: num_calls
        !> Hash identifier
        integer :: hash
    contains
        procedure :: increment => increment_entry
        procedure :: print => print_entry
    end type mimic_stack_entry