ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/neighborLists.F90
(Generate patch)

Comparing trunk/OOPSE/libmdtools/neighborLists.F90 (file contents):
Revision 480 by chuckv, Tue Apr 8 17:16:22 2003 UTC vs.
Revision 1198 by tim, Thu May 27 00:48:12 2004 UTC

# Line 1 | Line 1
1   !! Module neighborLists
2 < !! Impliments verlet neighbor lists for force modules.
2 > !! Implements verlet neighbor lists for force modules.
3   !! Automagically expands neighbor list if size too small
4   !! up to maxAllocations times. If after maxAllocations we try to
5   !! expand the neighbor list, we get an error message and quit.
6   !! @author Charles F. Vardeman II
7   !! @author Matthew Meineke
8   !! @author J. Daniel Gezelter
9 < !! @version $Id: neighborLists.F90,v 1.3 2003-04-08 17:16:22 chuckv Exp $,
9 > !! @version $Id: neighborLists.F90,v 1.11 2004-05-27 00:48:12 tim Exp $,
10  
11   module neighborLists
12    
# Line 44 | Line 44 | contains
44   contains
45  
46  
47 <  subroutine expandNeighborList(natoms, error)
47 >  subroutine expandNeighborList(nGroups, error)
48      integer, intent(out) :: error
49 <    integer :: natoms
49 >    integer :: nGroups
50      integer :: alloc_error
51      integer :: oldSize = 0
52      integer :: newSize = 0
53      integer :: i
54      integer, dimension(:), pointer :: newList => null()
55 <    error = 0
56 <    
55 >    error = 0  
56  
57      !! First time through we should allocate point and list.
58      !! If one is associated and one is not, something is wrong
59      !! and return a error.
60  
61 < #ifndef IS_MPI !!/Non MPI
61 > #ifdef IS_MPI !! // MPI
62      if (.not. associated(point) .and. &
63           .not. associated(list) ) then
64 <       allocate(point(natoms),stat=alloc_error)
64 >       allocate(point(getNgroupsInRow(plan_group_row)),stat=alloc_error)
65         if (alloc_error /= 0) then
66            write(default_error,*) &
67 <               "ExpandNeighborLists: Error in allocating point"
68 <          error = -1
67 >               "ExpandNeighborLists: Error in allocating MPI point"
68 >           error = -1
69            return
70         end if
71 <       allocate(list(listMultiplier * natoms),stat=alloc_error)
71 >       allocate(list(listMultiplier * getNgroupsInCol(plan_group_col)),stat=alloc_error)
72         if (alloc_error /= 0) then
73            write(default_error,*) &
74 <               "ExpandNeighborLists: Error in allocating list"
74 >               "ExpandNeighborLists: Error in allocating MPI list"
75            error = -1
76            return
77         end if
# Line 80 | Line 79 | contains
79         nAllocations = nAllocations + 1
80         return
81      end if
82 < #else !!// MPI
82 > #else !! // NONMPI
83      if (.not. associated(point) .and. &
84           .not. associated(list) ) then
85 <       allocate(point(getNRow(plan_row)),stat=alloc_error)
85 >       allocate(point(nGroups),stat=alloc_error)
86         if (alloc_error /= 0) then
87            write(default_error,*) &
88 <               "ExpandNeighborLists: Error in allocating MPI point"
89 <           error = -1
88 >               "ExpandNeighborLists: Error in allocating point"
89 >          error = -1
90            return
91         end if
92 <       allocate(list(listMultiplier * getNCol(plan_col)),stat=alloc_error)
92 >       allocate(list(listMultiplier * nGroups),stat=alloc_error)
93         if (alloc_error /= 0) then
94            write(default_error,*) &
95 <               "ExpandNeighborLists: Error in allocating MPI list"
95 >               "ExpandNeighborLists: Error in allocating list"
96            error = -1
97            return
98         end if
# Line 116 | Line 115 | contains
115  
116  
117   #ifdef IS_MPI !! MPI
118 <       newSize = listMultiplier * getNCol(plan_col) + oldSize
118 >       newSize = listMultiplier * getNgroupsInCol(plan_group_col) + oldSize
119   #else
120 <       newSize = listMultiplier * natoms + oldSize
120 >       newSize = listMultiplier * nGroups + oldSize
121   #endif !! MPI
122  
123        
# Line 152 | Line 151 | contains
151    
152    !! checks to see if any long range particle has moved
153    !! through the neighbor list skin thickness.
154 <  subroutine checkNeighborList(natoms, q, rcut, rlist, update_nlist)
155 <    integer :: natoms
156 <    real(kind = dp), intent(in) :: rcut, rlist
154 >  subroutine checkNeighborList(nGroups, q, listSkin, update_nlist)
155 >    integer :: nGroups
156 >    real(kind = dp), intent(in) :: listSkin
157      real( kind = dp ), dimension(:,:)  :: q
158      integer :: i
159      real( kind = DP ) :: dispmx
160      logical, intent(out) :: update_nlist
161      real( kind = DP ) :: dispmx_tmp
163    real( kind = dp ) :: skin_thickness
164    integer :: nlocal
162  
166
167    nlocal = natoms
168    skin_thickness = rlist - rcut
163      dispmx = 0.0E0_DP
164      !! calculate the largest displacement of any atom in any direction
165      
166      !! If we have changed the particle idents, then we need to update    
167 <    if (.not. allocated(q0) .or. size(q0) /= nlocal) then
167 >    if (.not. allocated(q0)) then      
168         update_nlist = .true.
169         return
170      end if
171  
172 +    if (size(q0,2) /= nGroups) then
173 +       update_nlist = .true.
174 +       return
175 +    end if
176  
177 +
178   #ifdef MPI
179      
180      dispmx_tmp = 0.0E0_DP
181 <    do i = 1, nlocal
181 >    do i = 1, nGroups
182         dispmx_tmp = max( abs ( q(1,i) - q0(1,i) ), dispmx_tmp )
183         dispmx_tmp = max( abs ( q(2,i) - q0(2,i) ), dispmx_tmp )
184         dispmx_tmp = max( abs ( q(3,i) - q0(3,i) ), dispmx_tmp )
# Line 190 | Line 189 | contains
189   #else
190      
191      dispmx = 0.0_DP
192 <    do i = 1, nlocal
192 >    do i = 1, nGroups
193         dispmx = max( abs ( q(1,i) - q0(1,i) ), dispmx )
194         dispmx = max( abs ( q(2,i) - q0(2,i) ), dispmx )
195         dispmx = max( abs ( q(3,i) - q0(3,i) ), dispmx )
196      end do
197  
198 < #endif
199 <    
198 > #endif  
199 >
200      !! a conservative test of list skin crossings
201 <    dispmx = 2.0E0_DP * sqrt (3.0E0_DP * dispmx * dispmx)
202 <    
203 <    update_nlist = (dispmx.gt.(skin_thickness))
204 <    
205 <  end subroutine checkNeighborList
201 >    dispmx = 2.0E0_DP * sqrt (3.0E0_DP * dispmx * dispmx)  
202 >
203 >    update_nlist = (dispmx.gt.listSkin)
204 >
205 >   end subroutine checkNeighborList
206    
207    
208    !! Saves neighbor list for comparison in check.
209    !! Save_neighborList will work even if the number of
210    !! local atoms has changed.
211 <  subroutine saveNeighborList(natoms, q)
211 >  subroutine saveNeighborList(nGroups, q)
212  
213 <    integer :: natoms
214 <    real(kind = dp ), dimension(3,natoms), intent(in)  :: q
213 >    integer :: nGroups
214 >    real(kind = dp ), dimension(3,nGroups), intent(in)  :: q
215      integer :: list_size
217
216      
217      !! get size of list
218 <    list_size = natoms
218 >    list_size = nGroups
219      
220      if (.not. allocated(q0)) then
221         allocate(q0(3,list_size))
222 <    else if( list_size > size(q0)) then
222 >    else if( list_size > size(q0,2)) then
223         deallocate(q0)
224         allocate(q0(3,list_size))
225      endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines