| 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 |
| 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 |
< |
|
| 33 |
> |
real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv |
| 34 |
> |
logical, public, save :: boxIsOrthorhombic |
| 35 |
|
|
| 36 |
|
public :: SimulationSetup |
| 37 |
|
public :: getNlocal |
| 38 |
|
public :: setBox |
| 39 |
– |
public :: setBox_3d |
| 40 |
– |
public :: getBox |
| 39 |
|
public :: setRcut |
| 40 |
|
public :: getRcut |
| 41 |
|
public :: getRlist |
| 52 |
|
public :: SimRequiresPrepairCalc |
| 53 |
|
public :: SimRequiresPostpairCalc |
| 54 |
|
public :: SimUsesDirectionalAtoms |
| 57 |
– |
|
| 58 |
– |
interface getBox |
| 59 |
– |
module procedure getBox_3d |
| 60 |
– |
module procedure getBox_1d |
| 61 |
– |
end interface |
| 55 |
|
|
| 63 |
– |
interface setBox |
| 64 |
– |
module procedure setBox_3d |
| 65 |
– |
module procedure setBox_1d |
| 66 |
– |
end interface |
| 67 |
– |
|
| 56 |
|
contains |
| 57 |
|
|
| 58 |
< |
subroutine SimulationSetup(setThisSim, nComponents, c_idents, & |
| 59 |
< |
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, CmolMembership, & |
| 58 |
> |
subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & |
| 59 |
> |
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
| 60 |
> |
CmolMembership, & |
| 61 |
|
status) |
| 62 |
|
|
| 63 |
|
type (simtype) :: setThisSim |
| 64 |
< |
integer, intent(inout) :: nComponents |
| 65 |
< |
integer, dimension(nComponents),intent(inout) :: c_idents |
| 64 |
> |
integer, intent(inout) :: CnGlobal, CnLocal |
| 65 |
> |
integer, dimension(CnLocal),intent(inout) :: c_idents |
| 66 |
|
|
| 67 |
|
integer :: CnLocalExcludes |
| 68 |
|
integer, dimension(2,CnLocalExcludes), intent(in) :: CexcludesLocal |
| 69 |
|
integer :: CnGlobalExcludes |
| 70 |
|
integer, dimension(CnGlobalExcludes), intent(in) :: CexcludesGlobal |
| 71 |
< |
integer, dimension(nComponents),intent(in) :: CmolMembership |
| 71 |
> |
integer, dimension(CnGlobal),intent(in) :: CmolMembership |
| 72 |
|
!! Result status, success = 0, status = -1 |
| 73 |
|
integer, intent(out) :: status |
| 74 |
|
integer :: i, me, thisStat, alloc_stat, myNode |
| 83 |
|
status = 0 |
| 84 |
|
|
| 85 |
|
! copy C struct into fortran type |
| 86 |
+ |
|
| 87 |
+ |
nLocal = CnLocal |
| 88 |
+ |
nGlobal = CnGlobal |
| 89 |
+ |
|
| 90 |
|
thisSim = setThisSim |
| 98 |
– |
natoms = nComponents |
| 91 |
|
rcut2 = thisSim%rcut * thisSim%rcut |
| 92 |
|
rcut6 = rcut2 * rcut2 * rcut2 |
| 93 |
|
rlist2 = thisSim%rlist * thisSim%rlist |
| 102 |
– |
box = thisSim%box |
| 94 |
|
|
| 95 |
|
nExcludes_Global = CnGlobalExcludes |
| 96 |
|
nExcludes_Local = CnLocalExcludes |
| 97 |
|
|
| 98 |
< |
call InitializeForceGlobals(natoms, thisStat) |
| 98 |
> |
call InitializeForceGlobals(nLocal, thisStat) |
| 99 |
|
if (thisStat /= 0) then |
| 100 |
|
write(default_error,*) "SimSetup: InitializeForceGlobals error" |
| 101 |
|
status = -1 |
| 154 |
|
endif |
| 155 |
|
|
| 156 |
|
#else |
| 157 |
< |
do i = 1, nComponents |
| 157 |
> |
do i = 1, nLocal |
| 158 |
|
|
| 159 |
|
me = getFirstMatchingElement(atypes, "c_ident", c_idents(i)) |
| 160 |
|
atid(i) = me |
| 173 |
|
excludesGlobal(i) = CexcludesGlobal(i) |
| 174 |
|
enddo |
| 175 |
|
|
| 176 |
< |
molMemberShipList = CmolMembership |
| 176 |
> |
do i = 1, nGlobal |
| 177 |
> |
molMemberShipList(i) = CmolMembership(i) |
| 178 |
> |
enddo |
| 179 |
|
|
| 180 |
|
if (status == 0) simulation_setup_complete = .true. |
| 181 |
|
|
| 182 |
|
end subroutine SimulationSetup |
| 183 |
|
|
| 184 |
< |
subroutine setBox_3d(new_box_size) |
| 185 |
< |
real(kind=dp), dimension(3) :: new_box_size |
| 186 |
< |
integer :: smallest, status, i |
| 187 |
< |
|
| 188 |
< |
thisSim%box = new_box_size |
| 189 |
< |
box = thisSim%box |
| 190 |
< |
|
| 184 |
> |
subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
| 185 |
> |
real(kind=dp), dimension(3,3) :: cHmat, cHmatInv |
| 186 |
> |
integer :: cBoxIsOrthorhombic |
| 187 |
> |
integer :: smallest, status, i |
| 188 |
> |
|
| 189 |
> |
Hmat = cHmat |
| 190 |
> |
HmatInv = cHmatInv |
| 191 |
> |
if (cBoxIsOrthorhombic .eq. 0 ) then |
| 192 |
> |
boxIsOrthorhombic = .false. |
| 193 |
> |
else |
| 194 |
> |
boxIsOrthorhombic = .true. |
| 195 |
> |
endif |
| 196 |
> |
|
| 197 |
|
return |
| 198 |
< |
end subroutine setBox_3d |
| 198 |
> |
end subroutine setBox |
| 199 |
|
|
| 201 |
– |
subroutine setBox_1d(dim, new_box_size) |
| 202 |
– |
integer :: dim, status |
| 203 |
– |
real(kind=dp) :: new_box_size |
| 204 |
– |
thisSim%box(dim) = new_box_size |
| 205 |
– |
box(dim) = thisSim%box(dim) |
| 206 |
– |
end subroutine setBox_1d |
| 207 |
– |
|
| 200 |
|
subroutine setRcut(new_rcut, status) |
| 201 |
|
real(kind = dp) :: new_rcut |
| 202 |
|
integer :: myStatus, status |
| 206 |
|
status = 0 |
| 207 |
|
return |
| 208 |
|
end subroutine setRcut |
| 217 |
– |
|
| 218 |
– |
function getBox_3d() result(thisBox) |
| 219 |
– |
real( kind = dp ), dimension(3) :: thisBox |
| 220 |
– |
thisBox = thisSim%box |
| 221 |
– |
end function getBox_3d |
| 222 |
– |
|
| 223 |
– |
function getBox_1d(dim) result(thisBox) |
| 224 |
– |
integer, intent(in) :: dim |
| 225 |
– |
real( kind = dp ) :: thisBox |
| 226 |
– |
|
| 227 |
– |
thisBox = thisSim%box(dim) |
| 228 |
– |
end function getBox_1d |
| 209 |
|
|
| 210 |
|
subroutine getRcut(thisrcut,rc2,rc6,status) |
| 211 |
|
real( kind = dp ), intent(out) :: thisrcut |
| 245 |
|
function getRrf() result(rrf) |
| 246 |
|
real( kind = dp ) :: rrf |
| 247 |
|
rrf = thisSim%rrf |
| 248 |
< |
write(*,*) 'getRrf = ', rrf, thisSim%rrf |
| 248 |
> |
write(*,*) 'getRrf = ', rrf |
| 249 |
|
end function getRrf |
| 250 |
|
|
| 251 |
|
function getRt() result(rt) |
| 252 |
|
real( kind = dp ) :: rt |
| 253 |
|
rt = thisSim%rt |
| 254 |
+ |
write(*,*) 'getRt = ', rt |
| 255 |
|
end function getRt |
| 256 |
|
|
| 257 |
|
function getDielect() result(dielect) |
| 330 |
|
return |
| 331 |
|
endif |
| 332 |
|
|
| 333 |
< |
allocate(molMembershipList(getNlocal()), stat=alloc_stat) |
| 333 |
> |
allocate(molMembershipList(nGlobal), stat=alloc_stat) |
| 334 |
|
if (alloc_stat /= 0 ) then |
| 335 |
|
thisStat = -1 |
| 336 |
|
return |
| 341 |
|
subroutine FreeSimGlobals() |
| 342 |
|
|
| 343 |
|
!We free in the opposite order in which we allocate in. |
| 344 |
< |
|
| 344 |
> |
|
| 345 |
> |
if (allocated(molMembershipList)) deallocate(molMembershipList) |
| 346 |
|
if (allocated(excludesGlobal)) deallocate(excludesGlobal) |
| 347 |
|
if (allocated(excludesLocal)) deallocate(excludesLocal) |
| 348 |
< |
if (allocated(molMembershipList)) deallocate(molMembershipList) |
| 348 |
> |
|
| 349 |
|
end subroutine FreeSimGlobals |
| 350 |
|
|
| 351 |
< |
pure function getNlocal() result(nlocal) |
| 352 |
< |
integer :: nlocal |
| 353 |
< |
nlocal = natoms |
| 351 |
> |
pure function getNlocal() result(n) |
| 352 |
> |
integer :: n |
| 353 |
> |
n = nLocal |
| 354 |
|
end function getNlocal |
| 355 |
|
|
| 356 |
|
|