20 |
|
|
21 |
|
logical, save :: simulation_setup_complete = .false. |
22 |
|
|
23 |
< |
integer, public, save :: natoms |
23 |
> |
integer, public, save :: nLocal, nGlobal |
24 |
|
integer, public, save :: nExcludes_Global = 0 |
25 |
|
integer, public, save :: nExcludes_Local = 0 |
26 |
|
integer, allocatable, dimension(:,:), public :: excludesLocal |
27 |
|
integer, allocatable, dimension(:), public :: excludesGlobal |
28 |
|
integer, allocatable, dimension(:), public :: molMembershipList |
29 |
|
|
30 |
< |
real(kind=dp), save :: rcut2 = 0.0_DP |
31 |
< |
real(kind=dp), save :: rcut6 = 0.0_DP |
32 |
< |
real(kind=dp), save :: rlist2 = 0.0_DP |
33 |
< |
real(kind=dp), public, dimension(3), save :: box |
34 |
< |
|
30 |
> |
real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv |
31 |
> |
logical, public, save :: boxIsOrthorhombic |
32 |
|
|
33 |
|
public :: SimulationSetup |
34 |
|
public :: getNlocal |
35 |
|
public :: setBox |
39 |
– |
public :: setBox_3d |
40 |
– |
public :: getBox |
41 |
– |
public :: setRcut |
42 |
– |
public :: getRcut |
43 |
– |
public :: getRlist |
44 |
– |
public :: getRrf |
45 |
– |
public :: getRt |
36 |
|
public :: getDielect |
37 |
|
public :: SimUsesPBC |
38 |
|
public :: SimUsesLJ |
44 |
|
public :: SimRequiresPrepairCalc |
45 |
|
public :: SimRequiresPostpairCalc |
46 |
|
public :: SimUsesDirectionalAtoms |
57 |
– |
|
58 |
– |
interface getBox |
59 |
– |
module procedure getBox_3d |
60 |
– |
module procedure getBox_1d |
61 |
– |
end interface |
47 |
|
|
63 |
– |
interface setBox |
64 |
– |
module procedure setBox_3d |
65 |
– |
module procedure setBox_1d |
66 |
– |
end interface |
67 |
– |
|
48 |
|
contains |
49 |
|
|
50 |
< |
subroutine SimulationSetup(setThisSim, nGlobal, nLocal, c_idents, & |
50 |
> |
subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & |
51 |
|
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
52 |
|
CmolMembership, & |
53 |
|
status) |
54 |
|
|
55 |
|
type (simtype) :: setThisSim |
56 |
< |
integer, intent(inout) :: nGlobal, nLocal |
57 |
< |
integer, dimension(nLocal),intent(inout) :: c_idents |
56 |
> |
integer, intent(inout) :: CnGlobal, CnLocal |
57 |
> |
integer, dimension(CnLocal),intent(inout) :: c_idents |
58 |
|
|
59 |
|
integer :: CnLocalExcludes |
60 |
|
integer, dimension(2,CnLocalExcludes), intent(in) :: CexcludesLocal |
61 |
|
integer :: CnGlobalExcludes |
62 |
|
integer, dimension(CnGlobalExcludes), intent(in) :: CexcludesGlobal |
63 |
< |
integer, dimension(nGlobal),intent(in) :: CmolMembership |
63 |
> |
integer, dimension(CnGlobal),intent(in) :: CmolMembership |
64 |
|
!! Result status, success = 0, status = -1 |
65 |
|
integer, intent(out) :: status |
66 |
|
integer :: i, me, thisStat, alloc_stat, myNode |
75 |
|
status = 0 |
76 |
|
|
77 |
|
! copy C struct into fortran type |
78 |
+ |
|
79 |
+ |
nLocal = CnLocal |
80 |
+ |
nGlobal = CnGlobal |
81 |
+ |
|
82 |
|
thisSim = setThisSim |
99 |
– |
natoms = nLocal |
100 |
– |
rcut2 = thisSim%rcut * thisSim%rcut |
101 |
– |
rcut6 = rcut2 * rcut2 * rcut2 |
102 |
– |
rlist2 = thisSim%rlist * thisSim%rlist |
103 |
– |
box = thisSim%box |
83 |
|
|
84 |
|
nExcludes_Global = CnGlobalExcludes |
85 |
|
nExcludes_Local = CnLocalExcludes |
86 |
|
|
87 |
< |
call InitializeForceGlobals(natoms, thisStat) |
87 |
> |
call InitializeForceGlobals(nLocal, thisStat) |
88 |
|
if (thisStat /= 0) then |
89 |
|
write(default_error,*) "SimSetup: InitializeForceGlobals error" |
90 |
|
status = -1 |
164 |
|
|
165 |
|
do i = 1, nGlobal |
166 |
|
molMemberShipList(i) = CmolMembership(i) |
167 |
< |
! write(0,*) 'molMembershipList(',i,') = ', molMemberShipList(i) |
189 |
< |
enddo |
167 |
> |
enddo |
168 |
|
|
169 |
|
if (status == 0) simulation_setup_complete = .true. |
170 |
|
|
171 |
|
end subroutine SimulationSetup |
172 |
|
|
173 |
< |
subroutine setBox_3d(new_box_size) |
174 |
< |
real(kind=dp), dimension(3) :: new_box_size |
173 |
> |
subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
174 |
> |
real(kind=dp), dimension(3,3) :: cHmat, cHmatInv |
175 |
> |
integer :: cBoxIsOrthorhombic |
176 |
|
integer :: smallest, status, i |
177 |
< |
|
178 |
< |
thisSim%box = new_box_size |
179 |
< |
box = thisSim%box |
180 |
< |
|
177 |
> |
|
178 |
> |
Hmat = cHmat |
179 |
> |
HmatInv = cHmatInv |
180 |
> |
if (cBoxIsOrthorhombic .eq. 0 ) then |
181 |
> |
boxIsOrthorhombic = .false. |
182 |
> |
else |
183 |
> |
boxIsOrthorhombic = .true. |
184 |
> |
endif |
185 |
> |
|
186 |
|
return |
187 |
< |
end subroutine setBox_3d |
204 |
< |
|
205 |
< |
subroutine setBox_1d(dim, new_box_size) |
206 |
< |
integer :: dim, status |
207 |
< |
real(kind=dp) :: new_box_size |
208 |
< |
thisSim%box(dim) = new_box_size |
209 |
< |
box(dim) = thisSim%box(dim) |
210 |
< |
end subroutine setBox_1d |
211 |
< |
|
212 |
< |
subroutine setRcut(new_rcut, status) |
213 |
< |
real(kind = dp) :: new_rcut |
214 |
< |
integer :: myStatus, status |
215 |
< |
thisSim%rcut = new_rcut |
216 |
< |
rcut2 = thisSim%rcut * thisSim%rcut |
217 |
< |
rcut6 = rcut2 * rcut2 * rcut2 |
218 |
< |
status = 0 |
219 |
< |
return |
220 |
< |
end subroutine setRcut |
187 |
> |
end subroutine setBox |
188 |
|
|
222 |
– |
function getBox_3d() result(thisBox) |
223 |
– |
real( kind = dp ), dimension(3) :: thisBox |
224 |
– |
thisBox = thisSim%box |
225 |
– |
end function getBox_3d |
226 |
– |
|
227 |
– |
function getBox_1d(dim) result(thisBox) |
228 |
– |
integer, intent(in) :: dim |
229 |
– |
real( kind = dp ) :: thisBox |
230 |
– |
|
231 |
– |
thisBox = thisSim%box(dim) |
232 |
– |
end function getBox_1d |
233 |
– |
|
234 |
– |
subroutine getRcut(thisrcut,rc2,rc6,status) |
235 |
– |
real( kind = dp ), intent(out) :: thisrcut |
236 |
– |
real( kind = dp ), intent(out), optional :: rc2 |
237 |
– |
real( kind = dp ), intent(out), optional :: rc6 |
238 |
– |
integer, optional :: status |
239 |
– |
|
240 |
– |
if (present(status)) status = 0 |
241 |
– |
|
242 |
– |
if (.not.simulation_setup_complete ) then |
243 |
– |
if (present(status)) status = -1 |
244 |
– |
return |
245 |
– |
end if |
246 |
– |
|
247 |
– |
thisrcut = thisSim%rcut |
248 |
– |
if(present(rc2)) rc2 = rcut2 |
249 |
– |
if(present(rc6)) rc6 = rcut6 |
250 |
– |
end subroutine getRcut |
251 |
– |
|
252 |
– |
subroutine getRlist(thisrlist,rl2,status) |
253 |
– |
real( kind = dp ), intent(out) :: thisrlist |
254 |
– |
real( kind = dp ), intent(out), optional :: rl2 |
255 |
– |
|
256 |
– |
integer, optional :: status |
257 |
– |
|
258 |
– |
if (present(status)) status = 0 |
259 |
– |
|
260 |
– |
if (.not.simulation_setup_complete ) then |
261 |
– |
if (present(status)) status = -1 |
262 |
– |
return |
263 |
– |
end if |
264 |
– |
|
265 |
– |
thisrlist = thisSim%rlist |
266 |
– |
if(present(rl2)) rl2 = rlist2 |
267 |
– |
end subroutine getRlist |
268 |
– |
|
269 |
– |
function getRrf() result(rrf) |
270 |
– |
real( kind = dp ) :: rrf |
271 |
– |
rrf = thisSim%rrf |
272 |
– |
write(*,*) 'getRrf = ', rrf, thisSim%rrf |
273 |
– |
end function getRrf |
274 |
– |
|
275 |
– |
function getRt() result(rt) |
276 |
– |
real( kind = dp ) :: rt |
277 |
– |
rt = thisSim%rt |
278 |
– |
end function getRt |
279 |
– |
|
189 |
|
function getDielect() result(dielect) |
190 |
|
real( kind = dp ) :: dielect |
191 |
|
dielect = thisSim%dielect |
262 |
|
return |
263 |
|
endif |
264 |
|
|
265 |
< |
allocate(molMembershipList(getNlocal()), stat=alloc_stat) |
265 |
> |
allocate(molMembershipList(nGlobal), stat=alloc_stat) |
266 |
|
if (alloc_stat /= 0 ) then |
267 |
|
thisStat = -1 |
268 |
|
return |
280 |
|
|
281 |
|
end subroutine FreeSimGlobals |
282 |
|
|
283 |
< |
pure function getNlocal() result(nlocal) |
284 |
< |
integer :: nlocal |
285 |
< |
nlocal = natoms |
283 |
> |
pure function getNlocal() result(n) |
284 |
> |
integer :: n |
285 |
> |
n = nLocal |
286 |
|
end function getNlocal |
287 |
|
|
288 |
|
|