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.5 2006-05-17 19:54:26 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. |
66 |
|
integer, parameter :: 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. |
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 ) |
225 |
|
dispmx_tmp = max( abs ( q(2,i) - q0(2,i) ), dispmx_tmp ) |
226 |
|
dispmx_tmp = max( abs ( q(3,i) - q0(3,i) ), dispmx_tmp ) |
227 |
|
end do |
228 |
+ |
#ifdef SINGLE_PRECISION |
229 |
+ |
call mpi_allreduce(dispmx_tmp,dispmx,1,mpi_real, & |
230 |
+ |
mpi_max,mpi_comm_world,mpi_err) |
231 |
+ |
#else |
232 |
|
call mpi_allreduce(dispmx_tmp,dispmx,1,mpi_double_precision, & |
233 |
|
mpi_max,mpi_comm_world,mpi_err) |
234 |
+ |
#endif |
235 |
|
|
236 |
|
#else |
237 |
< |
|
237 |
> |
|
238 |
|
dispmx = 0.0_DP |
239 |
|
do i = 1, nGroups |
240 |
|
dispmx = max( abs ( q(1,i) - q0(1,i) ), dispmx ) |
248 |
|
dispmx = 2.0E0_DP * sqrt (3.0E0_DP * dispmx * dispmx) |
249 |
|
|
250 |
|
update_nlist = (dispmx.gt.listSkin) |
251 |
< |
|
252 |
< |
end subroutine checkNeighborList |
253 |
< |
|
254 |
< |
|
251 |
> |
|
252 |
> |
end subroutine checkNeighborList |
253 |
> |
|
254 |
> |
|
255 |
|
!! Saves neighbor list for comparison in check. |
256 |
|
!! Save_neighborList will work even if the number of |
257 |
|
!! local atoms has changed. |
260 |
|
integer :: nGroups |
261 |
|
real(kind = dp ), dimension(3,nGroups), intent(in) :: q |
262 |
|
integer :: list_size |
263 |
< |
|
263 |
> |
|
264 |
|
!! get size of list |
265 |
|
list_size = nGroups |
266 |
< |
|
266 |
> |
|
267 |
|
if (.not. allocated(q0)) then |
268 |
|
allocate(q0(3,list_size)) |
269 |
|
else if( list_size > size(q0,2)) then |
272 |
|
endif |
273 |
|
q0 = q |
274 |
|
end subroutine saveNeighborList |
275 |
< |
|
276 |
< |
|
275 |
> |
|
276 |
> |
|
277 |
|
function getNeighborListSize() result(returnListSize) |
278 |
|
integer :: returnListSize |
279 |
|
returnListSize = listSize |
280 |
|
end function getNeighborListSize |
281 |
< |
|
281 |
> |
|
282 |
|
end module neighborLists |