24 module mpp_memutils_mod
37 logical :: memuse_started = .false.
44 if(memuse_started)
then
45 call mpp_error(fatal,
"mpp_memutils_mod: mpp_memuse_begin was already called")
47 memuse_started = .true.
56 character(len=*),
intent(in) :: text
57 integer,
intent(in),
optional :: unit
59 real :: m, mmin, mmax, mavg, mstd, end_memuse
62 if(.NOT.memuse_started)
then
63 call mpp_error(fatal,
"mpp_memutils_mod: mpp_memuse_begin must be called before calling mpp_memuse_being")
65 memuse_started = .false.
69 mu =
stderr();
if(
PRESENT(unit) )mu = unit
70 m = end_memuse - begin_memuse
75 if(
mpp_pe().EQ.mpp_root_pe() )
write( mu,
'(a64,4es11.3)' ) &
76 'Memory(MB) used in '//trim(text)//
'=', mmin, mmax, mstd, mavg
85 character(len=*),
intent(in) :: text
86 integer,
intent(in),
optional :: unit
88 real :: m, mmin, mmax, mavg, mstd
91 mu =
stderr();
if(
PRESENT(unit) )mu = unit
98 if(
mpp_pe().EQ.mpp_root_pe() )
write( mu,
'(a64,4es11.3)' ) &
99 'Memuse(MB) at '//trim(text)//
'=', mmin, mmax, mstd, mavg
110 real,
intent(out) :: memuse
113 integer(KIND=c_size_t) function getpeakrss()
bind(c, name="getpeakrss")
114 use,
intrinsic :: iso_c_binding
115 end function getpeakrss
119 real,
parameter :: b_to_mib = 1048576.0
122 memuse = real(getpeakrss())/b_to_mib
126 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...