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

Comparing trunk/OOPSE/libmdtools/simulation_module.F90 (file contents):
Revision 1198 by tim, Thu May 27 00:48:12 2004 UTC vs.
Revision 1214 by gezelter, Tue Jun 1 18:42:58 2004 UTC

# Line 64 | Line 64 | contains
64    
65    subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
66         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
67 <       CmolMembership, Cmfact, CnGroups, CgroupList, CgroupStart, &
67 >       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
68         status)    
69  
70      type (simtype) :: setThisSim
# Line 84 | Line 84 | contains
84      !! mass factors used for molecular cutoffs
85      real ( kind = dp ), dimension(CnLocal) :: Cmfact
86      integer, intent(in):: CnGroups
87 <    integer, dimension(CnLocal),intent(in) :: CgroupList
88 <    integer, dimension(CnGroups),intent(in) :: CgroupStart
89 <    integer :: maxSkipsForAtom
87 >    integer, dimension(CnGlobal), intent(in):: CglobalGroupMembership
88 >    integer :: maxSkipsForAtom, glPointer
89  
90   #ifdef IS_MPI
91      integer, allocatable, dimension(:) :: c_idents_Row
92      integer, allocatable, dimension(:) :: c_idents_Col
93 <    integer :: nAtomsInRow, nGroupsInRow
94 <    integer :: nAtomsInCol, nGroupsInCol
93 >    integer :: nAtomsInRow, nGroupsInRow, aid
94 >    integer :: nAtomsInCol, nGroupsInCol, gid
95   #endif  
96  
97      simulation_setup_complete = .false.
# Line 202 | Line 201 | contains
201         status = -1
202         return
203      endif
204 <    allocate(groupStartLocal(nGroups), stat=alloc_stat)
204 >    allocate(mfactLocal(nLocal),stat=alloc_stat)
205      if (alloc_stat /= 0 ) then
206         status = -1
207         return
208      endif
209 <    allocate(groupListLocal(nLocal), stat=alloc_stat)
210 <    if (alloc_stat /= 0 ) then
211 <       status = -1
212 <       return
213 <    endif    
214 <    allocate(mfactLocal(nLocal), stat=alloc_stat)
215 <    if (alloc_stat /= 0 ) then
216 <       status = -1
217 <       return
218 <    endif    
219 <            
220 <    groupStartLocal = CgroupStart
221 <    groupListLocal = CgroupList
209 >    
210 >    glPointer = 1
211 >
212 >    do i = 1, nGroupsInRow
213 >
214 >       gid = GroupRowToGlobal(i)
215 >       groupStartRow(i) = glPointer      
216 >
217 >       do j = 1, nAtomsInRow
218 >          aid = AtomRowToGlobal(j)
219 >          if (CglobalGroupMembership(aid) .eq. gid) then
220 >             groupListRow(glPointer) = j
221 >             glPointer = glPointer + 1
222 >          endif
223 >       enddo
224 >    enddo
225 >    groupStartRow(nGroupsInRow+1) = nAtomsInRow + 1
226 >
227 >    glPointer = 1
228 >
229 >    do i = 1, nGroupsInCol
230 >
231 >       gid = GroupColToGlobal(i)
232 >       groupStartCol(i) = glPointer      
233 >
234 >       do j = 1, nAtomsInCol
235 >          aid = AtomColToGlobal(j)
236 >          if (CglobalGroupMembership(aid) .eq. gid) then
237 >             groupListCol(glPointer) = j
238 >             glPointer = glPointer + 1
239 >          endif
240 >       enddo
241 >    enddo
242 >    groupStartCol(nGroupsInCol+1) = nAtomsInCol + 1
243 >
244      mfactLocal = Cmfact        
245 <            
225 <    call gather(groupStartLocal, groupStartRow, plan_group_row)
226 <    call gather(groupStartLocal, groupStartCol, plan_group_col)
227 <    groupStartRow(nGroupsInRow+1) = nAtomsInRow
228 <    groupStartCol(nGroupsInCol+1) = nAtomsInCol
229 <    call gather(groupListLocal,  groupListRow,  plan_atom_row)
230 <    call gather(groupListLocal,  groupListCol,  plan_atom_col)
245 >
246      call gather(mfactLocal,      mfactRow,      plan_atom_row)
247      call gather(mfactLocal,      mfactCol,      plan_atom_col)
248      
249      if (allocated(mfactLocal)) then
250         deallocate(mfactLocal)
251      end if
237    if (allocated(groupListLocal)) then
238       deallocate(groupListLocal)
239    endif
240    if (allocated(groupStartLocal)) then
241       deallocate(groupStartLocal)
242    endif
252   #else
253      allocate(groupStartRow(nGroups+1),stat=alloc_stat)
254      if (alloc_stat /= 0 ) then
# Line 271 | Line 280 | contains
280         status = -1
281         return
282      endif
283 +    allocate(mfactLocal(nLocal),stat=alloc_stat)
284 +    if (alloc_stat /= 0 ) then
285 +       status = -1
286 +       return
287 +    endif
288 +
289 +    glPointer = 1
290      do i = 1, nGroups
291 <       groupStartRow(i) = CgroupStart(i)
292 <       groupStartCol(i) = CgroupStart(i)
293 <    end do
294 <    groupStartRow(nGroups+1) = nLocal
295 <    groupStartCol(nGroups+1) = nLocal
291 >       groupStartRow(i) = glPointer      
292 >       groupStartCol(i) = glPointer
293 >       do j = 1, nLocal
294 >          if (CglobalGroupMembership(j) .eq. i) then
295 >             groupListRow(glPointer) = j
296 >             groupListCol(glPointer) = j
297 >             glPointer = glPointer + 1
298 >          endif
299 >       enddo
300 >    enddo
301 >    groupStartRow(nGroups+1) = nLocal + 1
302 >    groupStartCol(nGroups+1) = nLocal + 1
303 >
304      do i = 1, nLocal
281       groupListRow(i) = CgroupList(i)
282       groupListCol(i) = CgroupList(i)
305         mfactRow(i) = Cmfact(i)
306         mfactCol(i) = Cmfact(i)
307      end do
# Line 301 | Line 323 | contains
323      enddo
324  
325      maxSkipsForAtom = 0
326 + #ifdef IS_MPI
327 +    do j = 1, nAtomsInRow
328 + #else
329      do j = 1, nLocal
330 + #endif
331         nSkipsForAtom(j) = 0
332   #ifdef IS_MPI
333         id1 = AtomRowToGlobal(j)
# Line 326 | Line 352 | contains
352         end do
353      enddo
354  
355 + #ifdef IS_MPI
356 +    allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
357 + #else
358      allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
359 + #endif
360      if (alloc_stat /= 0 ) then
361         write(*,*) 'Could not allocate skipsForAtom array'
362         return
363      endif
364  
365 + #ifdef IS_MPI
366 +    do j = 1, nAtomsInRow
367 + #else
368      do j = 1, nLocal
369 + #endif
370         nSkipsForAtom(j) = 0
371   #ifdef IS_MPI
372         id1 = AtomRowToGlobal(j)
# Line 342 | Line 376 | contains
376         do i = 1, nExcludes_Local
377            if (excludesLocal(1,i) .eq. id1 ) then
378               nSkipsForAtom(j) = nSkipsForAtom(j) + 1
379 < #ifdef IS_MPI
380 <             id2 = AtomColToGlobal(excludesLocal(2,i))
347 < #else
379 >             ! exclude lists have global ID's so this line is
380 >             ! the same in MPI and non-MPI
381               id2 = excludesLocal(2,i)
349 #endif
382               skipsForAtom(j, nSkipsForAtom(j)) = id2
383            endif
384            if (excludesLocal(2, i) .eq. id2 ) then
385               nSkipsForAtom(j) = nSkipsForAtom(j) + 1
386 < #ifdef IS_MPI
387 <             id2 = AtomColToGlobal(excludesLocal(1,i))
356 < #else
386 >             ! exclude lists have global ID's so this line is
387 >             ! the same in MPI and non-MPI
388               id2 = excludesLocal(1,i)
358 #endif
389               skipsForAtom(j, nSkipsForAtom(j)) = id2
390            endif
391         end do
# Line 489 | Line 519 | contains
519      !We free in the opposite order in which we allocate in.
520  
521      if (allocated(skipsForAtom)) deallocate(skipsForAtom)
522 +    if (allocated(mfactLocal)) deallocate(mfactLocal)
523      if (allocated(mfactCol)) deallocate(mfactCol)
524      if (allocated(mfactRow)) deallocate(mfactRow)
525      if (allocated(groupListCol)) deallocate(groupListCol)    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines