mimic_utils Module



Contents


Variables

TypeVisibilityAttributesNameInitial
character(len=*), public, parameter, dimension(2):: CITE_PAPERS =["J. Chem. Theory Comput. 2019, 15, 6, 3810–3823 ", "J. Chem. Theory Comput. 2019, 15, 10, 5601–5613"]
type(mimic_timer), public, save:: timer
type(mimic_stack_entry), public, pointer, save:: current_entry=> null()

Interfaces

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)


Derived Types

type, public :: mimic_stack_entry

Class representing the call stack entry

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 function init_entry(name, hash, num_calls, parent)

Initializer of a stack entry

Type-Bound Procedures

procedure, public :: increment => increment_entry
procedure, public :: print => print_entry

type, public :: mimic_timer

Timer class storing all function calls

Components

TypeVisibilityAttributesNameInitial
type(mimic_stack_entry), private, dimension(:), pointer:: entries

List of top-level function calls

integer, private :: num_entries =0

Number of entries

Type-Bound Procedures

procedure, private :: start => start_timer
procedure, private :: stop => stop_timer
procedure, private :: print => print_timings

Functions

public function get_time() result(time)

Get current time

Arguments

None

Return Value real(kind=dp)

public pure function hash_str(str) result(hash)

Calculate a hash of the string

Arguments

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

Return Value integer

public function start_timer(this, parent, name) result(res)

Start a timer for a given function

Arguments

TypeIntentOptionalAttributesName
class(mimic_timer), intent(inout), target:: this
type(mimic_stack_entry), intent(inout), pointer:: parent

pointer to parent stack entry

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

name of the procedure

Return Value type(mimic_stack_entry),pointer

Pointer to a created stack entry

public function add_call(entries, num_entries, hash, name, parent) result(entry)

Add a function call to registry

Arguments

TypeIntentOptionalAttributesName
type(mimic_stack_entry), intent(inout), dimension(:), pointer:: entries
integer, intent(inout) :: num_entries
integer, intent(in) :: hash
character(len=*), intent(in) :: name
type(mimic_stack_entry), intent(in), pointer:: parent

Return Value type(mimic_stack_entry),pointer

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)

public recursive function find_entry(entries, num_entries, hash) result(entry)

Recursive function looking for the entry in array by hash

Arguments

TypeIntentOptionalAttributesName
type(mimic_stack_entry), intent(in), dimension(:), pointer:: entries

List of entries to search

integer :: num_entries

Number of entries

integer, intent(in) :: hash

Hash ID of the function

Return Value type(mimic_stack_entry),pointer

pointer to a found entry or null pointer


Subroutines

public subroutine print_welcome()

Writes a welcome message to the standard output together with the list of papers to cite.

Arguments

None

public subroutine timer_start(name)

Start timing the routine with a given name. This procedure will start tracking the execution time of a given function in a call stack tree. Subsequent calls to this function will create additional entries in the call stack that are going to be shown as children of the original routine.

Arguments

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

Name of the function to time.

public subroutine timer_stop()

Stop timing last routine. This procedure will record the finishing time of the routine that was timed the last. Moreover, it will move one level up in the call stack hierarchy.

Arguments

None

public subroutine timer_print()

Print the call stack with timing information.

Arguments

None

public subroutine stop_timer(this, entry)

Stop a timer for a given function (invalidates the pointer)

Arguments

TypeIntentOptionalAttributesName
class(mimic_timer), intent(inout), target:: this
type(mimic_stack_entry), intent(inout), pointer:: entry

Function timing of which is currently measured

public subroutine print_timings(this)

Print measured timings of function calls

Arguments

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

public subroutine increment_entry(this)

Add new start time to the entry

Arguments

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

public recursive subroutine copy_entry(src, dst)

Recursive function making a deep copy of stack_entry

Arguments

TypeIntentOptionalAttributesName
type(mimic_stack_entry), intent(in) :: src

Source entry

type(mimic_stack_entry), intent(out), target:: dst

Result

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