--- trunk/OOPSE/libmdtools/simulation_module.F90 2003/07/23 22:13:59 648 +++ trunk/OOPSE/libmdtools/simulation_module.F90 2004/05/07 21:35:05 1150 @@ -6,6 +6,7 @@ module simulation use force_globals use vector_class use atype_module + use switcheroo #ifdef IS_MPI use mpiSimulation #endif @@ -15,17 +16,22 @@ module simulation #define __FORTRAN90 #include "fSimulation.h" +#include "fSwitchingFunction.h" - type (simtype), public :: thisSim + type (simtype), public, save :: thisSim logical, save :: simulation_setup_complete = .false. integer, public, save :: nLocal, nGlobal + integer, public, save :: nGroup, nGroupGlobal integer, public, save :: nExcludes_Global = 0 integer, public, save :: nExcludes_Local = 0 integer, allocatable, dimension(:,:), public :: excludesLocal integer, allocatable, dimension(:), public :: excludesGlobal integer, allocatable, dimension(:), public :: molMembershipList + integer, allocatable, dimension(:), public :: groupList + integer, allocatable, dimension(:), public :: groupStart + real(kind=dp), allocatable, dimension(:), public :: mfact real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv logical, public, save :: boxIsOrthorhombic @@ -36,6 +42,7 @@ module simulation public :: getDielect public :: SimUsesPBC public :: SimUsesLJ + public :: SimUsesCharges public :: SimUsesDipoles public :: SimUsesSticky public :: SimUsesRF @@ -49,7 +56,7 @@ contains subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & - CmolMembership, & + CmolMembership, Cmfact, CnGroup, CgroupList, CgroupStart, & status) type (simtype) :: setThisSim @@ -64,6 +71,14 @@ contains !! Result status, success = 0, status = -1 integer, intent(out) :: status integer :: i, me, thisStat, alloc_stat, myNode + integer :: gStart, gEnd, groupSize, biggestGroupSize, ia + + !! mass factors used for molecular cutoffs + real ( kind = dp ), dimension(CnLocal) :: Cmfact + integer, intent(in):: CnGroup + integer, dimension(CnLocal),intent(in) :: CgroupList + integer, dimension(CnGroup),intent(in) :: CgroupStart + #ifdef IS_MPI integer, allocatable, dimension(:) :: c_idents_Row integer, allocatable, dimension(:) :: c_idents_Col @@ -78,6 +93,7 @@ contains nLocal = CnLocal nGlobal = CnGlobal + nGroup = CnGroup thisSim = setThisSim @@ -152,9 +168,6 @@ contains enddo - - - do i = 1, nExcludes_Local excludesLocal(1,i) = CexcludesLocal(1,i) excludesLocal(2,i) = CexcludesLocal(2,i) @@ -166,8 +179,30 @@ contains do i = 1, nGlobal molMemberShipList(i) = CmolMembership(i) - enddo + enddo + + biggestGroupSize = 0 + do i = 1, nGroup + groupStart(i) = CgroupStart(i) + groupSize = 0 + gStart = groupStart(i) + if (i .eq. nGroup) then + gEnd = nLocal + else + gEnd = CgroupStart(i+1) - 1 + endif + do ia = gStart, gEnd + groupList(ia) = CgroupList(ia) + groupSize = groupSize + 1 + enddo + if (groupSize .gt. biggestGroupSize) biggestGroupSize = groupSize + enddo + groupStart(nGroup+1) = nLocal+1 + do i = 1, nLocal + mfact(i) = Cmfact(i) + enddo + if (status == 0) simulation_setup_complete = .true. end subroutine SimulationSetup @@ -208,6 +243,11 @@ contains doesit = thisSim%SIM_uses_sticky end function SimUsesSticky + function SimUsesCharges() result(doesit) + logical :: doesit + doesit = thisSim%SIM_uses_charges + end function SimUsesCharges + function SimUsesDipoles() result(doesit) logical :: doesit doesit = thisSim%SIM_uses_dipoles @@ -269,6 +309,24 @@ contains thisStat = -1 return endif + + allocate(groupStart(nGroup+1), stat=alloc_stat) + if (alloc_stat /= 0 ) then + thisStat = -1 + return + endif + + allocate(groupList(nLocal), stat=alloc_stat) + if (alloc_stat /= 0 ) then + thisStat = -1 + return + endif + + allocate(mfact(nLocal), stat=alloc_stat) + if (alloc_stat /= 0 ) then + thisStat = -1 + return + endif end subroutine InitializeSimGlobals @@ -276,16 +334,19 @@ contains !We free in the opposite order in which we allocate in. + if (allocated(mfact)) deallocate(mfact) + if (allocated(groupList)) deallocate(groupList) + if (allocated(groupStart)) deallocate(groupStart) if (allocated(molMembershipList)) deallocate(molMembershipList) if (allocated(excludesGlobal)) deallocate(excludesGlobal) if (allocated(excludesLocal)) deallocate(excludesLocal) - + end subroutine FreeSimGlobals - + pure function getNlocal() result(n) integer :: n n = nLocal end function getNlocal - + end module simulation