Module fd4_stat_mod


Uses:
    module fd4_globaldef_mod
    module fd4_mpi_mod
Types:
    public type fd4_stat
Variables:
    integer, private, parameter :: FD4_STATNAME_LEN = 20
    integer, private, parameter :: FD4_STAT_INITIAL_SIZE = 23
    integer, public, parameter :: FD4_STAT_STDOUT = 6
Subroutines and functions:
    public subroutine fd4_stat_add (stat, name, idx)
    public subroutine fd4_stat_reset (stat)
    public subroutine fd4_stat_free (stat)
    public subroutine fd4_stat_countup (stat, idx, value)
    public subroutine fd4_stat_dump (stat, mpi, opt_root, opt_out)

Internal statistics and Profiling of FD4

User interface: Use fd4_domain_dump_stats to dump the current values to stdout.

Use fd4_stat_add to create a new statistics. All ranks must call this function in the same order, so that the index returned by fd4_stat_add is equal in all ranks.

To set a value, just access it directly:

  type(fd4_stat) :: stat
  call fd4_stat_add(stat, 'Bytes transferred', bytes_idx)
  stat%values(bytes_idx) = size_bytes
 

Author: Matthias Lieber

See also: module fd4_domain_mod


Description of Types

fd4_stat

public type fd4_stat
    integer (kind=i8k), pointer, dimension (:) :: values => null ()
    character (len=FD4_STATNAME_LEN), pointer, dimension (:) :: names => null ()
    integer (kind=i_k) :: nstat = 0
    integer (kind=i_k), dimension (2) :: sfcbnd = (/ HUGE (0_i_k), -1 /)
end type fd4_stat
Components:
values values of the statistics
names names of the statistics
sfcbnd min and max SFC index of all partitions
type for a set of statistics

Description of Subroutines and Functions

fd4_stat_add

public subroutine fd4_stat_add (stat, name, idx)
    type (fd4_stat), intent(inout) :: stat
    character (len=*), intent(in) :: name
    integer (kind=i_k), intent(out) :: idx
end subroutine fd4_stat_add
Parameters:
stat the statistics object
name name of the new statistic
idx added index
Add a new statistic to the fd4_stat.

The index idx in the arrays values and names of the fd4_stat is returned. If the name already exists, the corresponding index is returned.

Returns negative idx on error.


fd4_stat_reset

public subroutine fd4_stat_reset (stat)
    type (fd4_stat), intent(inout) :: stat
end subroutine fd4_stat_reset
Reset all values to zero.

fd4_stat_free

public subroutine fd4_stat_free (stat)
    type (fd4_stat), intent(inout) :: stat
end subroutine fd4_stat_free
Free memory of an fd4_stat.

fd4_stat_countup

public subroutine fd4_stat_countup (stat, idx, value)
    type (fd4_stat), intent(inout) :: stat
    integer (kind=i_k), intent(in) :: idx
    integer (kind=i8k), intent(in) :: value
end subroutine fd4_stat_countup
Parameters:
stat the statistics object
idx index of the statistic
value value to add
Count given statistic up by given value.

fd4_stat_dump

public subroutine fd4_stat_dump (stat, mpi, opt_root, opt_out)
    type (fd4_stat), intent(in) :: stat
    type (fd4_mpi), intent(inout) :: mpi
    integer, optional, intent(in) :: opt_root
    integer, optional, intent(in) :: opt_out
end subroutine fd4_stat_dump
Parameters:
stat the statistics object
mpi MPI context
opt_root root MPI process that prints statistics
opt_out unit for output (use FD4_STAT_STDOUT for stdout)
Collect global min/max/avg/sum values of the FD4 statistics and let rank opt_root print the statistics to unit out. The default unit is stdout. The default root is rank 0.