FMS  2024.03
Flexible Modeling System
memutils_mod

Module to expose the memory printing API. More...

Functions/Subroutines

subroutine, public memutils_init (print_flag)
 Initialize the memutils module. More...
 
subroutine, public print_memuse_stats (text, unit, always)
 Print memory usage stats to stdout, or a particular file. More...
 

Variables

logical, private print_memory_usage =.FALSE.
 Default behavior of print_memuse_stats()
 

Detailed Description

Module to expose the memory printing API.

Author
V. Balaji

Module to expose the memory printing API

Model components at times desire to print the memory statics to stderr, or another file (e.g. the log file). This can be useful in debugging. This module exposes the print_memuse_stat and memutils_init calls for use in external user code.

Function/Subroutine Documentation

◆ memutils_init()

subroutine, public memutils_mod::memutils_init ( logical, optional  print_flag)

Initialize the memutils module.

memutils_init initializes the print_memory_usage and memutils_initialized module variables when called. This configures if print_memuse_stats() should print the memory statistics when called. memutils_init, at present, can be called multiple times, and potentially change the behavior of print_memuse_stats().

Parameters
print_flagIndicate if memory statistics should be printed by default

Definition at line 54 of file memutils.F90.

◆ print_memuse_stats()

subroutine, public memutils_mod::print_memuse_stats ( character(len=*), intent(in)  text,
integer, intent(in), optional  unit,
logical, intent(in), optional  always 
)

Print memory usage stats to stdout, or a particular file.

API to allow external user code to print memory statistics to stderr, or an optional file (Fortran file unit). The module variable print_memory_usage will control the default behavior (set when memutils_init is called). The default behavior can be modified passing in the optional always (logical) parameter. If always.eqv..TRUE., print_memuse_stats() will print the memory statistics.

Parameters
[in]textText to be printed before the memory statistics
[in]unitFortran file unit to where memory statistics should be recorded
[in]alwaysIf .TRUE., force memory statistics to be printed

Definition at line 70 of file memutils.F90.