25 module mpp_memutils_mod
38 logical :: memuse_started = .false.
45 if(memuse_started)
then
46 call mpp_error(fatal,
"mpp_memutils_mod: mpp_memuse_begin was already called")
48 memuse_started = .true.
57 character(len=*),
intent(in) :: text
58 integer,
intent(in),
optional :: unit
60 real :: m, mmin, mmax, mavg, mstd, end_memuse
63 if(.NOT.memuse_started)
then
64 call mpp_error(fatal,
"mpp_memutils_mod: mpp_memuse_begin must be called before calling mpp_memuse_being")
66 memuse_started = .false.
70 mu =
stderr();
if(
PRESENT(unit) )mu = unit
71 m = end_memuse - begin_memuse
76 if(
mpp_pe().EQ.mpp_root_pe() )
write( mu,
'(a64,4es11.3)' ) &
77 'Memory(MB) used in '//trim(text)//
'=', mmin, mmax, mstd, mavg
86 character(len=*),
intent(in) :: text
87 integer,
intent(in),
optional :: unit
89 real :: m, mmin, mmax, mavg, mstd
92 mu =
stderr();
if(
PRESENT(unit) )mu = unit
99 if(
mpp_pe().EQ.mpp_root_pe() )
write( mu,
'(a64,4es11.3)' ) &
100 'Memuse(MB) at '//trim(text)//
'=', mmin, mmax, mstd, mavg
111 real,
intent(out) :: memuse
114 integer(KIND=c_size_t) function getpeakrss()
bind(c, name="getpeakrss")
115 use,
intrinsic :: iso_c_binding
116 end function getpeakrss
120 real,
parameter :: b_to_mib = 1048576.0
123 memuse = real(getpeakrss())/b_to_mib
127 end module mpp_memutils_mod
subroutine, public mpp_memuse_end(text, unit)
End the memory collection, and report on total memory used during the execution of the model run.
subroutine, public mpp_memuse_begin
Initialize the memory module, and record the initial memory use.
subroutine, public mpp_mem_dump(memuse)
Return the memory high water mark in MiB.
subroutine, public mpp_print_memuse_stats(text, unit)
Print the current memory high water mark to stderr, or the unit specified.
integer function stderr()
This function returns the current standard fortran unit numbers for error messages.
integer function mpp_npes()
Returns processor count for current pelist.
integer function mpp_pe()
Returns processor ID.
Reduction operations. Find the max of scalar a from the PEs in pelist result is also automatically br...
Reduction operations. Find the min of scalar a from the PEs in pelist result is also automatically br...