| 16 |
|
#define __FORTRAN90 |
| 17 |
|
#include "fSimulation.h" |
| 18 |
|
|
| 19 |
< |
type (simtype), public :: thisSim |
| 19 |
> |
type (simtype), public, save :: thisSim |
| 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 |
| 31 |
< |
real(kind=dp), save :: rlist2 = 0.0_DP |
| 32 |
< |
real(kind=dp), public, dimension(3), save :: box |
| 33 |
< |
|
| 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 |
| 38 |
– |
public :: setBox_3d |
| 39 |
– |
public :: getBox |
| 40 |
– |
public :: setRcut |
| 41 |
– |
public :: getRcut |
| 42 |
– |
public :: getRlist |
| 43 |
– |
public :: getRrf |
| 44 |
– |
public :: getRt |
| 36 |
|
public :: getDielect |
| 37 |
|
public :: SimUsesPBC |
| 38 |
|
public :: SimUsesLJ |
| 39 |
+ |
public :: SimUsesCharges |
| 40 |
|
public :: SimUsesDipoles |
| 41 |
|
public :: SimUsesSticky |
| 42 |
|
public :: SimUsesRF |
| 45 |
|
public :: SimRequiresPrepairCalc |
| 46 |
|
public :: SimRequiresPostpairCalc |
| 47 |
|
public :: SimUsesDirectionalAtoms |
| 56 |
– |
|
| 57 |
– |
interface getBox |
| 58 |
– |
module procedure getBox_3d |
| 59 |
– |
module procedure getBox_1d |
| 60 |
– |
end interface |
| 48 |
|
|
| 62 |
– |
interface setBox |
| 63 |
– |
module procedure setBox_3d |
| 64 |
– |
module procedure setBox_1d |
| 65 |
– |
end interface |
| 66 |
– |
|
| 49 |
|
contains |
| 50 |
|
|
| 51 |
< |
subroutine SimulationSetup(setThisSim, nComponents, c_idents, & |
| 51 |
> |
subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & |
| 52 |
|
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
| 53 |
+ |
CmolMembership, mfact, ngroup, groupList, groupStart, & |
| 54 |
|
status) |
| 55 |
|
|
| 56 |
|
type (simtype) :: setThisSim |
| 57 |
< |
integer, intent(inout) :: nComponents |
| 58 |
< |
integer, dimension(nComponents),intent(inout) :: c_idents |
| 57 |
> |
integer, intent(inout) :: CnGlobal, CnLocal |
| 58 |
> |
integer, dimension(CnLocal),intent(inout) :: c_idents |
| 59 |
|
|
| 60 |
|
integer :: CnLocalExcludes |
| 61 |
|
integer, dimension(2,CnLocalExcludes), intent(in) :: CexcludesLocal |
| 62 |
|
integer :: CnGlobalExcludes |
| 63 |
|
integer, dimension(CnGlobalExcludes), intent(in) :: CexcludesGlobal |
| 64 |
+ |
integer, dimension(CnGlobal),intent(in) :: CmolMembership |
| 65 |
|
!! Result status, success = 0, status = -1 |
| 66 |
|
integer, intent(out) :: status |
| 67 |
|
integer :: i, me, thisStat, alloc_stat, myNode |
| 68 |
+ |
|
| 69 |
+ |
!! mass factors used for molecular cutoffs |
| 70 |
+ |
real ( kind = dp ), dimension(3,nLocal) :: mfact |
| 71 |
+ |
integer, intent(in):: ngroup |
| 72 |
+ |
integer, dimension(nLocal),intent(in) :: groupList |
| 73 |
+ |
integer, dimension(ngroup),intent(in) :: groupStart |
| 74 |
+ |
|
| 75 |
|
#ifdef IS_MPI |
| 76 |
|
integer, allocatable, dimension(:) :: c_idents_Row |
| 77 |
|
integer, allocatable, dimension(:) :: c_idents_Col |
| 83 |
|
status = 0 |
| 84 |
|
|
| 85 |
|
! copy C struct into fortran type |
| 86 |
+ |
|
| 87 |
+ |
nLocal = CnLocal |
| 88 |
+ |
nGlobal = CnGlobal |
| 89 |
+ |
|
| 90 |
|
thisSim = setThisSim |
| 96 |
– |
natoms = nComponents |
| 97 |
– |
rcut2 = thisSim%rcut * thisSim%rcut |
| 98 |
– |
rcut6 = rcut2 * rcut2 * rcut2 |
| 99 |
– |
rlist2 = thisSim%rlist * thisSim%rlist |
| 100 |
– |
box = thisSim%box |
| 91 |
|
|
| 92 |
|
nExcludes_Global = CnGlobalExcludes |
| 93 |
|
nExcludes_Local = CnLocalExcludes |
| 94 |
|
|
| 95 |
< |
call InitializeForceGlobals(natoms, thisStat) |
| 95 |
> |
call InitializeForceGlobals(nLocal, thisStat) |
| 96 |
|
if (thisStat /= 0) then |
| 97 |
|
write(default_error,*) "SimSetup: InitializeForceGlobals error" |
| 98 |
|
status = -1 |
| 150 |
|
deallocate(c_idents_Row) |
| 151 |
|
endif |
| 152 |
|
|
| 153 |
< |
#else |
| 154 |
< |
do i = 1, nComponents |
| 153 |
> |
#endif |
| 154 |
> |
|
| 155 |
> |
! We build the local atid's for both mpi and nonmpi |
| 156 |
> |
do i = 1, nLocal |
| 157 |
|
|
| 158 |
|
me = getFirstMatchingElement(atypes, "c_ident", c_idents(i)) |
| 159 |
|
atid(i) = me |
| 160 |
|
|
| 161 |
|
enddo |
| 170 |
– |
#endif |
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
+ |
|
| 166 |
|
do i = 1, nExcludes_Local |
| 167 |
|
excludesLocal(1,i) = CexcludesLocal(1,i) |
| 168 |
|
excludesLocal(2,i) = CexcludesLocal(2,i) |
| 172 |
|
excludesGlobal(i) = CexcludesGlobal(i) |
| 173 |
|
enddo |
| 174 |
|
|
| 175 |
+ |
do i = 1, nGlobal |
| 176 |
+ |
molMemberShipList(i) = CmolMembership(i) |
| 177 |
+ |
enddo |
| 178 |
+ |
|
| 179 |
|
if (status == 0) simulation_setup_complete = .true. |
| 180 |
|
|
| 181 |
|
end subroutine SimulationSetup |
| 182 |
|
|
| 183 |
< |
subroutine setBox_3d(new_box_size) |
| 184 |
< |
real(kind=dp), dimension(3) :: new_box_size |
| 183 |
> |
subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
| 184 |
> |
real(kind=dp), dimension(3,3) :: cHmat, cHmatInv |
| 185 |
> |
integer :: cBoxIsOrthorhombic |
| 186 |
|
integer :: smallest, status, i |
| 187 |
< |
|
| 188 |
< |
thisSim%box = new_box_size |
| 189 |
< |
box = thisSim%box |
| 190 |
< |
|
| 187 |
> |
|
| 188 |
> |
Hmat = cHmat |
| 189 |
> |
HmatInv = cHmatInv |
| 190 |
> |
if (cBoxIsOrthorhombic .eq. 0 ) then |
| 191 |
> |
boxIsOrthorhombic = .false. |
| 192 |
> |
else |
| 193 |
> |
boxIsOrthorhombic = .true. |
| 194 |
> |
endif |
| 195 |
> |
|
| 196 |
|
return |
| 197 |
< |
end subroutine setBox_3d |
| 196 |
< |
|
| 197 |
< |
subroutine setBox_1d(dim, new_box_size) |
| 198 |
< |
integer :: dim, status |
| 199 |
< |
real(kind=dp) :: new_box_size |
| 200 |
< |
thisSim%box(dim) = new_box_size |
| 201 |
< |
box(dim) = thisSim%box(dim) |
| 202 |
< |
end subroutine setBox_1d |
| 197 |
> |
end subroutine setBox |
| 198 |
|
|
| 204 |
– |
subroutine setRcut(new_rcut, status) |
| 205 |
– |
real(kind = dp) :: new_rcut |
| 206 |
– |
integer :: myStatus, status |
| 207 |
– |
thisSim%rcut = new_rcut |
| 208 |
– |
rcut2 = thisSim%rcut * thisSim%rcut |
| 209 |
– |
rcut6 = rcut2 * rcut2 * rcut2 |
| 210 |
– |
status = 0 |
| 211 |
– |
return |
| 212 |
– |
end subroutine setRcut |
| 213 |
– |
|
| 214 |
– |
function getBox_3d() result(thisBox) |
| 215 |
– |
real( kind = dp ), dimension(3) :: thisBox |
| 216 |
– |
thisBox = thisSim%box |
| 217 |
– |
end function getBox_3d |
| 218 |
– |
|
| 219 |
– |
function getBox_1d(dim) result(thisBox) |
| 220 |
– |
integer, intent(in) :: dim |
| 221 |
– |
real( kind = dp ) :: thisBox |
| 222 |
– |
|
| 223 |
– |
thisBox = thisSim%box(dim) |
| 224 |
– |
end function getBox_1d |
| 225 |
– |
|
| 226 |
– |
subroutine getRcut(thisrcut,rc2,rc6,status) |
| 227 |
– |
real( kind = dp ), intent(out) :: thisrcut |
| 228 |
– |
real( kind = dp ), intent(out), optional :: rc2 |
| 229 |
– |
real( kind = dp ), intent(out), optional :: rc6 |
| 230 |
– |
integer, optional :: status |
| 231 |
– |
|
| 232 |
– |
if (present(status)) status = 0 |
| 233 |
– |
|
| 234 |
– |
if (.not.simulation_setup_complete ) then |
| 235 |
– |
if (present(status)) status = -1 |
| 236 |
– |
return |
| 237 |
– |
end if |
| 238 |
– |
|
| 239 |
– |
thisrcut = thisSim%rcut |
| 240 |
– |
if(present(rc2)) rc2 = rcut2 |
| 241 |
– |
if(present(rc6)) rc6 = rcut6 |
| 242 |
– |
end subroutine getRcut |
| 243 |
– |
|
| 244 |
– |
subroutine getRlist(thisrlist,rl2,status) |
| 245 |
– |
real( kind = dp ), intent(out) :: thisrlist |
| 246 |
– |
real( kind = dp ), intent(out), optional :: rl2 |
| 247 |
– |
|
| 248 |
– |
integer, optional :: status |
| 249 |
– |
|
| 250 |
– |
if (present(status)) status = 0 |
| 251 |
– |
|
| 252 |
– |
if (.not.simulation_setup_complete ) then |
| 253 |
– |
if (present(status)) status = -1 |
| 254 |
– |
return |
| 255 |
– |
end if |
| 256 |
– |
|
| 257 |
– |
thisrlist = thisSim%rlist |
| 258 |
– |
if(present(rl2)) rl2 = rlist2 |
| 259 |
– |
end subroutine getRlist |
| 260 |
– |
|
| 261 |
– |
function getRrf() result(rrf) |
| 262 |
– |
real( kind = dp ) :: rrf |
| 263 |
– |
rrf = thisSim%rrf |
| 264 |
– |
write(*,*) 'getRrf = ', rrf, thisSim%rrf |
| 265 |
– |
end function getRrf |
| 266 |
– |
|
| 267 |
– |
function getRt() result(rt) |
| 268 |
– |
real( kind = dp ) :: rt |
| 269 |
– |
rt = thisSim%rt |
| 270 |
– |
end function getRt |
| 271 |
– |
|
| 199 |
|
function getDielect() result(dielect) |
| 200 |
|
real( kind = dp ) :: dielect |
| 201 |
|
dielect = thisSim%dielect |
| 216 |
|
doesit = thisSim%SIM_uses_sticky |
| 217 |
|
end function SimUsesSticky |
| 218 |
|
|
| 219 |
+ |
function SimUsesCharges() result(doesit) |
| 220 |
+ |
logical :: doesit |
| 221 |
+ |
doesit = thisSim%SIM_uses_charges |
| 222 |
+ |
end function SimUsesCharges |
| 223 |
+ |
|
| 224 |
|
function SimUsesDipoles() result(doesit) |
| 225 |
|
logical :: doesit |
| 226 |
|
doesit = thisSim%SIM_uses_dipoles |
| 276 |
|
thisStat = -1 |
| 277 |
|
return |
| 278 |
|
endif |
| 279 |
+ |
|
| 280 |
+ |
allocate(molMembershipList(nGlobal), stat=alloc_stat) |
| 281 |
+ |
if (alloc_stat /= 0 ) then |
| 282 |
+ |
thisStat = -1 |
| 283 |
+ |
return |
| 284 |
+ |
endif |
| 285 |
|
|
| 286 |
|
end subroutine InitializeSimGlobals |
| 287 |
|
|
| 288 |
|
subroutine FreeSimGlobals() |
| 289 |
|
|
| 290 |
|
!We free in the opposite order in which we allocate in. |
| 291 |
< |
|
| 291 |
> |
|
| 292 |
> |
if (allocated(molMembershipList)) deallocate(molMembershipList) |
| 293 |
|
if (allocated(excludesGlobal)) deallocate(excludesGlobal) |
| 294 |
|
if (allocated(excludesLocal)) deallocate(excludesLocal) |
| 295 |
|
|
| 296 |
|
end subroutine FreeSimGlobals |
| 297 |
|
|
| 298 |
< |
pure function getNlocal() result(nlocal) |
| 299 |
< |
integer :: nlocal |
| 300 |
< |
nlocal = natoms |
| 298 |
> |
pure function getNlocal() result(n) |
| 299 |
> |
integer :: n |
| 300 |
> |
n = nLocal |
| 301 |
|
end function getNlocal |
| 302 |
|
|
| 303 |
|
|