Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
!===============================================================================
!===============================================================================
!
! (parallel) heap memory recording tool
!
! C. Thieulot May 2008
!
!===============================================================================
!===============================================================================
subroutine heap (threadinfo,arrayname,routinename,arraysize,datatype,alloc)
use definitions
use threads
implicit none
character*(*) arrayname,routinename,datatype
type (thread) threadinfo
integer arraysize,alloc
integer iunit,ndata
character signe
if (alloc>0 .and. threadinfo%err.ne.0) call stop_run ('Error alloc '//arrayname//' in '//routinename//'$')
iunit=threadinfo%mem_heap_unit
select case (trim(datatype))
case('bool')
ndata=0
!ndata=4*arraysize
threadinfo%mem_int=threadinfo%mem_int + alloc * ndata
threadinfo%mem_tot=threadinfo%mem_tot + alloc * ndata
case('int','real')
ndata=4*arraysize
threadinfo%mem_int=threadinfo%mem_int + alloc * ndata
threadinfo%mem_tot=threadinfo%mem_tot + alloc * ndata
case('dp')
ndata=8*arraysize
threadinfo%mem_dp =threadinfo%mem_dp + alloc * ndata
threadinfo%mem_tot=threadinfo%mem_tot + alloc * ndata
case default
write(iunit,*) 'wrong datatype! array name is'//arrayname//' in routinename '//routinename
end select
if (alloc>0) then
signe='+'
else
signe='-'
end if
write(iunit,'(a5,a16,a3,a16,a4,i10,a3,3i11)') ' ',routinename,' | ',arrayname,' | '//signe,ndata/1024,' | ', &
threadinfo%mem_int/1024, &
threadinfo%mem_dp/1024 , &
threadinfo%mem_tot/1024
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_init (threadinfo,iunit,filename)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iunit
character*(*) filename
threadinfo%mem_heap_unit=iunit
open(unit=iunit,file=filename,status='replace')
threadinfo%mem_int=0
threadinfo%mem_dp=0
threadinfo%mem_tot=0
write(iunit,'(a90)') '|---------------------------------------------------------------------------------------------'
write(iunit,'(a90)') '| routine name | array name | +/- kbytes | int memory dp memory total '
write(iunit,'(a90)') '|---------------------------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_final (threadinfo)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iunit
iunit=threadinfo%mem_heap_unit
write(iunit,'(a90)') '|---------------------------------------------------------------------------------------------'
close(iunit)
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_hop1 (threadinfo,istep)
use definitions
use threads
implicit none
type (thread) threadinfo
integer istep
integer iunit
character(len=5) cistep
iunit=threadinfo%mem_heap_unit
call int_to_char(cistep,5,istep)
write(iunit,'(a90)') '1---istep='//cistep//'-------------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_hop2 (threadinfo,iter)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iter
integer iunit
character(len=5) citer
iunit=threadinfo%mem_heap_unit
call int_to_char(citer,5,iter)
write(iunit,'(a90)') '2-------iter='//citer//'---------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_hop3 (threadinfo,iter_nl)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iter_nl
integer iunit
character(len=5) citer
iunit=threadinfo%mem_heap_unit
call int_to_char(citer,5,iter_nl)
write(iunit,'(a90)') '3-----------iter_nl='//citer//'-------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_hop3_f (threadinfo)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iunit
iunit=threadinfo%mem_heap_unit
write(iunit,'(a90)') '3-----------end ofloop----------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_hop2_f (threadinfo)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iunit
iunit=threadinfo%mem_heap_unit
write(iunit,'(a90)') '2-------end ofloop----------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================
subroutine heap_hop1_f (threadinfo)
use definitions
use threads
implicit none
type (thread) threadinfo
integer iunit
iunit=threadinfo%mem_heap_unit
write(iunit,'(a90)') '1-------end ofloop----------------------------------------------------------------------------'
end subroutine
!===============================================================================
!===============================================================================