1 |
+ |
!! |
2 |
+ |
!! Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
+ |
!! |
4 |
+ |
!! The University of Notre Dame grants you ("Licensee") a |
5 |
+ |
!! non-exclusive, royalty free, license to use, modify and |
6 |
+ |
!! redistribute this software in source and binary code form, provided |
7 |
+ |
!! that the following conditions are met: |
8 |
+ |
!! |
9 |
+ |
!! 1. Acknowledgement of the program authors must be made in any |
10 |
+ |
!! publication of scientific results based in part on use of the |
11 |
+ |
!! program. An acceptable form of acknowledgement is citation of |
12 |
+ |
!! the article in which the program was described (Matthew |
13 |
+ |
!! A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
+ |
!! J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
+ |
!! Parallel Simulation Engine for Molecular Dynamics," |
16 |
+ |
!! J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
+ |
!! |
18 |
+ |
!! 2. Redistributions of source code must retain the above copyright |
19 |
+ |
!! notice, this list of conditions and the following disclaimer. |
20 |
+ |
!! |
21 |
+ |
!! 3. Redistributions in binary form must reproduce the above copyright |
22 |
+ |
!! notice, this list of conditions and the following disclaimer in the |
23 |
+ |
!! documentation and/or other materials provided with the |
24 |
+ |
!! distribution. |
25 |
+ |
!! |
26 |
+ |
!! This software is provided "AS IS," without a warranty of any |
27 |
+ |
!! kind. All express or implied conditions, representations and |
28 |
+ |
!! warranties, including any implied warranty of merchantability, |
29 |
+ |
!! fitness for a particular purpose or non-infringement, are hereby |
30 |
+ |
!! excluded. The University of Notre Dame and its licensors shall not |
31 |
+ |
!! be liable for any damages suffered by licensee as a result of |
32 |
+ |
!! using, modifying or distributing the software or its |
33 |
+ |
!! derivatives. In no event will the University of Notre Dame or its |
34 |
+ |
!! licensors be liable for any lost revenue, profit or data, or for |
35 |
+ |
!! direct, indirect, special, consequential, incidental or punitive |
36 |
+ |
!! damages, however caused and regardless of the theory of liability, |
37 |
+ |
!! arising out of the use of or inability to use software, even if the |
38 |
+ |
!! University of Notre Dame has been advised of the possibility of |
39 |
+ |
!! such damages. |
40 |
+ |
!! |
41 |
+ |
|
42 |
+ |
|
43 |
|
!! Module neighborLists |
44 |
|
!! Implements verlet neighbor lists for force modules. |
45 |
|
!! Automagically expands neighbor list if size too small |
48 |
|
!! @author Charles F. Vardeman II |
49 |
|
!! @author Matthew Meineke |
50 |
|
!! @author J. Daniel Gezelter |
51 |
< |
!! @version $Id: neighborLists.F90,v 1.1.1.1 2004-09-24 04:16:36 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 |
|
|
123 |
– |
|
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 |