| 6 |
|
use force_globals |
| 7 |
|
use vector_class |
| 8 |
|
use atype_module |
| 9 |
– |
use lj |
| 9 |
|
#ifdef IS_MPI |
| 10 |
|
use mpiSimulation |
| 11 |
|
#endif |
| 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 |
| 67 |
|
|
| 68 |
|
contains |
| 69 |
|
|
| 70 |
< |
subroutine SimulationSetup(setThisSim, nComponents, c_idents, & |
| 70 |
> |
subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & |
| 71 |
|
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
| 72 |
+ |
CmolMembership, & |
| 73 |
|
status) |
| 74 |
|
|
| 75 |
|
type (simtype) :: setThisSim |
| 76 |
< |
integer, intent(inout) :: nComponents |
| 77 |
< |
integer, dimension(nComponents),intent(inout) :: c_idents |
| 76 |
> |
integer, intent(inout) :: CnGlobal, CnLocal |
| 77 |
> |
integer, dimension(CnLocal),intent(inout) :: c_idents |
| 78 |
|
|
| 79 |
|
integer :: CnLocalExcludes |
| 80 |
|
integer, dimension(2,CnLocalExcludes), intent(in) :: CexcludesLocal |
| 81 |
|
integer :: CnGlobalExcludes |
| 82 |
|
integer, dimension(CnGlobalExcludes), intent(in) :: CexcludesGlobal |
| 83 |
+ |
integer, dimension(CnGlobal),intent(in) :: CmolMembership |
| 84 |
|
!! Result status, success = 0, status = -1 |
| 85 |
|
integer, intent(out) :: status |
| 86 |
|
integer :: i, me, thisStat, alloc_stat, myNode |
| 95 |
|
status = 0 |
| 96 |
|
|
| 97 |
|
! copy C struct into fortran type |
| 98 |
+ |
|
| 99 |
+ |
nLocal = CnLocal |
| 100 |
+ |
nGlobal = CnGlobal |
| 101 |
+ |
|
| 102 |
|
thisSim = setThisSim |
| 97 |
– |
natoms = nComponents |
| 103 |
|
rcut2 = thisSim%rcut * thisSim%rcut |
| 104 |
|
rcut6 = rcut2 * rcut2 * rcut2 |
| 105 |
|
rlist2 = thisSim%rlist * thisSim%rlist |
| 108 |
|
nExcludes_Global = CnGlobalExcludes |
| 109 |
|
nExcludes_Local = CnLocalExcludes |
| 110 |
|
|
| 111 |
< |
call InitializeForceGlobals(natoms, thisStat) |
| 111 |
> |
call InitializeForceGlobals(nLocal, thisStat) |
| 112 |
|
if (thisStat /= 0) then |
| 113 |
+ |
write(default_error,*) "SimSetup: InitializeForceGlobals error" |
| 114 |
|
status = -1 |
| 115 |
|
return |
| 116 |
|
endif |
| 117 |
|
|
| 118 |
|
call InitializeSimGlobals(thisStat) |
| 119 |
|
if (thisStat /= 0) then |
| 120 |
+ |
write(default_error,*) "SimSetup: InitializeSimGlobals error" |
| 121 |
|
status = -1 |
| 122 |
|
return |
| 123 |
|
endif |
| 167 |
|
endif |
| 168 |
|
|
| 169 |
|
#else |
| 170 |
< |
do i = 1, nComponents |
| 170 |
> |
do i = 1, nLocal |
| 171 |
|
|
| 172 |
|
me = getFirstMatchingElement(atypes, "c_ident", c_idents(i)) |
| 173 |
|
atid(i) = me |
| 175 |
|
enddo |
| 176 |
|
#endif |
| 177 |
|
|
| 171 |
– |
!! Create neighbor lists |
| 172 |
– |
call expandNeighborList(nComponents, thisStat) |
| 173 |
– |
if (thisStat /= 0) then |
| 174 |
– |
status = -1 |
| 175 |
– |
return |
| 176 |
– |
endif |
| 178 |
|
|
| 179 |
+ |
|
| 180 |
|
do i = 1, nExcludes_Local |
| 181 |
|
excludesLocal(1,i) = CexcludesLocal(1,i) |
| 182 |
|
excludesLocal(2,i) = CexcludesLocal(2,i) |
| 185 |
|
do i = 1, nExcludes_Global |
| 186 |
|
excludesGlobal(i) = CexcludesGlobal(i) |
| 187 |
|
enddo |
| 188 |
< |
|
| 188 |
> |
|
| 189 |
> |
do i = 1, nGlobal |
| 190 |
> |
molMemberShipList(i) = CmolMembership(i) |
| 191 |
> |
enddo |
| 192 |
> |
|
| 193 |
|
if (status == 0) simulation_setup_complete = .true. |
| 194 |
|
|
| 195 |
|
end subroutine SimulationSetup |
| 201 |
|
thisSim%box = new_box_size |
| 202 |
|
box = thisSim%box |
| 203 |
|
|
| 198 |
– |
smallest = 1 |
| 199 |
– |
do i = 2, 3 |
| 200 |
– |
if (new_box_size(i) .lt. new_box_size(smallest)) smallest = i |
| 201 |
– |
end do |
| 202 |
– |
if (thisSim%rcut .gt. 0.5_dp * new_box_size(smallest)) & |
| 203 |
– |
call setRcut(0.5_dp * new_box_size(smallest), status) |
| 204 |
|
return |
| 205 |
|
end subroutine setBox_3d |
| 206 |
|
|
| 209 |
|
real(kind=dp) :: new_box_size |
| 210 |
|
thisSim%box(dim) = new_box_size |
| 211 |
|
box(dim) = thisSim%box(dim) |
| 212 |
– |
if (thisSim%rcut .gt. 0.5_dp * new_box_size) & |
| 213 |
– |
call setRcut(0.5_dp * new_box_size, status) |
| 212 |
|
end subroutine setBox_1d |
| 213 |
|
|
| 214 |
|
subroutine setRcut(new_rcut, status) |
| 217 |
|
thisSim%rcut = new_rcut |
| 218 |
|
rcut2 = thisSim%rcut * thisSim%rcut |
| 219 |
|
rcut6 = rcut2 * rcut2 * rcut2 |
| 222 |
– |
myStatus = 0 |
| 223 |
– |
call LJ_new_rcut(new_rcut, myStatus) |
| 224 |
– |
if (myStatus .ne. 0) then |
| 225 |
– |
write(default_error, *) 'LJ module refused our rcut!' |
| 226 |
– |
status = -1 |
| 227 |
– |
return |
| 228 |
– |
endif |
| 220 |
|
status = 0 |
| 221 |
|
return |
| 222 |
|
end subroutine setRcut |
| 271 |
|
function getRrf() result(rrf) |
| 272 |
|
real( kind = dp ) :: rrf |
| 273 |
|
rrf = thisSim%rrf |
| 274 |
+ |
write(*,*) 'getRrf = ', rrf, thisSim%rrf |
| 275 |
|
end function getRrf |
| 276 |
|
|
| 277 |
|
function getRt() result(rt) |
| 354 |
|
thisStat = -1 |
| 355 |
|
return |
| 356 |
|
endif |
| 357 |
+ |
|
| 358 |
+ |
allocate(molMembershipList(nGlobal), stat=alloc_stat) |
| 359 |
+ |
if (alloc_stat /= 0 ) then |
| 360 |
+ |
thisStat = -1 |
| 361 |
+ |
return |
| 362 |
+ |
endif |
| 363 |
|
|
| 364 |
|
end subroutine InitializeSimGlobals |
| 365 |
|
|
| 366 |
|
subroutine FreeSimGlobals() |
| 367 |
|
|
| 368 |
|
!We free in the opposite order in which we allocate in. |
| 369 |
< |
|
| 369 |
> |
|
| 370 |
> |
if (allocated(molMembershipList)) deallocate(molMembershipList) |
| 371 |
|
if (allocated(excludesGlobal)) deallocate(excludesGlobal) |
| 372 |
|
if (allocated(excludesLocal)) deallocate(excludesLocal) |
| 373 |
|
|
| 374 |
|
end subroutine FreeSimGlobals |
| 375 |
|
|
| 376 |
< |
pure function getNlocal() result(nlocal) |
| 377 |
< |
integer :: nlocal |
| 378 |
< |
nlocal = natoms |
| 376 |
> |
pure function getNlocal() result(n) |
| 377 |
> |
integer :: n |
| 378 |
> |
n = nLocal |
| 379 |
|
end function getNlocal |
| 380 |
|
|
| 381 |
|
|