ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/simulation_module.F90
(Generate patch)

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/simulation_module.F90 (file contents):
Revision 285 by mmeineke, Wed Feb 26 18:45:57 2003 UTC vs.
Revision 309 by gezelter, Mon Mar 10 23:19:23 2003 UTC

# Line 1 | Line 1
1 + !! Fortran interface to C entry plug.
2 +
3   module simulation
4    use definitions, ONLY :dp
5   #ifdef IS_MPI
# Line 8 | Line 10 | module simulation
10    PRIVATE
11  
12   #define __FORTRAN90
13 < #include "../headers/fsimulation.h"
13 > #include "fSimulation.h"
14  
15    type (simtype), public :: thisSim
14 !! Tag for MPI calculations  
15  integer, allocatable, dimension(:) :: tag
16  
17 < #ifdef IS_MPI
18 <  integer, allocatable, dimension(:) :: tag_row
19 <  integer, allocatable, dimension(:) :: tag_column
20 < #endif
17 >  logical :: setSim = .false.
18  
19 < !! WARNING: use_pbc hardcoded, fixme
23 <   logical :: setSim = .false.
19 >  integer,public :: natoms
20  
25 !! array for saving previous positions for neighbor lists.  
26  real( kind = dp ), allocatable,dimension(:,:),save :: q0
27
28
29  public :: wrap
21    public :: getBox
22    public :: getRcut
23    public :: getRlist
# Line 36 | Line 27 | module simulation
27    public :: isPBC
28    public :: getStringLen
29    public :: returnMixingRules
30 +  public :: doStress
31  
32   !  public :: setRcut
41
42  interface wrap
43     module procedure wrap_1d
44     module procedure wrap_3d
45  end interface
46
33    interface getBox
34       module procedure getBox_3d
35       module procedure getBox_dim
# Line 52 | Line 38 | module simulation
38  
39  
40  
55
56
57
58
59
60
41   contains
42  
43 <  subroutine setSimulation(nLRParticles,box,rlist,rcut,ensemble,mixingRule,use_pbc)
44 <    integer, intent(in) :: nLRParticles
45 <    real(kind = dp ), intent(in), dimension(3) :: box
66 <    real(kind = dp ), intent(in) :: rlist
67 <    real(kind = dp ), intent(in) :: rcut
68 <    character( len = stringLen), intent(in)  :: ensemble
69 <    character( len = stringLen), intent(in)  :: mixingRule
70 <    logical, intent(in) :: use_pbc
43 >  subroutine setSimulation(setThisSim,error)
44 >    type (simtype) :: setThisSim
45 >    integer :: error
46      integer :: alloc_stat
47 <    if( setsim ) return  ! simulation is already initialized
47 >
48 >    error = 0
49      setSim = .true.
50  
51 <    thisSim%nLRParticles = nLRParticles
52 <    thisSim%box          = box
77 <    thisSim%rlist        = rlist
78 <    thisSIm%rlistsq      = rlist * rlist
79 <    thisSim%rcut         = rcut
80 <    thisSim%rcutsq       = rcut * rcut
81 <    thisSim%rcut6        = thisSim%rcutsq * thisSim%rcutsq * thisSim%rcutsq
82 <    
83 <    thisSim%ensemble = ensemble
84 <    thisSim%mixingRule = mixingRule
85 <    thisSim%use_pbc = use_pbc
86 <
87 <    if (.not. allocated(q0)) then
88 <       allocate(q0(3,nLRParticles),stat=alloc_stat)
89 <    endif
51 > ! copy C struct into fortran type
52 >    thisSim = setThisSim
53    end subroutine setSimulation
54  
55    function getNparticles() result(nparticles)
# Line 115 | Line 78 | contains
78      thisBox = thisSim%box(dim)
79    end function getBox_dim
80    
118
119  function wrap_1d(r,dim) result(this_wrap)
120    
121    
122    real( kind = DP ) :: r
123    real( kind = DP ) :: this_wrap
124    integer           :: dim
125    
126    if (use_pbc) then
127       !     this_wrap = r - box(dim)*dsign(1.0E0_DP,r)*int(abs(r/box(dim)) + 0.5E0_DP)
128       this_wrap = r - thisSim%box(dim)*nint(r/thisSim%box(dim))
129    else
130       this_wrap = r
131    endif
132    
133    return
134  end function wrap_1d
135
136  function wrap_3d(r) result(this_wrap)
137    real( kind = dp ), dimension(3), intent(in) :: r
138    real( kind = dp ), dimension(3) :: this_wrap
139
140    
141    if (this_sim%use_pbc) then
142       !     this_wrap = r - box(dim)*dsign(1.0E0_DP,r)*int(abs(r/box(dim)) + 0.5E0_DP)
143       this_wrap = r - thisSim%box*nint(r/thisSim%box)
144    else
145       this_wrap = r
146    endif
147  end function wrap_3d
148
81    
82  
83    subroutine getRcut(thisrcut,rcut2,rcut6,status)
# Line 189 | Line 121 | contains
121  
122    end subroutine getRlist
123    
124 <  
193 <
124 >
125   pure function getNlocal() result(nlocal)
126      integer :: nlocal
127      nlocal = thisSim%nLRparticles
128    end function getNlocal
129  
130 +  function doStress() result(do_stress)
131 +    logical :: do_stress
132 +    do_stress = thisSim%do_stress
133 +  end function doStress
134  
135    function isEnsemble(this_ensemble) result(is_this_ensemble)
136      character(len = *) :: this_ensemble
137 <    logical :: is_this_enemble
137 >    logical :: is_this_ensemble
138      is_this_ensemble = .false.
139      if (this_ensemble == thisSim%ensemble) is_this_ensemble = .true.
140    end function isEnsemble
141 <
141 >  
142    function returnEnsemble() result(thisEnsemble)
143      character (len = len(thisSim%ensemble)) :: thisEnsemble
144      thisEnsemble = thisSim%ensemble
# Line 223 | Line 158 | contains
158    pure function getStringLen() result (thislen)
159      integer :: thislen    
160      thislen = string_len
161 <  end function setStringLen
161 >  end function getStringLen
162  
163   end module simulation

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines