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 394 by gezelter, Mon Mar 24 21:55:34 2003 UTC vs.
Revision 491 by mmeineke, Fri Apr 11 18:46:37 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 21 | Line 20 | module simulation
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
# Line 67 | Line 67 | contains
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
# Line 93 | Line 95 | contains
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
# Line 103 | Line 108 | contains
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
# Line 160 | Line 167 | contains
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
# Line 168 | Line 175 | contains
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
# Line 184 | Line 185 | contains
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
# Line 196 | Line 201 | contains
201      thisSim%box = new_box_size
202      box = thisSim%box
203  
199    smallest = 1
200    do i = 2, 3
201       if (new_box_size(i) .lt. new_box_size(smallest)) smallest = i
202    end do
203    if (thisSim%rcut .gt. 0.5_dp * new_box_size(smallest)) &
204         call setRcut(0.5_dp * new_box_size(smallest), status)
204      return    
205    end subroutine setBox_3d
206  
# Line 210 | Line 209 | contains
209      real(kind=dp) :: new_box_size
210      thisSim%box(dim) = new_box_size
211      box(dim) = thisSim%box(dim)
213    if (thisSim%rcut .gt. 0.5_dp * new_box_size) &
214         call setRcut(0.5_dp * new_box_size, status)
212    end subroutine setBox_1d
213  
214    subroutine setRcut(new_rcut, status)
# Line 220 | Line 217 | contains
217      thisSim%rcut = new_rcut
218      rcut2 = thisSim%rcut * thisSim%rcut
219      rcut6 = rcut2 * rcut2 * rcut2
223    myStatus = 0
224    call LJ_new_rcut(new_rcut, myStatus)
225    if (myStatus .ne. 0) then
226       write(default_error, *) 'LJ module refused our rcut!'
227       status = -1
228       return
229    endif
220      status = 0
221      return
222    end subroutine setRcut
# Line 364 | Line 354 | contains
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    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines