Base type to define a global timer. All watches within LightKrylov and associated tools are derived from this type.
Within LightKrylov, the derived type global_lightkrylov_timer
is used to manage all
atomic timers associated with both internal routines (private) as well as user-defined
(public) timers that can be added and removed as necessary. In order to protect the
private timers, they are defined and set only during the initialisation of the derived
type via the deferred procedure set_private_timers_and_name
if timing is requested
and cannot be deleted.
Once the global watch is initalized, the user can define and subsequently remove
user-defined timers at any point that will be managed by the global watch in the same
way as private timers.
Upon finalization, the user-defined timers with the associated timing information is
presented together with that of the private timers.
The type-bound procedures of the abstract_watch type allow individual access to each managed timer individually using the timer name as reference.
Add new timer group to the watch.
Type-bound to abstract_watch: Add timer group to watch. Note: The new group name must be unique. This is a quick hack and should be done better.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name | |||
integer, | intent(in) | :: | istart | |||
integer, | intent(in) | :: | iend | |||
integer, | intent(out), | optional | :: | count |
Add new timer to the watch.
Type-bound to abstract_watch: Add timer to watch and optionally start it immediately. Note: The new timer name must be unique.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name | |||
logical, | intent(in), | optional | :: | start | ||
integer, | intent(out), | optional | :: | count |
Print summary of registered timers and their current status.
Type-bound to abstract_watch: Summarize registered timers and their status.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(in) | :: | self | |||
logical, | intent(in), | optional | :: | only_user |
Summarize only user defined timers? default: .false. |
Gather timing information and print it to screen/logfile.
Finalize global watch within LightKrylov and print used timers.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
logical, | intent(in), | optional | :: | write_to_file |
Print timer summary to a dedicated timer logfile as well as the general log file? default: .true. |
Type-bound to abstract_watch: Getter routine to return the data for timer referenced by name. Notes: Wrapper of the corresponding routine from lightkrylov_timer. If it is running, the timer is stopped.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name | |||
logical, | intent(in), | optional | :: | restart | ||
real(kind=dp), | intent(out), | optional | :: | etime | ||
real(kind=dp), | intent(out), | optional | :: | etmin | ||
real(kind=dp), | intent(out), | optional | :: | etmax | ||
real(kind=dp), | intent(out), | optional | :: | etimp | ||
integer, | intent(out), | optional | :: | lcount | ||
integer, | intent(out), | optional | :: | rcount | ||
integer, | intent(out), | optional | :: | gcount |
Type-bound to abstract_watch: Getter routine to return the group id based on name.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch) | :: | self | ||||
character(len=*) | :: | name |
Timer name |
Type-bound to abstract_watch: Getter routine to return the current etime for timer referenced by name. Notes: Wrapper of the corresponding routine from lightkrylov_timer. If it is running, the timer is stopped.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch) | :: | self | ||||
character(len=*) | :: | name | ||||
logical, | optional | :: | restart |
Type-bound to abstract_watch: Getter routine to return the timer id based on name.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch) | :: | self | ||||
character(len=*) | :: | name |
Timer name |
Set up private timers, flags and counters. Switch on timing.
Initialize global watch within LightKrylov and define private system timers.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self |
Type-bound to abstract_watch: Pause timer referenced by name. Note: Wrapper of the corresponding routine from lightkrylov_timer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name |
Type-bound to abstract_watch: Print timing information for timer referenced by name. Note: Wrapper of the corresponding routine from lightkrylov_timer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name |
Remove existing timer from the watch.
Type-bound to abstract_watch: Remove timer from watch. Note: Timers considered private (defined during initialisation) cannot be removed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name | |||
integer, | intent(out), | optional | :: | count |
Type-bound to abstract_watch: Reset timer referenced by name. Note: Wrapper of the corresponding routine from lightkrylov_timer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name | |||
logical, | intent(in), | optional | :: | soft | ||
logical, | intent(in), | optional | :: | clean |
Reset all timers in watch.
Type-bound to abstract_watch: Utility function to reset all timers at once. Note: Wrapper of the corresponding routine from lightkrylov_timer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
logical, | intent(in), | optional | :: | soft | ||
logical, | intent(in), | optional | :: | clean |
Define private timers that cannot be removed by the user.
Interface for defining timers and groups.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self |
Type-bound to abstract_watch: Set name of watch
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name |
Watch name |
Type-bound to abstract_watch: Start timer referenced by name. Note: Wrapper of the corresponding routine from lightkrylov_timer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name |
Type-bound to abstract_watch: Stop timer referenced by name. Note: Wrapper of the corresponding routine from lightkrylov_timer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_watch), | intent(inout) | :: | self | |||
character(len=*), | intent(in) | :: | name |
type, abstract, public :: abstract_watch !! Base type to define a global timer. !! All watches within LightKrylov and associated tools are derived from this type. !! !! Within LightKrylov, the derived type `global_lightkrylov_timer` is used to manage all !! atomic timers associated with both internal routines (private) as well as user-defined !! (public) timers that can be added and removed as necessary. In order to protect the !! private timers, they are defined and set only during the initialisation of the derived !! type via the deferred procedure `set_private_timers_and_name` if timing is requested !! and cannot be deleted. !! Once the global watch is initalized, the user can define and subsequently remove !! user-defined timers at any point that will be managed by the global watch in the same !! way as private timers. !! Upon finalization, the user-defined timers with the associated timing information is !! presented together with that of the private timers. !! !! The type-bound procedures of the abstract_watch type allow individual access to each !! managed timer individually using the timer name as reference. private character(len=128) :: name = 'default_watch' type(lightkrylov_timer), dimension(:), allocatable :: timers !! Array of timers contained in the watch. integer :: timer_count = 0 !! Number of timers managed by watch. type(lightkrylov_timer_group), dimension(:), allocatable :: groups !! Array of timer groups contained in the watch. integer :: group_count = 0 !! Number of timer groups managed by watch. integer :: private_count = 0 !! Number of private timers (immutable by user). integer :: user_count = 0 !! Number of user defined timers. logical :: user_mode = .false. !! Number of user defined timers. logical :: is_initialized = .false. contains private procedure, pass(self), public :: add_timer !! Add new timer to the watch. procedure, pass(self), public :: remove_timer !! Remove existing timer from the watch. procedure, pass(self), public :: add_group !! Add new timer group to the watch. ! Getter/Setter and helper routines for watch components. procedure, pass(self), public :: get_timer_id procedure, pass(self), public :: get_group_id procedure, pass(self), public :: set_watch_name ! Wrappers for the basic timing routines/access to timer components. procedure, pass(self), public :: start => start_timer_by_name procedure, pass(self), public :: stop => stop_timer_by_name procedure, pass(self), public :: pause => pause_timer_by_name procedure, pass(self), public :: reset => reset_timer_by_name procedure, pass(self), public :: get_time => get_timer_etime_by_name procedure, pass(self), public :: get_data => get_timer_data_by_name procedure, pass(self), public :: print_info => print_timer_info_by_name ! Global manipulation routines. procedure, pass(self), public :: reset_all !! Reset all timers in watch. procedure, pass(self), public :: enumerate !! Print summary of registered timers and their current status. procedure, pass(self), public :: initialize !! Set up private timers, flags and counters. Switch on timing. procedure, pass(self), public :: finalize !! Gather timing information and print it to screen/logfile. procedure(abstract_set_timers), pass(self), deferred, public :: set_private_timers_and_name !! Define private timers that cannot be removed by the user. end type abstract_watch