--- trunk/OOPSE/libmdtools/simulation_module.F90 2004/05/01 18:52:38 1144 +++ 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, 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 @@ -50,7 +56,7 @@ contains subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, & CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, & - CmolMembership, mfact, ngroup, groupList, groupStart, & + CmolMembership, Cmfact, CnGroup, CgroupList, CgroupStart, & status) type (simtype) :: setThisSim @@ -65,12 +71,13 @@ 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(3,nLocal) :: mfact - integer, intent(in):: ngroup - integer, dimension(nLocal),intent(in) :: groupList - integer, dimension(ngroup),intent(in) :: groupStart + 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 @@ -86,6 +93,7 @@ contains nLocal = CnLocal nGlobal = CnGlobal + nGroup = CnGroup thisSim = setThisSim @@ -160,9 +168,6 @@ contains enddo - - - do i = 1, nExcludes_Local excludesLocal(1,i) = CexcludesLocal(1,i) excludesLocal(2,i) = CexcludesLocal(2,i) @@ -174,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 @@ -282,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 @@ -289,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