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.6 2006-12-05 00:17:24 chuckv 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. |
66 |
< |
integer, parameter :: listMultiplier = 80 |
64 |
> |
!! Default Parameter for size > # of long range particles neighbor list |
65 |
> |
!! should be. It is listMultiplier x nGroups for size of list |
66 |
> |
integer, save :: listMultiplier = 80 |
67 |
|
!! Maximum number of times we should reallocate neighbor list. |
68 |
< |
integer, parameter :: maxAllocations = 5 |
68 |
> |
integer, parameter :: maxAllocations = 10 |
69 |
|
!! Number of times we have allocated the neighbor list. |
70 |
|
integer, save :: nAllocations = 0 |
71 |
|
!! Pointer array to location in list for atom i. |
77 |
|
real( kind = dp ), dimension(:,:), allocatable, save :: q0 |
78 |
|
!! Current list size |
79 |
|
integer, save :: listSize |
80 |
+ |
|
81 |
|
!--------------MODULE ACCESS--------------------------> |
82 |
|
public :: expandNeighborList |
83 |
|
public :: checkNeighborList |
84 |
|
public :: saveNeighborList |
85 |
|
public :: getNeighborListSize |
86 |
< |
|
86 |
> |
public :: setNeighbors |
87 |
> |
|
88 |
|
contains |
89 |
|
|
90 |
|
|
109 |
|
if (alloc_error /= 0) then |
110 |
|
write(default_error,*) & |
111 |
|
"ExpandNeighborLists: Error in allocating MPI point" |
112 |
< |
error = -1 |
112 |
> |
error = -1 |
113 |
|
return |
114 |
|
end if |
115 |
|
allocate(list(listMultiplier * getNgroupsInCol(plan_group_col)),stat=alloc_error) |
145 |
|
return |
146 |
|
end if |
147 |
|
#endif !! //MPI |
148 |
< |
|
148 |
> |
|
149 |
|
! Expand the neighbor list |
150 |
< |
|
150 |
> |
|
151 |
|
! Check to see if we have exceeded the maximum number of allocations. |
152 |
|
if (nAllocations > maxAllocations) then |
153 |
|
write(default_error,*) & |
164 |
|
newSize = listMultiplier * nGroups + oldSize |
165 |
|
#endif !! MPI |
166 |
|
|
165 |
– |
|
167 |
|
|
168 |
+ |
|
169 |
|
allocate(newList(newSize), stat=alloc_error) |
170 |
|
if (alloc_error /= 0) then |
171 |
|
write(*,*) "Error allocating new neighborlist" |
183 |
|
error = -1 |
184 |
|
return |
185 |
|
end if |
186 |
< |
|
186 |
> |
|
187 |
|
!! Point list at new list |
188 |
< |
|
188 |
> |
|
189 |
|
list => newList |
190 |
|
end if |
191 |
|
|
192 |
|
nAllocations = nAllocations + 1 |
193 |
|
listSize = size(list) |
194 |
|
end subroutine expandNeighborList |
195 |
< |
|
195 |
> |
|
196 |
|
!! checks to see if any long range particle has moved |
197 |
|
!! through the neighbor list skin thickness. |
198 |
|
subroutine checkNeighborList(nGroups, q, listSkin, update_nlist) |
206 |
|
|
207 |
|
dispmx = 0.0E0_DP |
208 |
|
!! calculate the largest displacement of any atom in any direction |
209 |
< |
|
209 |
> |
|
210 |
|
!! If we have changed the particle idents, then we need to update |
211 |
|
if (.not. allocated(q0)) then |
212 |
|
update_nlist = .true. |
220 |
|
|
221 |
|
|
222 |
|
#ifdef MPI |
223 |
< |
|
223 |
> |
|
224 |
|
dispmx_tmp = 0.0E0_DP |
225 |
|
do i = 1, nGroups |
226 |
|
dispmx_tmp = max( abs ( q(1,i) - q0(1,i) ), dispmx_tmp ) |
227 |
|
dispmx_tmp = max( abs ( q(2,i) - q0(2,i) ), dispmx_tmp ) |
228 |
|
dispmx_tmp = max( abs ( q(3,i) - q0(3,i) ), dispmx_tmp ) |
229 |
|
end do |
230 |
+ |
#ifdef SINGLE_PRECISION |
231 |
+ |
call mpi_allreduce(dispmx_tmp,dispmx,1,mpi_real, & |
232 |
+ |
mpi_max,mpi_comm_world,mpi_err) |
233 |
+ |
#else |
234 |
|
call mpi_allreduce(dispmx_tmp,dispmx,1,mpi_double_precision, & |
235 |
|
mpi_max,mpi_comm_world,mpi_err) |
236 |
+ |
#endif |
237 |
|
|
238 |
|
#else |
239 |
< |
|
239 |
> |
|
240 |
|
dispmx = 0.0_DP |
241 |
|
do i = 1, nGroups |
242 |
|
dispmx = max( abs ( q(1,i) - q0(1,i) ), dispmx ) |
250 |
|
dispmx = 2.0E0_DP * sqrt (3.0E0_DP * dispmx * dispmx) |
251 |
|
|
252 |
|
update_nlist = (dispmx.gt.listSkin) |
253 |
< |
|
254 |
< |
end subroutine checkNeighborList |
255 |
< |
|
256 |
< |
|
253 |
> |
|
254 |
> |
end subroutine checkNeighborList |
255 |
> |
|
256 |
> |
|
257 |
|
!! Saves neighbor list for comparison in check. |
258 |
|
!! Save_neighborList will work even if the number of |
259 |
|
!! local atoms has changed. |
262 |
|
integer :: nGroups |
263 |
|
real(kind = dp ), dimension(3,nGroups), intent(in) :: q |
264 |
|
integer :: list_size |
265 |
< |
|
265 |
> |
|
266 |
|
!! get size of list |
267 |
|
list_size = nGroups |
268 |
< |
|
268 |
> |
|
269 |
|
if (.not. allocated(q0)) then |
270 |
|
allocate(q0(3,list_size)) |
271 |
|
else if( list_size > size(q0,2)) then |
274 |
|
endif |
275 |
|
q0 = q |
276 |
|
end subroutine saveNeighborList |
277 |
< |
|
278 |
< |
|
277 |
> |
|
278 |
> |
|
279 |
|
function getNeighborListSize() result(returnListSize) |
280 |
|
integer :: returnListSize |
281 |
|
returnListSize = listSize |
282 |
|
end function getNeighborListSize |
283 |
< |
|
283 |
> |
|
284 |
> |
|
285 |
> |
subroutine setNeighbors(nNeighbors) |
286 |
> |
integer, intent(in) :: nNeighbors |
287 |
> |
listMultiplier = nNeighbors |
288 |
> |
end subroutine setNeighbors |
289 |
> |
|
290 |
|
end module neighborLists |