48 |
|
!! @author Charles F. Vardeman II |
49 |
|
!! @author Matthew Meineke |
50 |
|
!! @author J. Daniel Gezelter |
51 |
< |
!! @version $Id: neighborLists.F90,v 1.2 2005-01-12 22:40:45 gezelter Exp $, |
51 |
> |
!! @version $Id: neighborLists.F90,v 1.3 2005-04-15 22:03:48 gezelter Exp $, |
52 |
|
|
53 |
|
module neighborLists |
54 |
< |
|
54 |
> |
|
55 |
|
use definitions |
56 |
|
#ifdef IS_MPI |
57 |
|
use mpiSimulation |
58 |
|
#endif |
59 |
< |
|
59 |
> |
|
60 |
|
implicit none |
61 |
|
PRIVATE |
62 |
< |
|
62 |
> |
|
63 |
|
!--------------MODULE VARIABLES----------------------> |
64 |
|
!! Parameter for size > # of long range particles neighbor list |
65 |
|
!! should be. |
82 |
|
public :: checkNeighborList |
83 |
|
public :: saveNeighborList |
84 |
|
public :: getNeighborListSize |
85 |
< |
|
85 |
> |
|
86 |
|
contains |
87 |
|
|
88 |
|
|
107 |
|
if (alloc_error /= 0) then |
108 |
|
write(default_error,*) & |
109 |
|
"ExpandNeighborLists: Error in allocating MPI point" |
110 |
< |
error = -1 |
110 |
> |
error = -1 |
111 |
|
return |
112 |
|
end if |
113 |
|
allocate(list(listMultiplier * getNgroupsInCol(plan_group_col)),stat=alloc_error) |
143 |
|
return |
144 |
|
end if |
145 |
|
#endif !! //MPI |
146 |
< |
|
146 |
> |
|
147 |
|
! Expand the neighbor list |
148 |
< |
|
148 |
> |
|
149 |
|
! Check to see if we have exceeded the maximum number of allocations. |
150 |
|
if (nAllocations > maxAllocations) then |
151 |
|
write(default_error,*) & |
162 |
|
newSize = listMultiplier * nGroups + oldSize |
163 |
|
#endif !! MPI |
164 |
|
|
165 |
– |
|
165 |
|
|
166 |
+ |
|
167 |
|
allocate(newList(newSize), stat=alloc_error) |
168 |
|
if (alloc_error /= 0) then |
169 |
|
write(*,*) "Error allocating new neighborlist" |
181 |
|
error = -1 |
182 |
|
return |
183 |
|
end if |
184 |
< |
|
184 |
> |
|
185 |
|
!! Point list at new list |
186 |
< |
|
186 |
> |
|
187 |
|
list => newList |
188 |
|
end if |
189 |
|
|
190 |
|
nAllocations = nAllocations + 1 |
191 |
|
listSize = size(list) |
192 |
|
end subroutine expandNeighborList |
193 |
< |
|
193 |
> |
|
194 |
|
!! checks to see if any long range particle has moved |
195 |
|
!! through the neighbor list skin thickness. |
196 |
|
subroutine checkNeighborList(nGroups, q, listSkin, update_nlist) |
204 |
|
|
205 |
|
dispmx = 0.0E0_DP |
206 |
|
!! calculate the largest displacement of any atom in any direction |
207 |
< |
|
207 |
> |
|
208 |
|
!! If we have changed the particle idents, then we need to update |
209 |
|
if (.not. allocated(q0)) then |
210 |
|
update_nlist = .true. |
218 |
|
|
219 |
|
|
220 |
|
#ifdef MPI |
221 |
< |
|
221 |
> |
|
222 |
|
dispmx_tmp = 0.0E0_DP |
223 |
|
do i = 1, nGroups |
224 |
|
dispmx_tmp = max( abs ( q(1,i) - q0(1,i) ), dispmx_tmp ) |
229 |
|
mpi_max,mpi_comm_world,mpi_err) |
230 |
|
|
231 |
|
#else |
232 |
< |
|
232 |
> |
|
233 |
|
dispmx = 0.0_DP |
234 |
|
do i = 1, nGroups |
235 |
|
dispmx = max( abs ( q(1,i) - q0(1,i) ), dispmx ) |
243 |
|
dispmx = 2.0E0_DP * sqrt (3.0E0_DP * dispmx * dispmx) |
244 |
|
|
245 |
|
update_nlist = (dispmx.gt.listSkin) |
246 |
< |
|
247 |
< |
end subroutine checkNeighborList |
248 |
< |
|
249 |
< |
|
246 |
> |
|
247 |
> |
end subroutine checkNeighborList |
248 |
> |
|
249 |
> |
|
250 |
|
!! Saves neighbor list for comparison in check. |
251 |
|
!! Save_neighborList will work even if the number of |
252 |
|
!! local atoms has changed. |
255 |
|
integer :: nGroups |
256 |
|
real(kind = dp ), dimension(3,nGroups), intent(in) :: q |
257 |
|
integer :: list_size |
258 |
< |
|
258 |
> |
|
259 |
|
!! get size of list |
260 |
|
list_size = nGroups |
261 |
< |
|
261 |
> |
|
262 |
|
if (.not. allocated(q0)) then |
263 |
|
allocate(q0(3,list_size)) |
264 |
|
else if( list_size > size(q0,2)) then |
267 |
|
endif |
268 |
|
q0 = q |
269 |
|
end subroutine saveNeighborList |
270 |
< |
|
271 |
< |
|
270 |
> |
|
271 |
> |
|
272 |
|
function getNeighborListSize() result(returnListSize) |
273 |
|
integer :: returnListSize |
274 |
|
returnListSize = listSize |
275 |
|
end function getNeighborListSize |
276 |
< |
|
276 |
> |
|
277 |
|
end module neighborLists |