ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/simulation_module.F90
(Generate patch)

Comparing trunk/OOPSE/libmdtools/simulation_module.F90 (file contents):
Revision 378 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
Revision 490 by gezelter, Fri Apr 11 15:16:59 2003 UTC

# Line 6 | Line 6 | module simulation
6    use force_globals
7    use vector_class
8    use atype_module
9  use lj
9   #ifdef IS_MPI
10    use mpiSimulation
11   #endif
# Line 26 | Line 25 | module simulation
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
# Line 67 | Line 67 | contains
67    
68   contains
69    
70 <  subroutine SimulationSetup(setThisSim, nComponents, c_idents, &
70 >  subroutine SimulationSetup(setThisSim, nGlobal, nLocal, 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) :: nGlobal, nLocal
77 >    integer, dimension(nLocal),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(nGlobal),intent(in) :: CmolMembership
84      !!  Result status, success = 0, status = -1
85      integer, intent(out) :: status
86      integer :: i, me, thisStat, alloc_stat, myNode
# Line 94 | Line 96 | contains
96  
97      ! copy C struct into fortran type
98      thisSim = setThisSim
99 <    natoms = nComponents
99 >    natoms = nLocal
100      rcut2 = thisSim%rcut * thisSim%rcut
101      rcut6 = rcut2 * rcut2 * rcut2
102      rlist2 = thisSim%rlist * thisSim%rlist
# Line 105 | Line 107 | contains
107  
108      call InitializeForceGlobals(natoms, thisStat)
109      if (thisStat /= 0) then
110 +       write(default_error,*) "SimSetup: InitializeForceGlobals error"
111         status = -1
112         return
113      endif
114  
115      call InitializeSimGlobals(thisStat)
116      if (thisStat /= 0) then
117 +       write(default_error,*) "SimSetup: InitializeSimGlobals error"
118         status = -1
119         return
120      endif
# Line 160 | Line 164 | contains
164      endif
165      
166   #else
167 <    do i = 1, nComponents
167 >    do i = 1, nLocal
168        
169         me = getFirstMatchingElement(atypes, "c_ident", c_idents(i))
170         atid(i) = me
# Line 168 | Line 172 | contains
172      enddo
173   #endif
174  
171    !! Create neighbor lists
172    call expandNeighborList(nComponents, thisStat)
173    if (thisStat /= 0) then
174       status = -1
175       return
176    endif
175  
176 +
177      do i = 1, nExcludes_Local
178         excludesLocal(1,i) = CexcludesLocal(1,i)
179         excludesLocal(2,i) = CexcludesLocal(2,i)
# Line 183 | Line 182 | contains
182      do i = 1, nExcludes_Global
183         excludesGlobal(i) = CexcludesGlobal(i)
184      enddo
185 <    
185 >
186 >    do i = 1, nGlobal
187 >       molMemberShipList(i) = CmolMembership(i)
188 >       ! write(0,*) 'molMembershipList(',i,') = ', molMemberShipList(i)
189 >    enddo
190 >
191      if (status == 0) simulation_setup_complete = .true.
192      
193    end subroutine SimulationSetup
# Line 195 | Line 199 | contains
199      thisSim%box = new_box_size
200      box = thisSim%box
201  
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)
202      return    
203    end subroutine setBox_3d
204  
# Line 209 | Line 207 | contains
207      real(kind=dp) :: new_box_size
208      thisSim%box(dim) = new_box_size
209      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)
210    end subroutine setBox_1d
211  
212    subroutine setRcut(new_rcut, status)
# Line 219 | Line 215 | contains
215      thisSim%rcut = new_rcut
216      rcut2 = thisSim%rcut * thisSim%rcut
217      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
218      status = 0
219      return
220    end subroutine setRcut
# Line 280 | Line 269 | contains
269    function getRrf() result(rrf)
270      real( kind = dp ) :: rrf
271      rrf = thisSim%rrf
272 +    write(*,*) 'getRrf = ', rrf, thisSim%rrf
273    end function getRrf
274    
275    function getRt() result(rt)
# Line 362 | Line 352 | contains
352         thisStat = -1
353         return
354      endif
355 +
356 +    allocate(molMembershipList(getNlocal()), stat=alloc_stat)
357 +    if (alloc_stat /= 0 ) then
358 +       thisStat = -1
359 +       return
360 +    endif
361      
362    end subroutine InitializeSimGlobals
363    
364    subroutine FreeSimGlobals()
365      
366      !We free in the opposite order in which we allocate in.
367 <    
367 >
368 >    if (allocated(molMembershipList)) deallocate(molMembershipList)    
369      if (allocated(excludesGlobal)) deallocate(excludesGlobal)
370      if (allocated(excludesLocal)) deallocate(excludesLocal)
371  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines