66 |
|
logical, save :: haveRcut = .false. |
67 |
|
logical, save :: haveMixingMap = .false. |
68 |
|
logical, save :: useGeometricDistanceMixing = .false. |
69 |
+ |
logical, save :: cleanArrays = .true. |
70 |
+ |
logical, save :: arraysAllocated = .false. |
71 |
|
|
72 |
|
|
71 |
– |
|
72 |
– |
|
73 |
|
character(len = statusMsgSize) :: errMesg |
74 |
|
integer :: sc_err |
75 |
|
|
76 |
|
character(len = 200) :: errMsg |
77 |
|
character(len=*), parameter :: RoutineName = "Sutton-Chen MODULE" |
78 |
|
!! Logical that determines if eam arrays should be zeroed |
79 |
– |
logical :: cleanme = .true. |
79 |
|
logical :: nmflag = .false. |
80 |
|
|
81 |
|
|
290 |
|
|
291 |
|
!! routine checks to see if array is allocated, deallocates array if allocated |
292 |
|
!! and then creates the array to the required size |
293 |
< |
subroutine allocateSC(status) |
294 |
< |
integer, intent(out) :: status |
293 |
> |
subroutine allocateSC() |
294 |
> |
integer :: status |
295 |
|
|
296 |
|
#ifdef IS_MPI |
297 |
|
integer :: nAtomsInRow |
299 |
|
#endif |
300 |
|
integer :: alloc_stat |
301 |
|
|
302 |
< |
|
302 |
> |
|
303 |
|
status = 0 |
304 |
|
#ifdef IS_MPI |
305 |
|
nAtomsInRow = getNatomsInRow(plan_atom_row) |
312 |
|
allocate(frho(nlocal),stat=alloc_stat) |
313 |
|
if (alloc_stat /= 0) then |
314 |
|
status = -1 |
316 |
– |
return |
315 |
|
end if |
316 |
|
|
317 |
|
if (allocated(rho)) deallocate(rho) |
318 |
|
allocate(rho(nlocal),stat=alloc_stat) |
319 |
|
if (alloc_stat /= 0) then |
320 |
|
status = -1 |
323 |
– |
return |
321 |
|
end if |
322 |
|
|
323 |
|
if (allocated(dfrhodrho)) deallocate(dfrhodrho) |
324 |
|
allocate(dfrhodrho(nlocal),stat=alloc_stat) |
325 |
|
if (alloc_stat /= 0) then |
326 |
|
status = -1 |
330 |
– |
return |
327 |
|
end if |
328 |
|
|
329 |
|
#ifdef IS_MPI |
332 |
|
allocate(rho_tmp(nlocal),stat=alloc_stat) |
333 |
|
if (alloc_stat /= 0) then |
334 |
|
status = -1 |
339 |
– |
return |
335 |
|
end if |
336 |
|
|
337 |
|
|
339 |
|
allocate(frho_row(nAtomsInRow),stat=alloc_stat) |
340 |
|
if (alloc_stat /= 0) then |
341 |
|
status = -1 |
347 |
– |
return |
342 |
|
end if |
343 |
|
if (allocated(rho_row)) deallocate(rho_row) |
344 |
|
allocate(rho_row(nAtomsInRow),stat=alloc_stat) |
345 |
|
if (alloc_stat /= 0) then |
346 |
|
status = -1 |
353 |
– |
return |
347 |
|
end if |
348 |
|
if (allocated(dfrhodrho_row)) deallocate(dfrhodrho_row) |
349 |
|
allocate(dfrhodrho_row(nAtomsInRow),stat=alloc_stat) |
350 |
|
if (alloc_stat /= 0) then |
351 |
|
status = -1 |
359 |
– |
return |
352 |
|
end if |
353 |
|
|
354 |
|
|
358 |
|
allocate(frho_col(nAtomsInCol),stat=alloc_stat) |
359 |
|
if (alloc_stat /= 0) then |
360 |
|
status = -1 |
369 |
– |
return |
361 |
|
end if |
362 |
|
if (allocated(rho_col)) deallocate(rho_col) |
363 |
|
allocate(rho_col(nAtomsInCol),stat=alloc_stat) |
364 |
|
if (alloc_stat /= 0) then |
365 |
|
status = -1 |
375 |
– |
return |
366 |
|
end if |
367 |
|
if (allocated(dfrhodrho_col)) deallocate(dfrhodrho_col) |
368 |
|
allocate(dfrhodrho_col(nAtomsInCol),stat=alloc_stat) |
369 |
|
if (alloc_stat /= 0) then |
370 |
|
status = -1 |
381 |
– |
return |
371 |
|
end if |
372 |
|
|
373 |
|
#endif |
374 |
< |
|
374 |
> |
if (status == -1) then |
375 |
> |
call handleError("SuttonChen:allocateSC","Error in allocating SC arrays") |
376 |
> |
end if |
377 |
> |
arraysAllocated = .true. |
378 |
|
end subroutine allocateSC |
379 |
|
|
380 |
|
!! C sets rcut to be the largest cutoff of any atype |
389 |
|
|
390 |
|
end subroutine setCutoffSC |
391 |
|
|
392 |
+ |
!! This array allocates module arrays if needed and builds mixing map. |
393 |
|
subroutine clean_SC() |
394 |
< |
|
394 |
> |
if (.not.arraysAllocated) call allocateSC() |
395 |
> |
if (.not.haveMixingMap) call createMixingMap() |
396 |
|
! clean non-IS_MPI first |
397 |
|
frho = 0.0_dp |
398 |
|
rho = 0.0_dp |
433 |
|
|
434 |
|
! check to see if we need to be cleaned at the start of a force loop |
435 |
|
|
436 |
< |
if (.not.haveMixingMap) call createMixingMap() |
436 |
> |
if (cleanArrays) call clean_SC() |
437 |
> |
cleanArrays = .false. |
438 |
|
|
444 |
– |
|
439 |
|
#ifdef IS_MPI |
440 |
|
Atid1 = Atid_row(Atom1) |
441 |
|
Atid2 = Atid_col(Atom2) |
476 |
|
integer :: myid |
477 |
|
|
478 |
|
|
485 |
– |
cleanme = .true. |
479 |
|
!! Scatter the electron density from pre-pair calculation back to local atoms |
480 |
|
#ifdef IS_MPI |
481 |
|
call scatter(rho_row,rho,plan_atom_row,sc_err) |
559 |
|
!Local Variables |
560 |
|
|
561 |
|
! write(*,*) "Frho: ", Frho(atom1) |
562 |
+ |
|
563 |
+ |
cleanArrays = .true. |
564 |
|
|
570 |
– |
|
565 |
|
dvpdr = 0.0E0_DP |
566 |
|
|
567 |
|
|