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 |
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. |
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 |
212 |
< |
status = -1 |
213 |
< |
return |
214 |
< |
endif |
215 |
< |
allocate(mfactLocal(nLocal), stat=alloc_stat) |
216 |
< |
if (alloc_stat /= 0 ) then |
217 |
< |
status = -1 |
218 |
< |
return |
219 |
< |
endif |
220 |
< |
|
221 |
< |
groupStartLocal = CgroupStart |
222 |
< |
groupListLocal = CgroupList |
223 |
< |
mfactLocal = Cmfact |
224 |
< |
|
225 |
< |
call gather(groupStartLocal, groupStartRow, plan_group_row) |
226 |
< |
call gather(groupStartLocal, groupStartCol, plan_group_col) |
227 |
< |
groupStartRow(nGroupsInRow+1) = nAtomsInRow + 1 |
228 |
< |
groupStartCol(nGroupsInCol+1) = nAtomsInCol + 1 |
229 |
< |
call gather(groupListLocal, groupListRow, plan_atom_row) |
230 |
< |
call gather(groupListLocal, groupListCol, plan_atom_col) |
209 |
> |
|
210 |
> |
glPointer = 1 |
211 |
|
|
212 |
< |
! C passes us groupList as globalID numbers for the atoms |
233 |
< |
! we need to remap these onto the row and column ids on this |
234 |
< |
! processor. This is a linear search, but is only done once |
235 |
< |
! (we hope) |
212 |
> |
do i = 1, nGroupsInRow |
213 |
|
|
214 |
< |
do i = 1, nAtomsInRow |
214 |
> |
gid = GroupRowToGlobal(i) |
215 |
> |
groupStartRow(i) = glPointer |
216 |
> |
|
217 |
|
do j = 1, nAtomsInRow |
218 |
< |
if (AtomRowToGlobal(j) .eq. groupListRow(i)) then |
219 |
< |
groupListRow(i) = j |
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 |
< |
do i = 1, nAtomsInCol |
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 |
< |
if (AtomColToGlobal(j) .eq. groupListCol(i)) then |
236 |
< |
groupListCol(i) = j |
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 |
+ |
|
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 |
257 |
– |
if (allocated(groupListLocal)) then |
258 |
– |
deallocate(groupListLocal) |
259 |
– |
endif |
260 |
– |
if (allocated(groupStartLocal)) then |
261 |
– |
deallocate(groupStartLocal) |
262 |
– |
endif |
252 |
|
#else |
253 |
|
allocate(groupStartRow(nGroups+1),stat=alloc_stat) |
254 |
|
if (alloc_stat /= 0 ) then |
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 |
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 |
301 |
– |
groupListRow(i) = CgroupList(i) |
302 |
– |
groupListCol(i) = CgroupList(i) |
305 |
|
mfactRow(i) = Cmfact(i) |
306 |
|
mfactCol(i) = Cmfact(i) |
307 |
|
end do |
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) |