Millepede-II V04-17-03
mpdalc.f90
Go to the documentation of this file.
1
22
24MODULE mpdalc
25 USE mpdef
26 IMPLICIT NONE
27 SAVE
28 ! variables
29 INTEGER(mpl) :: numwordsalloc = 0
30 INTEGER(mpl) :: maxwordsalloc = 0
31 INTEGER(mpi) :: nummpalloc = 0
32 INTEGER(mpi) :: nummpdealloc = 0
33 INTEGER(mpi) :: printflagalloc = 0
34
36 INTERFACE mpalloc
37 MODULE PROCEDURE mpallocdvec, mpallocfvec, mpallocivec, mpalloclvec, &
40 END INTERFACE mpalloc
42 INTERFACE mpdealloc
46 END INTERFACE mpdealloc
47
48CONTAINS
49 ! allocate dynamic vector or array
51 SUBROUTINE mpallocdvec(array,length,text)
52 REAL(mpd), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
53 INTEGER(mpl), INTENT(IN) :: length
54 CHARACTER (LEN=*), INTENT(IN) :: text
55
56 INTEGER(mpi) :: ifail
57 ALLOCATE (array(length),stat=ifail)
58 CALL mpalloccheck(ifail,(mpd*length)/mpi,text)
59 END SUBROUTINE mpallocdvec
60
62 SUBROUTINE mpallocfvec(array,length,text)
63 REAL(mps), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
64 INTEGER(mpl), INTENT(IN) :: length
65 CHARACTER (LEN=*), INTENT(IN) :: text
66
67 INTEGER(mpi) :: ifail
68 ALLOCATE (array(length),stat=ifail)
69 CALL mpalloccheck(ifail,(mps*length)/mpi,text)
70 END SUBROUTINE mpallocfvec
71
73 SUBROUTINE mpallocivec(array,length,text)
74 INTEGER(mpi), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
75 INTEGER(mpl), INTENT(IN) :: length
76 CHARACTER (LEN=*), INTENT(IN) :: text
77
78 INTEGER(mpi) :: ifail
79 ALLOCATE (array(length),stat=ifail)
80 CALL mpalloccheck(ifail,length,text)
81 END SUBROUTINE mpallocivec
82
84 SUBROUTINE mpalloclvec(array,length,text)
85 INTEGER(mpl), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
86 INTEGER(mpl), INTENT(IN) :: length
87 CHARACTER (LEN=*), INTENT(IN) :: text
88
89 INTEGER(mpi) :: ifail
90 ALLOCATE (array(length),stat=ifail)
91 CALL mpalloccheck(ifail,length,text)
92 END SUBROUTINE mpalloclvec
93
95 SUBROUTINE mpallocfarr(array,rows,cols,text)
96 REAL(mps), DIMENSION(:,:), INTENT(IN OUT), ALLOCATABLE :: array
97 INTEGER(mpl), INTENT(IN) :: rows
98 INTEGER(mpl), INTENT(IN) :: cols
99 CHARACTER (LEN=*), INTENT(IN) :: text
100
101 INTEGER(mpi) :: ifail
102 ALLOCATE (array(rows,cols),stat=ifail)
103 CALL mpalloccheck(ifail,(mps*rows*cols)/mpi,text)
104 END SUBROUTINE mpallocfarr
105
107 SUBROUTINE mpallociarr(array,rows,cols,text)
108 INTEGER(mpi), DIMENSION(:,:), INTENT(IN OUT), ALLOCATABLE :: array
109 INTEGER(mpl), INTENT(IN) :: rows
110 INTEGER(mpl), INTENT(IN) :: cols
111 CHARACTER (LEN=*), INTENT(IN) :: text
112
113 INTEGER(mpi) :: ifail
114 ALLOCATE (array(rows,cols),stat=ifail)
115 CALL mpalloccheck(ifail,rows*cols,text)
116 END SUBROUTINE mpallociarr
117
119 SUBROUTINE mpalloclarr(array,rows,cols,text)
120 INTEGER(mpl), DIMENSION(:,:), INTENT(IN OUT), ALLOCATABLE :: array
121 INTEGER(mpl), INTENT(IN) :: rows
122 INTEGER(mpl), INTENT(IN) :: cols
123 CHARACTER (LEN=*), INTENT(IN) :: text
124
125 INTEGER(mpi) :: ifail
126 ALLOCATE (array(rows,cols),stat=ifail)
127 CALL mpalloccheck(ifail,(mpl*rows*cols)/mpi,text)
128 END SUBROUTINE mpalloclarr
129
131 SUBROUTINE mpalloclist(array,length,text)
132 TYPE(listitem), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
133 INTEGER(mpl), INTENT(IN) :: length
134 CHARACTER (LEN=*), INTENT(IN) :: text
135
136 INTEGER(mpi) :: ifail
137 ALLOCATE (array(length),stat=ifail)
138 CALL mpalloccheck(ifail,((mps+mpi)*length)/mpi,text)
139 END SUBROUTINE mpalloclist
140
142 SUBROUTINE mpalloclistc(array,length,text)
143 TYPE(listitemc), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
144 INTEGER(mpl), INTENT(IN) :: length
145 CHARACTER (LEN=*), INTENT(IN) :: text
146
147 INTEGER(mpi) :: ifail
148 ALLOCATE (array(length),stat=ifail)
149 CALL mpalloccheck(ifail,((mpi+itemclen)*length)/mpi,text)
150 END SUBROUTINE mpalloclistc
151
153 SUBROUTINE mpalloclisti(array,length,text)
154 TYPE(listitemi), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
155 INTEGER(mpl), INTENT(IN) :: length
156 CHARACTER (LEN=*), INTENT(IN) :: text
157
158 INTEGER(mpi) :: ifail
159 ALLOCATE (array(length),stat=ifail)
160 CALL mpalloccheck(ifail,((mpi+mpi)*length)/mpi,text)
161 END SUBROUTINE mpalloclisti
162
164 SUBROUTINE mpalloccvec(array,length,text)
165 CHARACTER, DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
166 INTEGER(mpl), INTENT(IN) :: length
167 CHARACTER (LEN=*), INTENT(IN) :: text
168
169 INTEGER(mpi) :: ifail
170 ALLOCATE (array(length),stat=ifail)
171 CALL mpalloccheck(ifail,(length+mpi-1)/mpi,text)
172 END SUBROUTINE mpalloccvec
173
175 SUBROUTINE mpalloccheck(ifail,numwords,text)
176 INTEGER(mpi), INTENT(IN) :: ifail
177 INTEGER(mpl), INTENT(IN) :: numwords
178 CHARACTER (LEN=*), INTENT(IN) :: text
179 IF (ifail == 0) THEN
181 numwordsalloc = numwordsalloc + numwords
183 IF (printflagalloc /= 0) THEN
184 print *, ' MPALLOC allocated ', numwords, ' words for : ', text
185 print *, ' words used ', numwordsalloc, maxwordsalloc
186 ENDIF
187 ELSE
188 print *, ' MPALLOC failed to allocate ', numwords, ' words for : ', text
189 print *, ' MPALLOC words used ', numwordsalloc, maxwordsalloc
190 print *, ' MPALLOC stat = ', ifail
191 CALL peend(30,'Aborted, memory allocation failed')
192 stop
193 ENDIF
194 END SUBROUTINE mpalloccheck
195 ! deallocate dynamic vector or array
197 SUBROUTINE mpdeallocdvec(array)
198 REAL(mpd), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
199
200 INTEGER(mpi) :: ifail
201 INTEGER(mpl) :: isize
202 isize = (mpd*size(array,kind=mpl))/mpi
203 DEALLOCATE (array,stat=ifail)
204 CALL mpdealloccheck(ifail,isize)
205 END SUBROUTINE mpdeallocdvec
206
208 SUBROUTINE mpdeallocfvec(array)
209 REAL(mps), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
210
211 INTEGER(mpi) :: ifail
212 INTEGER(mpl) :: isize
213 isize = (mps*size(array,kind=mpl))/mpi
214 DEALLOCATE (array,stat=ifail)
215 CALL mpdealloccheck(ifail,isize)
216 END SUBROUTINE mpdeallocfvec
217
219 SUBROUTINE mpdeallocivec(array)
220 INTEGER(mpi), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
221
222 INTEGER(mpi) :: ifail
223 INTEGER(mpl) :: isize
224 isize = size(array,kind=mpl)
225 DEALLOCATE (array,stat=ifail)
226 CALL mpdealloccheck(ifail,isize)
227 END SUBROUTINE mpdeallocivec
228
230 SUBROUTINE mpdealloclvec(array)
231 INTEGER(mpl), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
232
233 INTEGER(mpi) :: ifail
234 INTEGER(mpl) :: isize
235 isize = size(array,kind=mpl)
236 DEALLOCATE (array,stat=ifail)
237 CALL mpdealloccheck(ifail,isize)
238 END SUBROUTINE mpdealloclvec
239
241 SUBROUTINE mpdeallocfarr(array)
242 REAL(mps), DIMENSION(:,:), INTENT(IN OUT), ALLOCATABLE :: array
243
244 INTEGER(mpi) :: ifail
245 INTEGER(mpl) :: isize
246 isize = (mps*size(array,kind=mpl))/mpi
247 DEALLOCATE (array,stat=ifail)
248 CALL mpdealloccheck(ifail,isize)
249 END SUBROUTINE mpdeallocfarr
250
252 SUBROUTINE mpdeallociarr(array)
253 INTEGER(mpi), DIMENSION(:,:), INTENT(IN OUT), ALLOCATABLE :: array
254
255 INTEGER(mpi) :: ifail
256 INTEGER(mpl) :: isize
257 isize = size(array,kind=mpl)
258 DEALLOCATE (array,stat=ifail)
259 CALL mpdealloccheck(ifail,isize)
260 END SUBROUTINE mpdeallociarr
261
263 SUBROUTINE mpdealloclarr(array)
264 INTEGER(mpl), DIMENSION(:,:), INTENT(IN OUT), ALLOCATABLE :: array
265
266 INTEGER(mpi) :: ifail
267 INTEGER(mpl) :: isize
268 isize = (mpl*size(array,kind=mpl))/mpi
269 DEALLOCATE (array,stat=ifail)
270 CALL mpdealloccheck(ifail,isize)
271 END SUBROUTINE mpdealloclarr
272
274 SUBROUTINE mpdealloclist(array)
275 TYPE(listitem), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
276
277 INTEGER(mpi) :: ifail
278 INTEGER(mpl) :: isize
279 isize = ((mpi+mps)*size(array,kind=mpl))/mpi
280 DEALLOCATE (array,stat=ifail)
281 CALL mpdealloccheck(ifail,isize)
282 END SUBROUTINE mpdealloclist
283
285 SUBROUTINE mpdealloclistc(array)
286 TYPE(listitemc), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
287
288 INTEGER(mpi) :: ifail
289 INTEGER(mpl) :: isize
290 isize = ((mpi+itemclen)*size(array,kind=mpl))/mpi
291 DEALLOCATE (array,stat=ifail)
292 CALL mpdealloccheck(ifail,isize)
293 END SUBROUTINE mpdealloclistc
294
296 SUBROUTINE mpdealloclisti(array)
297 TYPE(listitemi), DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
298
299 INTEGER(mpi) :: ifail
300 INTEGER(mpl) :: isize
301 isize = ((mpi+mpi)*size(array,kind=mpl))/mpi
302 DEALLOCATE (array,stat=ifail)
303 CALL mpdealloccheck(ifail,isize)
304 END SUBROUTINE mpdealloclisti
305
307 SUBROUTINE mpdealloccvec(array)
308 CHARACTER, DIMENSION(:), INTENT(IN OUT), ALLOCATABLE :: array
309
310 INTEGER(mpi) :: ifail
311 INTEGER(mpl) :: isize
312 isize = (size(array,kind=mpl)+mpi-1)/mpi
313 DEALLOCATE (array,stat=ifail)
314 CALL mpdealloccheck(ifail,isize)
315 END SUBROUTINE mpdealloccvec
316
318 SUBROUTINE mpdealloccheck(ifail,numwords)
319 INTEGER(mpi), INTENT(IN) :: ifail
320 INTEGER(mpl), INTENT(IN) :: numwords
321 IF (ifail == 0) THEN
322 numwordsalloc = numwordsalloc - numwords
324 IF (printflagalloc /= 0) THEN
325 print *, ' MPDEALLOC deallocated ', numwords, ' words '
326 print *, ' words used ', numwordsalloc, maxwordsalloc
327 ENDIF
328 ELSE
329 print *, ' MPDEALLOC failed to deallocate ', numwords, ' words'
330 print *, ' MPDEALLOC words used ', numwordsalloc, maxwordsalloc
331 print *, ' MPDEALLOC stat = ', ifail
332 CALL peend(31,'Aborted, memory deallocation failed')
333 stop
334 ENDIF
335 END SUBROUTINE mpdealloccheck
336
337END MODULE mpdalc
allocate array
Definition: mpdalc.f90:36
deallocate array
Definition: mpdalc.f90:42
(De)Allocate vectors and arrays.
Definition: mpdalc.f90:24
subroutine mpdeallocfvec(array)
deallocate (1D) single precision array
Definition: mpdalc.f90:209
subroutine mpalloclist(array, length, text)
allocate (1D) list item array
Definition: mpdalc.f90:132
subroutine mpallocivec(array, length, text)
allocate (1D) integer array
Definition: mpdalc.f90:74
subroutine mpalloclarr(array, rows, cols, text)
allocate (2D) large integer array
Definition: mpdalc.f90:120
subroutine mpdealloccvec(array)
deallocate (1D) character array
Definition: mpdalc.f90:308
subroutine mpallocfvec(array, length, text)
allocate (1D) single precision array
Definition: mpdalc.f90:63
subroutine mpalloclisti(array, length, text)
allocate (1D) character list item array
Definition: mpdalc.f90:154
subroutine mpalloccvec(array, length, text)
allocate (1D) character array
Definition: mpdalc.f90:165
integer(mpl) maxwordsalloc
peak dynamic memory allocation (words)
Definition: mpdalc.f90:30
integer(mpi) nummpdealloc
number of dynamic deallocations
Definition: mpdalc.f90:32
integer(mpi) printflagalloc
print flag for dynamic allocations
Definition: mpdalc.f90:33
subroutine mpdealloclisti(array)
deallocate (1D) integer list item array
Definition: mpdalc.f90:297
subroutine mpalloclistc(array, length, text)
allocate (1D) character list item array
Definition: mpdalc.f90:143
subroutine mpdealloclistc(array)
deallocate (1D) character list item array
Definition: mpdalc.f90:286
subroutine mpdeallocdvec(array)
deallocate (1D) double precision array
Definition: mpdalc.f90:198
subroutine mpdealloccheck(ifail, numwords)
check deallocation
Definition: mpdalc.f90:319
subroutine mpdealloclarr(array)
deallocate (2D) large integer array
Definition: mpdalc.f90:264
subroutine mpalloccheck(ifail, numwords, text)
check allocation
Definition: mpdalc.f90:176
subroutine mpallocfarr(array, rows, cols, text)
allocate (2D) single precision array
Definition: mpdalc.f90:96
integer(mpl) numwordsalloc
current dynamic memory allocation (words)
Definition: mpdalc.f90:29
subroutine mpdeallocivec(array)
deallocate (1D) integer array
Definition: mpdalc.f90:220
integer(mpi) nummpalloc
number of dynamic allocations
Definition: mpdalc.f90:31
subroutine mpdealloclvec(array)
deallocate (1D) large integer array
Definition: mpdalc.f90:231
subroutine mpallociarr(array, rows, cols, text)
allocate (2D) INTEGER(mpi) array
Definition: mpdalc.f90:108
subroutine mpdealloclist(array)
deallocate (1D) list item array
Definition: mpdalc.f90:275
subroutine mpalloclvec(array, length, text)
allocate (1D) large integer array
Definition: mpdalc.f90:85
subroutine mpallocdvec(array, length, text)
allocate (1D) double precision array
Definition: mpdalc.f90:52
subroutine mpdeallociarr(array)
deallocate (2D) integer array
Definition: mpdalc.f90:253
subroutine mpdeallocfarr(array)
deallocate (2D) single precision array
Definition: mpdalc.f90:242
Definition of constants.
Definition: mpdef.f90:24
integer, parameter mpl
long integer
Definition: mpdef.f90:36
integer, parameter itemclen
comment length (60 characters)
Definition: mpdef.f90:45
integer, parameter mps
single precision
Definition: mpdef.f90:37
integer, parameter mpi
integer
Definition: mpdef.f90:35
subroutine peend(icode, cmessage)
Print exit code.
Definition: pede.f90:13230
list items from steering file
Definition: mpdef.f90:40
character list items from steering file
Definition: mpdef.f90:47
integer list items from steering file
Definition: mpdef.f90:52