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 460 by chuckv, Fri Apr 4 22:22:30 2003 UTC vs.
Revision 941 by gezelter, Tue Jan 13 23:01:43 2004 UTC

# Line 16 | Line 16 | module simulation
16   #define __FORTRAN90
17   #include "fSimulation.h"
18  
19 <  type (simtype), public :: thisSim
19 >  type (simtype), public, save :: thisSim
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
31 <  real(kind=dp), save :: rlist2 = 0.0_DP
32 <  real(kind=dp), public, dimension(3), save :: box
33 <
30 >  real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv
31 >  logical, public, save :: boxIsOrthorhombic
32    
33    public :: SimulationSetup
34    public :: getNlocal
35    public :: setBox
38  public :: setBox_3d
39  public :: getBox
40  public :: setRcut
41  public :: getRcut
42  public :: getRlist
43  public :: getRrf
44  public :: getRt
36    public :: getDielect
37    public :: SimUsesPBC
38    public :: SimUsesLJ
39 +  public :: SimUsesCharges
40    public :: SimUsesDipoles
41    public :: SimUsesSticky
42    public :: SimUsesRF
# Line 53 | Line 45 | module simulation
45    public :: SimRequiresPrepairCalc
46    public :: SimRequiresPostpairCalc
47    public :: SimUsesDirectionalAtoms
56
57  interface getBox
58     module procedure getBox_3d
59     module procedure getBox_1d
60  end interface
48    
62  interface setBox
63     module procedure setBox_3d
64     module procedure setBox_1d
65  end interface
66  
49   contains
50    
51 <  subroutine SimulationSetup(setThisSim, nComponents, c_idents, &
51 >  subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
52         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
53 +       CmolMembership, &
54         status)    
55  
56      type (simtype) :: setThisSim
57 <    integer, intent(inout) :: nComponents
58 <    integer, dimension(nComponents),intent(inout) :: c_idents
57 >    integer, intent(inout) :: CnGlobal, CnLocal
58 >    integer, dimension(CnLocal),intent(inout) :: c_idents
59  
60      integer :: CnLocalExcludes
61      integer, dimension(2,CnLocalExcludes), intent(in) :: CexcludesLocal
62      integer :: CnGlobalExcludes
63      integer, dimension(CnGlobalExcludes), intent(in) :: CexcludesGlobal
64 +    integer, dimension(CnGlobal),intent(in) :: CmolMembership
65      !!  Result status, success = 0, status = -1
66      integer, intent(out) :: status
67      integer :: i, me, thisStat, alloc_stat, myNode
# Line 92 | Line 76 | contains
76      status = 0
77  
78      ! copy C struct into fortran type
79 +
80 +    nLocal = CnLocal
81 +    nGlobal = CnGlobal
82 +
83      thisSim = setThisSim
96    natoms = nComponents
97    rcut2 = thisSim%rcut * thisSim%rcut
98    rcut6 = rcut2 * rcut2 * rcut2
99    rlist2 = thisSim%rlist * thisSim%rlist
100    box = thisSim%box
84  
85      nExcludes_Global = CnGlobalExcludes
86      nExcludes_Local = CnLocalExcludes
87  
88 <    call InitializeForceGlobals(natoms, thisStat)
88 >    call InitializeForceGlobals(nLocal, thisStat)
89      if (thisStat /= 0) then
90 +       write(default_error,*) "SimSetup: InitializeForceGlobals error"
91         status = -1
92         return
93      endif
94  
95      call InitializeSimGlobals(thisStat)
96      if (thisStat /= 0) then
97 +       write(default_error,*) "SimSetup: InitializeSimGlobals error"
98         status = -1
99         return
100      endif
# Line 158 | Line 143 | contains
143         deallocate(c_idents_Row)
144      endif
145      
146 < #else
147 <    do i = 1, nComponents
146 > #endif
147 >
148 > ! We build the local atid's for both mpi and nonmpi
149 >    do i = 1, nLocal
150        
151         me = getFirstMatchingElement(atypes, "c_ident", c_idents(i))
152         atid(i) = me
153    
154      enddo
168 #endif
155  
170    !! Create neighbor lists
171    call expandNeighborList(nComponents, thisStat)
172    if (thisStat /= 0) then
173       status = -1
174       return
175    endif
156  
157  
158 +
159      do i = 1, nExcludes_Local
160         excludesLocal(1,i) = CexcludesLocal(1,i)
161         excludesLocal(2,i) = CexcludesLocal(2,i)
# Line 184 | Line 165 | contains
165         excludesGlobal(i) = CexcludesGlobal(i)
166      enddo
167  
168 +    do i = 1, nGlobal
169 +       molMemberShipList(i) = CmolMembership(i)
170 +     enddo
171 +
172      if (status == 0) simulation_setup_complete = .true.
173      
174    end subroutine SimulationSetup
175    
176 <  subroutine setBox_3d(new_box_size)
177 <    real(kind=dp), dimension(3) :: new_box_size
176 >  subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
177 >    real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
178 >    integer :: cBoxIsOrthorhombic
179      integer :: smallest, status, i
180 <
181 <    thisSim%box = new_box_size
182 <    box = thisSim%box
183 <
180 >    
181 >    Hmat = cHmat
182 >    HmatInv = cHmatInv
183 >    if (cBoxIsOrthorhombic .eq. 0 ) then
184 >       boxIsOrthorhombic = .false.
185 >    else
186 >       boxIsOrthorhombic = .true.
187 >    endif
188 >    
189      return    
190 <  end subroutine setBox_3d
200 <
201 <  subroutine setBox_1d(dim, new_box_size)
202 <    integer :: dim, status
203 <    real(kind=dp) :: new_box_size
204 <    thisSim%box(dim) = new_box_size
205 <    box(dim) = thisSim%box(dim)
206 <  end subroutine setBox_1d
190 >  end subroutine setBox
191  
208  subroutine setRcut(new_rcut, status)
209    real(kind = dp) :: new_rcut
210    integer :: myStatus, status
211    thisSim%rcut = new_rcut
212    rcut2 = thisSim%rcut * thisSim%rcut
213    rcut6 = rcut2 * rcut2 * rcut2
214    status = 0
215    return
216  end subroutine setRcut
217
218  function getBox_3d() result(thisBox)
219    real( kind = dp ), dimension(3) :: thisBox
220    thisBox = thisSim%box
221  end function getBox_3d
222  
223  function getBox_1d(dim) result(thisBox)
224    integer, intent(in) :: dim
225    real( kind = dp ) :: thisBox
226    
227    thisBox = thisSim%box(dim)
228  end function getBox_1d
229    
230  subroutine getRcut(thisrcut,rc2,rc6,status)
231    real( kind = dp ), intent(out) :: thisrcut
232    real( kind = dp ), intent(out), optional :: rc2
233    real( kind = dp ), intent(out), optional :: rc6
234    integer, optional :: status
235
236    if (present(status)) status = 0
237    
238    if (.not.simulation_setup_complete ) then
239       if (present(status)) status = -1
240       return
241    end if
242    
243    thisrcut = thisSim%rcut
244    if(present(rc2)) rc2 = rcut2
245    if(present(rc6)) rc6 = rcut6
246  end subroutine getRcut
247  
248  subroutine getRlist(thisrlist,rl2,status)
249    real( kind = dp ), intent(out) :: thisrlist
250    real( kind = dp ), intent(out), optional :: rl2
251
252    integer, optional :: status
253
254    if (present(status)) status = 0
255
256    if (.not.simulation_setup_complete ) then
257       if (present(status)) status = -1
258       return
259    end if
260    
261    thisrlist = thisSim%rlist
262    if(present(rl2)) rl2 = rlist2
263  end subroutine getRlist
264
265  function getRrf() result(rrf)
266    real( kind = dp ) :: rrf
267    rrf = thisSim%rrf
268    write(*,*) 'getRrf = ', rrf, thisSim%rrf
269  end function getRrf
270  
271  function getRt() result(rt)
272    real( kind = dp ) :: rt
273    rt = thisSim%rt
274  end function getRt
275
192    function getDielect() result(dielect)
193      real( kind = dp ) :: dielect
194      dielect = thisSim%dielect
# Line 293 | Line 209 | contains
209      doesit = thisSim%SIM_uses_sticky
210    end function SimUsesSticky
211  
212 +  function SimUsesCharges() result(doesit)
213 +    logical :: doesit
214 +    doesit = thisSim%SIM_uses_charges
215 +  end function SimUsesCharges
216 +
217    function SimUsesDipoles() result(doesit)
218      logical :: doesit
219      doesit = thisSim%SIM_uses_dipoles
# Line 348 | Line 269 | contains
269         thisStat = -1
270         return
271      endif
272 +
273 +    allocate(molMembershipList(nGlobal), stat=alloc_stat)
274 +    if (alloc_stat /= 0 ) then
275 +       thisStat = -1
276 +       return
277 +    endif
278      
279    end subroutine InitializeSimGlobals
280    
281    subroutine FreeSimGlobals()
282      
283      !We free in the opposite order in which we allocate in.
284 <    
284 >
285 >    if (allocated(molMembershipList)) deallocate(molMembershipList)    
286      if (allocated(excludesGlobal)) deallocate(excludesGlobal)
287      if (allocated(excludesLocal)) deallocate(excludesLocal)
288  
289    end subroutine FreeSimGlobals
290  
291 <  pure function getNlocal() result(nlocal)
292 <    integer :: nlocal
293 <    nlocal = natoms
291 >  pure function getNlocal() result(n)
292 >    integer :: n
293 >    n = nLocal
294    end function getNlocal
295  
296    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines