10 |
|
|
11 |
|
logical, save :: atype_vector_initialized = .false. |
12 |
|
logical, save :: ff_initialized = .false. |
13 |
– |
|
13 |
|
|
15 |
– |
#ifdef IS_MPI |
16 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: q_Row |
17 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: q_Col |
18 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: u_l_Row |
19 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: u_l_Col |
20 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: A_Row |
21 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: A_Col |
22 |
– |
|
23 |
– |
real( kind = dp ), allocatable, dimension(:) :: pot_Row |
24 |
– |
real( kind = dp ), allocatable, dimension(:) :: pot_Col |
25 |
– |
real( kind = dp ), allocatable, dimension(:) :: pot_Temp |
26 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: f_Row |
27 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: f_Col |
28 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: f_Temp |
29 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: t_Row |
30 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: t_Col |
31 |
– |
real( kind = dp ), allocatable, dimension(:,:) :: t_Temp |
32 |
– |
integer, allocatable, dimension(:) :: atid_Row |
33 |
– |
integer, allocatable, dimension(:) :: atid_Col |
34 |
– |
#else |
35 |
– |
integer, allocatable, dimension(:) :: atid |
36 |
– |
#endif |
37 |
– |
|
14 |
|
real(kind = dp) :: pot = 0.0_dp |
15 |
|
real(kind = dp), dimension(9) :: tau_Temp = 0.0_dp |
16 |
|
real(kind = dp) :: virial_Temp = 0.0_dp |
93 |
|
end subroutine new_atype |
94 |
|
|
95 |
|
|
96 |
< |
subroutine init_FF(nComponents, c_idents, nExcludes, excludesLocal, status) |
97 |
< |
!! Number of components in c_idents array |
122 |
< |
integer, intent(inout) :: nComponents |
123 |
< |
!! Array of identities nComponents long corresponding to |
124 |
< |
!! ljatype ident. |
125 |
< |
integer, dimension(nComponents),intent(inout) :: c_idents |
126 |
< |
integer :: nExcludes |
127 |
< |
integer, dimension(nExcludes),intent(inout) :: excludesLocal |
96 |
> |
subroutine init_FF(status) |
97 |
> |
|
98 |
|
!! Result status, success = 0, error = -1 |
99 |
< |
integer, intent(out) :: status |
100 |
< |
integer :: i, me, thisStat |
131 |
< |
integer :: myNode, alloc_stat |
99 |
> |
integer, intent(out) :: status |
100 |
> |
integer :: thisStat = 0 |
101 |
|
|
133 |
– |
#ifdef IS_MPI |
134 |
– |
integer, allocatable, dimension(:) :: c_idents_Row |
135 |
– |
integer, allocatable, dimension(:) :: c_idents_Col |
136 |
– |
integer :: nrow |
137 |
– |
integer :: ncol |
138 |
– |
#endif |
139 |
– |
|
140 |
– |
status = 0 |
102 |
|
|
142 |
– |
|
143 |
– |
#ifdef IS_MPI |
144 |
– |
! We can only set up forces if mpiSimulation has been setup. |
145 |
– |
if (.not. isMPISimSet()) then |
146 |
– |
write(default_error,*) "MPI is not set" |
147 |
– |
status = -1 |
148 |
– |
return |
149 |
– |
endif |
150 |
– |
nrow = getNrow(plan_row) |
151 |
– |
ncol = getNcol(plan_col) |
152 |
– |
mynode = getMyNode() |
153 |
– |
|
154 |
– |
allocate(c_idents_Row(nrow),stat=alloc_stat) |
155 |
– |
if (alloc_stat /= 0 ) then |
156 |
– |
status = -1 |
157 |
– |
return |
158 |
– |
endif |
159 |
– |
|
160 |
– |
allocate(c_idents_Col(ncol),stat=alloc_stat) |
161 |
– |
if (alloc_stat /= 0 ) then |
162 |
– |
status = -1 |
163 |
– |
return |
164 |
– |
endif |
165 |
– |
|
166 |
– |
call gather(c_idents, c_idents_Row, plan_row) |
167 |
– |
call gather(c_idents, c_idents_Col, plan_col) |
168 |
– |
|
169 |
– |
allocate(atid_Row(nrow),stat=alloc_stat) |
170 |
– |
if (alloc_stat /= 0 ) then |
171 |
– |
status = -1 |
172 |
– |
return |
173 |
– |
endif |
174 |
– |
|
175 |
– |
allocate(atid_Col(ncol),stat=alloc_stat) |
176 |
– |
if (alloc_stat /= 0 ) then |
177 |
– |
status = -1 |
178 |
– |
return |
179 |
– |
endif |
180 |
– |
|
181 |
– |
do i = 1, nrow |
182 |
– |
me = getFirstMatchingElement(atypes, "c_ident", c_idents_Row(i)) |
183 |
– |
atid_Row(i) = me |
184 |
– |
enddo |
185 |
– |
|
186 |
– |
do i = 1, ncol |
187 |
– |
me = getFirstMatchingElement(atypes, "c_ident", c_idents_Col(i)) |
188 |
– |
atid_Col(i) = me |
189 |
– |
enddo |
190 |
– |
|
191 |
– |
!! free temporary ident arrays |
192 |
– |
if (allocated(c_idents_Col)) then |
193 |
– |
deallocate(c_idents_Col) |
194 |
– |
end if |
195 |
– |
if (allocated(c_idents_Row)) then |
196 |
– |
deallocate(c_idents_Row) |
197 |
– |
endif |
198 |
– |
|
199 |
– |
#else |
200 |
– |
do i = 1, nComponents |
201 |
– |
|
202 |
– |
me = getFirstMatchingElement(atypes, "c_ident", c_idents(i)) |
203 |
– |
atid(i) = me |
204 |
– |
|
205 |
– |
enddo |
206 |
– |
#endif |
207 |
– |
|
103 |
|
call initForce_Modules(thisStat) |
104 |
|
if (thisStat /= 0) then |
105 |
|
status = -1 |
106 |
|
return |
107 |
|
endif |
108 |
|
|
214 |
– |
!! Create neighbor lists |
215 |
– |
call expandList(thisStat) |
216 |
– |
if (thisStat /= 0) then |
217 |
– |
status = -1 |
218 |
– |
return |
219 |
– |
endif |
109 |
|
|
221 |
– |
call setupGlobals(thisStat) |
222 |
– |
if (thisStat /= 0) then |
223 |
– |
status = -1 |
224 |
– |
return |
225 |
– |
endif |
226 |
– |
|
110 |
|
ff_initialized = .true. |
111 |
|
|
112 |
|
|
113 |
|
end subroutine init_FF |
114 |
|
|
232 |
– |
subroutine setupGlobals(thisStat) |
233 |
– |
integer, intent(out) :: thisStat |
234 |
– |
integer :: nrow |
235 |
– |
integer :: ncol |
236 |
– |
integer :: nlocal |
237 |
– |
integer :: ndim = 3 |
238 |
– |
integer :: alloc_stat |
115 |
|
|
240 |
– |
thisStat = 0 |
116 |
|
|
242 |
– |
#ifdef IS_MPI |
243 |
– |
nrow = getNrow(plan_row) |
244 |
– |
ncol = getNcol(plan_col) |
245 |
– |
#endif |
246 |
– |
nlocal = getNlocal() |
117 |
|
|
248 |
– |
call freeGlobals() |
118 |
|
|
250 |
– |
#ifdef IS_MPI |
251 |
– |
|
252 |
– |
allocate(q_Row(ndim,nrow),stat=alloc_stat) |
253 |
– |
if (alloc_stat /= 0 ) then |
254 |
– |
thisStat = 0 |
255 |
– |
return |
256 |
– |
endif |
257 |
– |
|
258 |
– |
|
259 |
– |
allocate(q_Col(ndim,ncol),stat=alloc_stat) |
260 |
– |
if (alloc_stat /= 0 ) then |
261 |
– |
thisStat = 0 |
262 |
– |
return |
263 |
– |
endif |
264 |
– |
|
265 |
– |
|
266 |
– |
allocate(u_l_Row(ndim,nrow),stat=alloc_stat) |
267 |
– |
if (alloc_stat /= 0 ) then |
268 |
– |
thisStat = 0 |
269 |
– |
return |
270 |
– |
endif |
271 |
– |
|
272 |
– |
allocate(u_l_Col(ndim,ncol),stat=alloc_stat) |
273 |
– |
if (alloc_stat /= 0 ) then |
274 |
– |
thisStat = 0 |
275 |
– |
return |
276 |
– |
endif |
277 |
– |
|
278 |
– |
|
279 |
– |
allocate(A_row(9,nrow),stat=alloc_stat) |
280 |
– |
if (alloc_stat /= 0 ) then |
281 |
– |
thisStat = 0 |
282 |
– |
return |
283 |
– |
endif |
284 |
– |
|
285 |
– |
|
286 |
– |
allocate(A_Col(9,ncol),stat=alloc_stat) |
287 |
– |
if (alloc_stat /= 0 ) then |
288 |
– |
thisStat = 0 |
289 |
– |
return |
290 |
– |
endif |
291 |
– |
|
292 |
– |
|
293 |
– |
allocate(pot_row(nrow),stat=alloc_stat) |
294 |
– |
if (alloc_stat /= 0 ) then |
295 |
– |
thisStat = 0 |
296 |
– |
return |
297 |
– |
endif |
298 |
– |
|
299 |
– |
allocate(pot_Col(ncol),stat=alloc_stat) |
300 |
– |
if (alloc_stat /= 0 ) then |
301 |
– |
thisStat = 0 |
302 |
– |
return |
303 |
– |
endif |
304 |
– |
|
305 |
– |
allocate(pot_Temp(nlocal),stat=alloc_stat) |
306 |
– |
if (alloc_stat /= 0 ) then |
307 |
– |
thisStat = 0 |
308 |
– |
return |
309 |
– |
endif |
310 |
– |
|
311 |
– |
allocate(f_Row(ndim,nrow),stat=alloc_stat) |
312 |
– |
if (alloc_stat /= 0 ) then |
313 |
– |
thisStat = 0 |
314 |
– |
return |
315 |
– |
endif |
316 |
– |
|
317 |
– |
allocate(f_Col(ndim,ncol),stat=alloc_stat) |
318 |
– |
if (alloc_stat /= 0 ) then |
319 |
– |
thisStat = 0 |
320 |
– |
return |
321 |
– |
endif |
322 |
– |
|
323 |
– |
allocate(f_Temp(ndim,nlocal),stat=alloc_stat) |
324 |
– |
if (alloc_stat /= 0 ) then |
325 |
– |
thisStat = 0 |
326 |
– |
return |
327 |
– |
endif |
328 |
– |
|
329 |
– |
allocate(t_Row(ndim,nrow),stat=alloc_stat) |
330 |
– |
if (alloc_stat /= 0 ) then |
331 |
– |
thisStat = 0 |
332 |
– |
return |
333 |
– |
endif |
334 |
– |
|
335 |
– |
allocate(t_Col(ndim,ncol),stat=alloc_stat) |
336 |
– |
if (alloc_stat /= 0 ) then |
337 |
– |
thisStat = 0 |
338 |
– |
return |
339 |
– |
endif |
340 |
– |
|
341 |
– |
allocate(t_temp(ndim,nlocal),stat=alloc_stat) |
342 |
– |
if (alloc_stat /= 0 ) then |
343 |
– |
thisStat = 0 |
344 |
– |
return |
345 |
– |
endif |
346 |
– |
|
347 |
– |
allocate(atid_Row(nrow),stat=alloc_stat) |
348 |
– |
if (alloc_stat /= 0 ) then |
349 |
– |
thisStat = 0 |
350 |
– |
return |
351 |
– |
endif |
352 |
– |
|
353 |
– |
allocate(atid_Col(ncol),stat=alloc_stat) |
354 |
– |
if (alloc_stat /= 0 ) then |
355 |
– |
thisStat = 0 |
356 |
– |
return |
357 |
– |
endif |
358 |
– |
|
359 |
– |
#else |
360 |
– |
|
361 |
– |
allocate(atid(nlocal),stat=alloc_stat) |
362 |
– |
if (alloc_stat /= 0 ) then |
363 |
– |
thisStat = 0 |
364 |
– |
return |
365 |
– |
end if |
366 |
– |
|
367 |
– |
#endif |
368 |
– |
|
369 |
– |
end subroutine setupGlobals |
119 |
|
|
371 |
– |
subroutine freeGlobals() |
372 |
– |
|
373 |
– |
!We free in the opposite order in which we allocate in. |
374 |
– |
#ifdef IS_MPI |
375 |
– |
|
376 |
– |
if (allocated(atid_Col)) deallocate(atid_Col) |
377 |
– |
if (allocated(atid_Row)) deallocate(atid_Row) |
378 |
– |
if (allocated(t_Temp)) deallocate(t_Temp) |
379 |
– |
if (allocated(t_Col)) deallocate(t_Col) |
380 |
– |
if (allocated(t_Row)) deallocate(t_Row) |
381 |
– |
if (allocated(f_Temp)) deallocate(f_Temp) |
382 |
– |
if (allocated(f_Col)) deallocate(f_Col) |
383 |
– |
if (allocated(f_Row)) deallocate(f_Row) |
384 |
– |
if (allocated(pot_Temp)) deallocate(pot_Temp) |
385 |
– |
if (allocated(pot_Col)) deallocate(pot_Col) |
386 |
– |
if (allocated(pot_Row)) deallocate(pot_Row) |
387 |
– |
if (allocated(A_Col)) deallocate(A_Col) |
388 |
– |
if (allocated(A_Row)) deallocate(A_Row) |
389 |
– |
if (allocated(u_l_Col)) deallocate(u_l_Col) |
390 |
– |
if (allocated(u_l_Row)) deallocate(u_l_Row) |
391 |
– |
if (allocated(q_Col)) deallocate(q_Col) |
392 |
– |
if (allocated(q_Row)) deallocate(q_Row) |
393 |
– |
|
394 |
– |
#else |
395 |
– |
|
396 |
– |
if (allocated(atid)) deallocate(atid) |
397 |
– |
|
398 |
– |
#endif |
399 |
– |
|
400 |
– |
|
401 |
– |
end subroutine freeGlobals |
402 |
– |
|
403 |
– |
|
404 |
– |
|
405 |
– |
|
406 |
– |
|
120 |
|
subroutine initForce_Modules(thisStat) |
121 |
|
integer, intent(out) :: thisStat |
122 |
|
integer :: my_status |