1 |
+ |
!! |
2 |
+ |
!! Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
+ |
!! |
4 |
+ |
!! The University of Notre Dame grants you ("Licensee") a |
5 |
+ |
!! non-exclusive, royalty free, license to use, modify and |
6 |
+ |
!! redistribute this software in source and binary code form, provided |
7 |
+ |
!! that the following conditions are met: |
8 |
+ |
!! |
9 |
+ |
!! 1. Acknowledgement of the program authors must be made in any |
10 |
+ |
!! publication of scientific results based in part on use of the |
11 |
+ |
!! program. An acceptable form of acknowledgement is citation of |
12 |
+ |
!! the article in which the program was described (Matthew |
13 |
+ |
!! A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
+ |
!! J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
+ |
!! Parallel Simulation Engine for Molecular Dynamics," |
16 |
+ |
!! J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
+ |
!! |
18 |
+ |
!! 2. Redistributions of source code must retain the above copyright |
19 |
+ |
!! notice, this list of conditions and the following disclaimer. |
20 |
+ |
!! |
21 |
+ |
!! 3. Redistributions in binary form must reproduce the above copyright |
22 |
+ |
!! notice, this list of conditions and the following disclaimer in the |
23 |
+ |
!! documentation and/or other materials provided with the |
24 |
+ |
!! distribution. |
25 |
+ |
!! |
26 |
+ |
!! This software is provided "AS IS," without a warranty of any |
27 |
+ |
!! kind. All express or implied conditions, representations and |
28 |
+ |
!! warranties, including any implied warranty of merchantability, |
29 |
+ |
!! fitness for a particular purpose or non-infringement, are hereby |
30 |
+ |
!! excluded. The University of Notre Dame and its licensors shall not |
31 |
+ |
!! be liable for any damages suffered by licensee as a result of |
32 |
+ |
!! using, modifying or distributing the software or its |
33 |
+ |
!! derivatives. In no event will the University of Notre Dame or its |
34 |
+ |
!! licensors be liable for any lost revenue, profit or data, or for |
35 |
+ |
!! direct, indirect, special, consequential, incidental or punitive |
36 |
+ |
!! damages, however caused and regardless of the theory of liability, |
37 |
+ |
!! arising out of the use of or inability to use software, even if the |
38 |
+ |
!! University of Notre Dame has been advised of the possibility of |
39 |
+ |
!! such damages. |
40 |
+ |
!! |
41 |
+ |
|
42 |
|
!! Fortran interface to C entry plug. |
43 |
|
|
44 |
|
module simulation |
58 |
|
#define __FORTRAN90 |
59 |
|
#include "brains/fSimulation.h" |
60 |
|
#include "UseTheForce/fSwitchingFunction.h" |
61 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
62 |
|
|
63 |
|
type (simtype), public, save :: thisSim |
64 |
|
|
83 |
|
real(kind=dp), allocatable, dimension(:), public :: mfactCol |
84 |
|
real(kind=dp), allocatable, dimension(:), public :: mfactLocal |
85 |
|
|
86 |
+ |
logical, allocatable, dimension(:) :: simHasAtypeMap |
87 |
+ |
#ifdef IS_MPI |
88 |
+ |
logical, allocatable, dimension(:) :: simHasAtypeMapTemp |
89 |
+ |
#endif |
90 |
+ |
|
91 |
|
real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv |
92 |
|
logical, public, save :: boxIsOrthorhombic |
93 |
< |
|
93 |
> |
|
94 |
|
public :: SimulationSetup |
95 |
|
public :: getNlocal |
96 |
|
public :: setBox |
97 |
|
public :: getDielect |
98 |
|
public :: SimUsesPBC |
99 |
< |
public :: SimUsesLJ |
99 |
> |
|
100 |
> |
public :: SimUsesDirectionalAtoms |
101 |
> |
public :: SimUsesLennardJones |
102 |
> |
public :: SimUsesElectrostatics |
103 |
|
public :: SimUsesCharges |
104 |
|
public :: SimUsesDipoles |
105 |
|
public :: SimUsesSticky |
106 |
< |
public :: SimUsesRF |
107 |
< |
public :: SimUsesGB |
106 |
> |
public :: SimUsesStickyPower |
107 |
> |
public :: SimUsesGayBerne |
108 |
|
public :: SimUsesEAM |
109 |
+ |
public :: SimUsesShapes |
110 |
+ |
public :: SimUsesFLARB |
111 |
+ |
public :: SimUsesRF |
112 |
+ |
public :: SimUsesDampedWolf |
113 |
|
public :: SimRequiresPrepairCalc |
114 |
|
public :: SimRequiresPostpairCalc |
115 |
< |
public :: SimUsesDirectionalAtoms |
116 |
< |
|
115 |
> |
public :: SimHasAtype |
116 |
> |
|
117 |
|
contains |
118 |
< |
|
118 |
> |
|
119 |
|
subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & |
120 |
|
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
121 |
|
CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, & |
188 |
|
nGroupsInRow = getNgroupsInRow(plan_group_row) |
189 |
|
nGroupsInCol = getNgroupsInCol(plan_group_col) |
190 |
|
mynode = getMyNode() |
191 |
< |
|
191 |
> |
|
192 |
|
allocate(c_idents_Row(nAtomsInRow),stat=alloc_stat) |
193 |
|
if (alloc_stat /= 0 ) then |
194 |
|
status = -1 |
221 |
|
if (allocated(c_idents_Row)) then |
222 |
|
deallocate(c_idents_Row) |
223 |
|
endif |
224 |
< |
|
224 |
> |
|
225 |
|
#endif |
226 |
|
|
227 |
|
#ifdef IS_MPI |
260 |
|
status = -1 |
261 |
|
return |
262 |
|
endif |
263 |
< |
|
263 |
> |
|
264 |
|
glPointer = 1 |
265 |
|
|
266 |
|
do i = 1, nGroupsInRow |
299 |
|
|
300 |
|
call gather(mfactLocal, mfactRow, plan_atom_row) |
301 |
|
call gather(mfactLocal, mfactCol, plan_atom_col) |
302 |
< |
|
302 |
> |
|
303 |
|
if (allocated(mfactLocal)) then |
304 |
|
deallocate(mfactLocal) |
305 |
|
end if |
359 |
|
mfactRow(i) = Cmfact(i) |
360 |
|
mfactCol(i) = Cmfact(i) |
361 |
|
end do |
362 |
< |
|
362 |
> |
|
363 |
|
#endif |
364 |
|
|
365 |
|
|
366 |
< |
! We build the local atid's for both mpi and nonmpi |
366 |
> |
! We build the local atid's for both mpi and nonmpi |
367 |
|
do i = 1, nLocal |
368 |
< |
|
368 |
> |
|
369 |
|
me = getFirstMatchingElement(atypes, "c_ident", c_idents(i)) |
370 |
|
atid(i) = me |
371 |
< |
|
371 |
> |
|
372 |
|
enddo |
373 |
|
|
374 |
|
do i = 1, nExcludes_Local |
391 |
|
#ifdef IS_MPI |
392 |
|
do j = 1, nAtomsInRow |
393 |
|
#else |
394 |
< |
do j = 1, nLocal |
394 |
> |
do j = 1, nLocal |
395 |
|
#endif |
396 |
< |
nSkipsForAtom(j) = 0 |
396 |
> |
nSkipsForAtom(j) = 0 |
397 |
|
#ifdef IS_MPI |
398 |
< |
id1 = AtomRowToGlobal(j) |
399 |
< |
#else |
400 |
< |
id1 = j |
398 |
> |
id1 = AtomRowToGlobal(j) |
399 |
> |
#else |
400 |
> |
id1 = j |
401 |
|
#endif |
402 |
< |
do i = 1, nExcludes_Local |
403 |
< |
if (excludesLocal(1,i) .eq. id1 ) then |
404 |
< |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
402 |
> |
do i = 1, nExcludes_Local |
403 |
> |
if (excludesLocal(1,i) .eq. id1 ) then |
404 |
> |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
405 |
|
|
406 |
< |
if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then |
407 |
< |
maxSkipsForAtom = nSkipsForAtom(j) |
406 |
> |
if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then |
407 |
> |
maxSkipsForAtom = nSkipsForAtom(j) |
408 |
> |
endif |
409 |
|
endif |
410 |
< |
endif |
411 |
< |
if (excludesLocal(2,i) .eq. id1 ) then |
357 |
< |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
410 |
> |
if (excludesLocal(2,i) .eq. id1 ) then |
411 |
> |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
412 |
|
|
413 |
< |
if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then |
414 |
< |
maxSkipsForAtom = nSkipsForAtom(j) |
413 |
> |
if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then |
414 |
> |
maxSkipsForAtom = nSkipsForAtom(j) |
415 |
> |
endif |
416 |
|
endif |
417 |
< |
endif |
418 |
< |
end do |
364 |
< |
enddo |
417 |
> |
end do |
418 |
> |
enddo |
419 |
|
|
420 |
|
#ifdef IS_MPI |
421 |
< |
allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat) |
421 |
> |
allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat) |
422 |
|
#else |
423 |
< |
allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat) |
423 |
> |
allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat) |
424 |
|
#endif |
425 |
< |
if (alloc_stat /= 0 ) then |
426 |
< |
write(*,*) 'Could not allocate skipsForAtom array' |
427 |
< |
return |
428 |
< |
endif |
425 |
> |
if (alloc_stat /= 0 ) then |
426 |
> |
write(*,*) 'Could not allocate skipsForAtom array' |
427 |
> |
return |
428 |
> |
endif |
429 |
|
|
430 |
|
#ifdef IS_MPI |
431 |
< |
do j = 1, nAtomsInRow |
431 |
> |
do j = 1, nAtomsInRow |
432 |
|
#else |
433 |
< |
do j = 1, nLocal |
433 |
> |
do j = 1, nLocal |
434 |
|
#endif |
435 |
< |
nSkipsForAtom(j) = 0 |
435 |
> |
nSkipsForAtom(j) = 0 |
436 |
|
#ifdef IS_MPI |
437 |
< |
id1 = AtomRowToGlobal(j) |
437 |
> |
id1 = AtomRowToGlobal(j) |
438 |
|
#else |
439 |
< |
id1 = j |
439 |
> |
id1 = j |
440 |
|
#endif |
441 |
< |
do i = 1, nExcludes_Local |
442 |
< |
if (excludesLocal(1,i) .eq. id1 ) then |
443 |
< |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
444 |
< |
! exclude lists have global ID's so this line is |
445 |
< |
! the same in MPI and non-MPI |
446 |
< |
id2 = excludesLocal(2,i) |
447 |
< |
skipsForAtom(j, nSkipsForAtom(j)) = id2 |
448 |
< |
endif |
449 |
< |
if (excludesLocal(2, i) .eq. id1 ) then |
450 |
< |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
451 |
< |
! exclude lists have global ID's so this line is |
452 |
< |
! the same in MPI and non-MPI |
453 |
< |
id2 = excludesLocal(1,i) |
454 |
< |
skipsForAtom(j, nSkipsForAtom(j)) = id2 |
455 |
< |
endif |
456 |
< |
end do |
457 |
< |
enddo |
404 |
< |
|
405 |
< |
do i = 1, nExcludes_Global |
406 |
< |
excludesGlobal(i) = CexcludesGlobal(i) |
407 |
< |
enddo |
441 |
> |
do i = 1, nExcludes_Local |
442 |
> |
if (excludesLocal(1,i) .eq. id1 ) then |
443 |
> |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
444 |
> |
! exclude lists have global ID's so this line is |
445 |
> |
! the same in MPI and non-MPI |
446 |
> |
id2 = excludesLocal(2,i) |
447 |
> |
skipsForAtom(j, nSkipsForAtom(j)) = id2 |
448 |
> |
endif |
449 |
> |
if (excludesLocal(2, i) .eq. id1 ) then |
450 |
> |
nSkipsForAtom(j) = nSkipsForAtom(j) + 1 |
451 |
> |
! exclude lists have global ID's so this line is |
452 |
> |
! the same in MPI and non-MPI |
453 |
> |
id2 = excludesLocal(1,i) |
454 |
> |
skipsForAtom(j, nSkipsForAtom(j)) = id2 |
455 |
> |
endif |
456 |
> |
end do |
457 |
> |
enddo |
458 |
|
|
459 |
< |
do i = 1, nGlobal |
460 |
< |
molMemberShipList(i) = CmolMembership(i) |
461 |
< |
enddo |
412 |
< |
|
413 |
< |
if (status == 0) simulation_setup_complete = .true. |
414 |
< |
|
415 |
< |
end subroutine SimulationSetup |
416 |
< |
|
417 |
< |
subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
418 |
< |
real(kind=dp), dimension(3,3) :: cHmat, cHmatInv |
419 |
< |
integer :: cBoxIsOrthorhombic |
420 |
< |
integer :: smallest, status, i |
421 |
< |
|
422 |
< |
Hmat = cHmat |
423 |
< |
HmatInv = cHmatInv |
424 |
< |
if (cBoxIsOrthorhombic .eq. 0 ) then |
425 |
< |
boxIsOrthorhombic = .false. |
426 |
< |
else |
427 |
< |
boxIsOrthorhombic = .true. |
428 |
< |
endif |
429 |
< |
|
430 |
< |
return |
431 |
< |
end subroutine setBox |
459 |
> |
do i = 1, nExcludes_Global |
460 |
> |
excludesGlobal(i) = CexcludesGlobal(i) |
461 |
> |
enddo |
462 |
|
|
463 |
< |
function getDielect() result(dielect) |
464 |
< |
real( kind = dp ) :: dielect |
465 |
< |
dielect = thisSim%dielect |
436 |
< |
end function getDielect |
437 |
< |
|
438 |
< |
function SimUsesPBC() result(doesit) |
439 |
< |
logical :: doesit |
440 |
< |
doesit = thisSim%SIM_uses_PBC |
441 |
< |
end function SimUsesPBC |
463 |
> |
do i = 1, nGlobal |
464 |
> |
molMemberShipList(i) = CmolMembership(i) |
465 |
> |
enddo |
466 |
|
|
467 |
< |
function SimUsesLJ() result(doesit) |
468 |
< |
logical :: doesit |
469 |
< |
doesit = thisSim%SIM_uses_LJ |
470 |
< |
end function SimUsesLJ |
467 |
> |
call createSimHasAtype(alloc_stat) |
468 |
> |
if (alloc_stat /= 0) then |
469 |
> |
status = -1 |
470 |
> |
end if |
471 |
> |
|
472 |
> |
if (status == 0) simulation_setup_complete = .true. |
473 |
|
|
474 |
< |
function SimUsesSticky() result(doesit) |
449 |
< |
logical :: doesit |
450 |
< |
doesit = thisSim%SIM_uses_sticky |
451 |
< |
end function SimUsesSticky |
474 |
> |
end subroutine SimulationSetup |
475 |
|
|
476 |
< |
function SimUsesCharges() result(doesit) |
477 |
< |
logical :: doesit |
478 |
< |
doesit = thisSim%SIM_uses_charges |
479 |
< |
end function SimUsesCharges |
476 |
> |
subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
477 |
> |
real(kind=dp), dimension(3,3) :: cHmat, cHmatInv |
478 |
> |
integer :: cBoxIsOrthorhombic |
479 |
> |
integer :: smallest, status, i |
480 |
|
|
481 |
< |
function SimUsesDipoles() result(doesit) |
482 |
< |
logical :: doesit |
483 |
< |
doesit = thisSim%SIM_uses_dipoles |
484 |
< |
end function SimUsesDipoles |
481 |
> |
Hmat = cHmat |
482 |
> |
HmatInv = cHmatInv |
483 |
> |
if (cBoxIsOrthorhombic .eq. 0 ) then |
484 |
> |
boxIsOrthorhombic = .false. |
485 |
> |
else |
486 |
> |
boxIsOrthorhombic = .true. |
487 |
> |
endif |
488 |
|
|
489 |
< |
function SimUsesRF() result(doesit) |
490 |
< |
logical :: doesit |
465 |
< |
doesit = thisSim%SIM_uses_RF |
466 |
< |
end function SimUsesRF |
489 |
> |
return |
490 |
> |
end subroutine setBox |
491 |
|
|
492 |
< |
function SimUsesGB() result(doesit) |
493 |
< |
logical :: doesit |
494 |
< |
doesit = thisSim%SIM_uses_GB |
495 |
< |
end function SimUsesGB |
492 |
> |
function getDielect() result(dielect) |
493 |
> |
real( kind = dp ) :: dielect |
494 |
> |
dielect = thisSim%dielect |
495 |
> |
end function getDielect |
496 |
|
|
497 |
< |
function SimUsesEAM() result(doesit) |
498 |
< |
logical :: doesit |
499 |
< |
doesit = thisSim%SIM_uses_EAM |
500 |
< |
end function SimUsesEAM |
497 |
> |
function SimUsesPBC() result(doesit) |
498 |
> |
logical :: doesit |
499 |
> |
doesit = thisSim%SIM_uses_PBC |
500 |
> |
end function SimUsesPBC |
501 |
|
|
502 |
< |
function SimUsesDirectionalAtoms() result(doesit) |
503 |
< |
logical :: doesit |
504 |
< |
doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_sticky .or. & |
505 |
< |
thisSim%SIM_uses_GB .or. thisSim%SIM_uses_RF |
506 |
< |
end function SimUsesDirectionalAtoms |
502 |
> |
function SimUsesDirectionalAtoms() result(doesit) |
503 |
> |
logical :: doesit |
504 |
> |
doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_Sticky .or. & |
505 |
> |
thisSim%SIM_uses_StickyPower .or. & |
506 |
> |
thisSim%SIM_uses_GayBerne .or. thisSim%SIM_uses_Shapes |
507 |
> |
end function SimUsesDirectionalAtoms |
508 |
|
|
509 |
< |
function SimRequiresPrepairCalc() result(doesit) |
510 |
< |
logical :: doesit |
511 |
< |
doesit = thisSim%SIM_uses_EAM |
512 |
< |
end function SimRequiresPrepairCalc |
509 |
> |
function SimUsesLennardJones() result(doesit) |
510 |
> |
logical :: doesit |
511 |
> |
doesit = thisSim%SIM_uses_LennardJones |
512 |
> |
end function SimUsesLennardJones |
513 |
|
|
514 |
< |
function SimRequiresPostpairCalc() result(doesit) |
515 |
< |
logical :: doesit |
516 |
< |
doesit = thisSim%SIM_uses_RF |
517 |
< |
end function SimRequiresPostpairCalc |
493 |
< |
|
494 |
< |
subroutine InitializeSimGlobals(thisStat) |
495 |
< |
integer, intent(out) :: thisStat |
496 |
< |
integer :: alloc_stat |
497 |
< |
|
498 |
< |
thisStat = 0 |
499 |
< |
|
500 |
< |
call FreeSimGlobals() |
501 |
< |
|
502 |
< |
allocate(excludesLocal(2,nExcludes_Local), stat=alloc_stat) |
503 |
< |
if (alloc_stat /= 0 ) then |
504 |
< |
thisStat = -1 |
505 |
< |
return |
506 |
< |
endif |
507 |
< |
|
508 |
< |
allocate(excludesGlobal(nExcludes_Global), stat=alloc_stat) |
509 |
< |
if (alloc_stat /= 0 ) then |
510 |
< |
thisStat = -1 |
511 |
< |
return |
512 |
< |
endif |
514 |
> |
function SimUsesElectrostatics() result(doesit) |
515 |
> |
logical :: doesit |
516 |
> |
doesit = thisSim%SIM_uses_Electrostatics |
517 |
> |
end function SimUsesElectrostatics |
518 |
|
|
519 |
< |
allocate(molMembershipList(nGlobal), stat=alloc_stat) |
520 |
< |
if (alloc_stat /= 0 ) then |
521 |
< |
thisStat = -1 |
522 |
< |
return |
518 |
< |
endif |
519 |
< |
|
520 |
< |
end subroutine InitializeSimGlobals |
521 |
< |
|
522 |
< |
subroutine FreeSimGlobals() |
523 |
< |
|
524 |
< |
!We free in the opposite order in which we allocate in. |
519 |
> |
function SimUsesCharges() result(doesit) |
520 |
> |
logical :: doesit |
521 |
> |
doesit = thisSim%SIM_uses_Charges |
522 |
> |
end function SimUsesCharges |
523 |
|
|
524 |
< |
if (allocated(skipsForAtom)) deallocate(skipsForAtom) |
525 |
< |
if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom) |
526 |
< |
if (allocated(mfactLocal)) deallocate(mfactLocal) |
527 |
< |
if (allocated(mfactCol)) deallocate(mfactCol) |
530 |
< |
if (allocated(mfactRow)) deallocate(mfactRow) |
531 |
< |
if (allocated(groupListCol)) deallocate(groupListCol) |
532 |
< |
if (allocated(groupListRow)) deallocate(groupListRow) |
533 |
< |
if (allocated(groupStartCol)) deallocate(groupStartCol) |
534 |
< |
if (allocated(groupStartRow)) deallocate(groupStartRow) |
535 |
< |
if (allocated(molMembershipList)) deallocate(molMembershipList) |
536 |
< |
if (allocated(excludesGlobal)) deallocate(excludesGlobal) |
537 |
< |
if (allocated(excludesLocal)) deallocate(excludesLocal) |
538 |
< |
|
539 |
< |
end subroutine FreeSimGlobals |
540 |
< |
|
541 |
< |
pure function getNlocal() result(n) |
542 |
< |
integer :: n |
543 |
< |
n = nLocal |
544 |
< |
end function getNlocal |
545 |
< |
|
546 |
< |
|
547 |
< |
end module simulation |
524 |
> |
function SimUsesDipoles() result(doesit) |
525 |
> |
logical :: doesit |
526 |
> |
doesit = thisSim%SIM_uses_Dipoles |
527 |
> |
end function SimUsesDipoles |
528 |
|
|
529 |
+ |
function SimUsesSticky() result(doesit) |
530 |
+ |
logical :: doesit |
531 |
+ |
doesit = thisSim%SIM_uses_Sticky |
532 |
+ |
end function SimUsesSticky |
533 |
|
|
534 |
< |
subroutine setFortranSim(setThisSim, CnGlobal, CnLocal, c_idents, & |
535 |
< |
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
536 |
< |
CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, & |
537 |
< |
status) |
554 |
< |
use definitions, ONLY : dp |
555 |
< |
use simulation |
556 |
< |
|
557 |
< |
type (simtype) :: setThisSim |
558 |
< |
integer, intent(inout) :: CnGlobal, CnLocal |
559 |
< |
integer, dimension(CnLocal),intent(inout) :: c_idents |
534 |
> |
function SimUsesStickyPower() result(doesit) |
535 |
> |
logical :: doesit |
536 |
> |
doesit = thisSim%SIM_uses_StickyPower |
537 |
> |
end function SimUsesStickyPower |
538 |
|
|
539 |
< |
integer :: CnLocalExcludes |
540 |
< |
integer, dimension(2,CnLocalExcludes), intent(inout) :: CexcludesLocal |
541 |
< |
integer :: CnGlobalExcludes |
542 |
< |
integer, dimension(CnGlobalExcludes), intent(inout) :: CexcludesGlobal |
543 |
< |
integer, dimension(CnGlobal),intent(inout) :: CmolMembership |
544 |
< |
!! Result status, success = 0, status = -1 |
545 |
< |
integer, intent(inout) :: status |
546 |
< |
|
547 |
< |
!! mass factors used for molecular cutoffs |
548 |
< |
real ( kind = dp ), dimension(CnLocal) :: Cmfact |
549 |
< |
integer, intent(in):: CnGroups |
550 |
< |
integer, dimension(CnGlobal), intent(inout):: CglobalGroupMembership |
551 |
< |
|
552 |
< |
call SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & |
553 |
< |
CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & |
554 |
< |
CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, & |
555 |
< |
status) |
556 |
< |
end subroutine setFortranSim |
557 |
< |
|
558 |
< |
subroutine setFortranBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
559 |
< |
use simulation, only : setBox |
560 |
< |
use definitions, ONLY : dp |
561 |
< |
real(kind=dp), dimension(3,3) :: cHmat, cHmatInv |
562 |
< |
integer :: cBoxIsOrthorhombic |
563 |
< |
|
564 |
< |
call setBox(cHmat, cHmatInv, cBoxIsOrthorhombic) |
565 |
< |
|
566 |
< |
end subroutine setFortranBox |
539 |
> |
function SimUsesGayBerne() result(doesit) |
540 |
> |
logical :: doesit |
541 |
> |
doesit = thisSim%SIM_uses_GayBerne |
542 |
> |
end function SimUsesGayBerne |
543 |
> |
|
544 |
> |
function SimUsesEAM() result(doesit) |
545 |
> |
logical :: doesit |
546 |
> |
doesit = thisSim%SIM_uses_EAM |
547 |
> |
end function SimUsesEAM |
548 |
> |
|
549 |
> |
function SimUsesShapes() result(doesit) |
550 |
> |
logical :: doesit |
551 |
> |
doesit = thisSim%SIM_uses_Shapes |
552 |
> |
end function SimUsesShapes |
553 |
> |
|
554 |
> |
function SimUsesFLARB() result(doesit) |
555 |
> |
logical :: doesit |
556 |
> |
doesit = thisSim%SIM_uses_FLARB |
557 |
> |
end function SimUsesFLARB |
558 |
> |
|
559 |
> |
function SimUsesRF() result(doesit) |
560 |
> |
logical :: doesit |
561 |
> |
doesit = thisSim%SIM_uses_RF |
562 |
> |
end function SimUsesRF |
563 |
> |
|
564 |
> |
function SimUsesDampedWolf() result(doesit) |
565 |
> |
logical :: doesit |
566 |
> |
doesit = thisSim%SIM_uses_DampedWolf |
567 |
> |
end function SimUsesDampedWolf |
568 |
> |
|
569 |
> |
function SimRequiresPrepairCalc() result(doesit) |
570 |
> |
logical :: doesit |
571 |
> |
doesit = thisSim%SIM_uses_EAM |
572 |
> |
end function SimRequiresPrepairCalc |
573 |
> |
|
574 |
> |
function SimRequiresPostpairCalc() result(doesit) |
575 |
> |
logical :: doesit |
576 |
> |
doesit = thisSim%SIM_uses_RF .or. thisSim%SIM_uses_DampedWolf |
577 |
> |
end function SimRequiresPostpairCalc |
578 |
> |
|
579 |
> |
! Function returns true if the simulation has this atype |
580 |
> |
function SimHasAtype(thisAtype) result(doesit) |
581 |
> |
logical :: doesit |
582 |
> |
integer :: thisAtype |
583 |
> |
doesit = .false. |
584 |
> |
if(.not.allocated(SimHasAtypeMap)) return |
585 |
> |
|
586 |
> |
doesit = SimHasAtypeMap(thisAtype) |
587 |
> |
|
588 |
> |
end function SimHasAtype |
589 |
> |
|
590 |
> |
subroutine createSimHasAtype(status) |
591 |
> |
integer, intent(out) :: status |
592 |
> |
integer :: alloc_stat |
593 |
> |
integer :: me_i |
594 |
> |
integer :: mpiErrors |
595 |
> |
integer :: nAtypes |
596 |
> |
status = 0 |
597 |
> |
|
598 |
> |
nAtypes = getSize(atypes) |
599 |
> |
! Setup logical map for atypes in simulation |
600 |
> |
if (.not.allocated(SimHasAtypeMap)) then |
601 |
> |
allocate(SimHasAtypeMap(nAtypes),stat=alloc_stat) |
602 |
> |
if (alloc_stat /= 0 ) then |
603 |
> |
status = -1 |
604 |
> |
return |
605 |
> |
end if |
606 |
> |
SimHasAtypeMap = .false. |
607 |
> |
end if |
608 |
> |
|
609 |
> |
! Loop through the local atoms and grab the atypes present |
610 |
> |
do me_i = 1,nLocal |
611 |
> |
SimHasAtypeMap(atid(me_i)) = .true. |
612 |
> |
end do |
613 |
> |
! For MPI, we need to know all possible atypes present in |
614 |
> |
! simulation on all processors. Use LOR operation to set map. |
615 |
> |
#ifdef IS_MPI |
616 |
> |
if (.not.allocated(SimHasAtypeMapTemp)) then |
617 |
> |
allocate(SimHasAtypeMapTemp(nAtypes),stat=alloc_stat) |
618 |
> |
if (alloc_stat /= 0 ) then |
619 |
> |
status = -1 |
620 |
> |
return |
621 |
> |
end if |
622 |
> |
end if |
623 |
> |
call mpi_allreduce(SimHasAtypeMap, SimHasAtypeMaptemp, nAtypes, & |
624 |
> |
mpi_logical, MPI_LOR, mpi_comm_world, mpiErrors) |
625 |
> |
simHasAtypeMap = simHasAtypeMapTemp |
626 |
> |
deallocate(simHasAtypeMapTemp) |
627 |
> |
#endif |
628 |
> |
end subroutine createSimHasAtype |
629 |
> |
|
630 |
> |
subroutine InitializeSimGlobals(thisStat) |
631 |
> |
integer, intent(out) :: thisStat |
632 |
> |
integer :: alloc_stat |
633 |
> |
|
634 |
> |
thisStat = 0 |
635 |
> |
|
636 |
> |
call FreeSimGlobals() |
637 |
> |
|
638 |
> |
allocate(excludesLocal(2,nExcludes_Local), stat=alloc_stat) |
639 |
> |
if (alloc_stat /= 0 ) then |
640 |
> |
thisStat = -1 |
641 |
> |
return |
642 |
> |
endif |
643 |
> |
|
644 |
> |
allocate(excludesGlobal(nExcludes_Global), stat=alloc_stat) |
645 |
> |
if (alloc_stat /= 0 ) then |
646 |
> |
thisStat = -1 |
647 |
> |
return |
648 |
> |
endif |
649 |
> |
|
650 |
> |
allocate(molMembershipList(nGlobal), stat=alloc_stat) |
651 |
> |
if (alloc_stat /= 0 ) then |
652 |
> |
thisStat = -1 |
653 |
> |
return |
654 |
> |
endif |
655 |
> |
|
656 |
> |
end subroutine InitializeSimGlobals |
657 |
> |
|
658 |
> |
subroutine FreeSimGlobals() |
659 |
> |
|
660 |
> |
!We free in the opposite order in which we allocate in. |
661 |
> |
|
662 |
> |
if (allocated(skipsForAtom)) deallocate(skipsForAtom) |
663 |
> |
if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom) |
664 |
> |
if (allocated(mfactLocal)) deallocate(mfactLocal) |
665 |
> |
if (allocated(mfactCol)) deallocate(mfactCol) |
666 |
> |
if (allocated(mfactRow)) deallocate(mfactRow) |
667 |
> |
if (allocated(groupListCol)) deallocate(groupListCol) |
668 |
> |
if (allocated(groupListRow)) deallocate(groupListRow) |
669 |
> |
if (allocated(groupStartCol)) deallocate(groupStartCol) |
670 |
> |
if (allocated(groupStartRow)) deallocate(groupStartRow) |
671 |
> |
if (allocated(molMembershipList)) deallocate(molMembershipList) |
672 |
> |
if (allocated(excludesGlobal)) deallocate(excludesGlobal) |
673 |
> |
if (allocated(excludesLocal)) deallocate(excludesLocal) |
674 |
> |
|
675 |
> |
end subroutine FreeSimGlobals |
676 |
> |
|
677 |
> |
pure function getNlocal() result(n) |
678 |
> |
integer :: n |
679 |
> |
n = nLocal |
680 |
> |
end function getNlocal |
681 |
> |
|
682 |
> |
|
683 |
> |
|
684 |
> |
|
685 |
> |
|
686 |
> |
end module simulation |