37 #if defined(__sgi) || defined(__aix) || defined(__SX) 42 call mpp_error(fatal,
"mpp_memutils_mod: mpp_memuse_begin was already called")
46 #if defined(__sgi) || defined(__aix) || defined(__SX) 57 character(len=*),
intent(in) :: text
58 integer,
intent(in),
optional :: unit
59 real :: m, mmin, mmax, mavg, mstd, end_memuse
61 #if defined(__sgi) || defined(__aix) || defined(__SX) 66 call mpp_error(fatal,
"mpp_memutils_mod: mpp_memuse_begin must be called before calling mpp_memuse_being")
70 #if defined(__sgi) || defined(__aix) || defined(__SX) 71 end_memuse = memuse()*1e-3
76 mu = stderr();
if(
PRESENT(unit) )mu = unit
80 mavg = m;
call mpp_sum(mavg); mavg = mavg/mpp_npes()
81 mstd = (m-mavg)**2;
call mpp_sum(mstd); mstd = sqrt( mstd/mpp_npes() )
82 if( mpp_pe().EQ.mpp_root_pe() )
write( mu,
'(a64,4es11.3)' ) &
83 'Memory(MB) used in '//trim(text)//
'=', mmin, mmax, mstd, mavg
93 character(len=*),
intent(in) :: text
94 integer,
intent(in),
optional :: unit
95 real :: m, mmin, mmax, mavg, mstd
99 #if defined(__sgi) || defined(__aix) || defined(__SX) 103 mu = stderr();
if(
PRESENT(unit) )mu = unit
104 #if defined(__sgi) || defined(__aix) || defined(__SX) 111 mavg = m;
call mpp_sum(mavg); mavg = mavg/mpp_npes()
112 mstd = (m-mavg)**2;
call mpp_sum(mstd); mstd = sqrt( mstd/mpp_npes() )
113 if( mpp_pe().EQ.mpp_root_pe() )
write( mu,
'(a64,4es11.3)' ) &
114 'Memuse(MB) at '//trim(text)//
'=', mmin, mmax, mstd, mavg
123 real,
intent(out) :: memuse
129 character(len=32) :: file_name =
'/proc/self/status' 130 character(len=32) ::
string 137 mem_unit = get_unit()
138 open(mem_unit, file=file_name, form=
'FORMATTED', action=
'READ', access=
'SEQUENTIAL')
140 do;
read (mem_unit,
'(a)', end=10)
string 141 if ( index(
string,
'VmHWM:' ) == 1 )
then 148 multiplier = 1.0/1024.
151 memuse = memuse * multiplier
subroutine, public mpp_memuse_begin
subroutine, public mpp_mem_dump(memuse)
subroutine, public mpp_print_memuse_stats(text, unit)
subroutine, public mpp_memuse_end(text, unit)