ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/nano_mpi/src/simulation_module.F90
Revision: 4
Committed: Mon Jun 10 17:18:36 2002 UTC (22 years, 1 month ago) by chuckv
File size: 8990 byte(s)
Log Message:
Import Root

File Contents

# Content
1 module simulation
2 use definitions, ONLY : DP,ndim
3 implicit none
4
5 !! simulation parameters
6
7
8
9 !! standard simulation
10 integer :: nmol
11 integer :: natoms
12 integer :: nlocal
13 integer :: nmol_local
14
15 integer, allocatable, dimension(:) :: na
16 integer, allocatable, dimension(:,:) :: atom_index
17 integer, allocatable, dimension(:) :: ident
18 integer, allocatable, dimension(:) :: present_atypes
19 integer :: n_atypes_present
20 real( kind = DP ) :: temp
21 real( kind = DP ) :: total_mass
22 real( kind = DP ) :: mass_local
23 real( kind = DP ), allocatable, dimension(:,:) :: q
24 real( kind = DP ), allocatable, dimension(:,:) :: v
25 real( kind = DP ), allocatable, dimension(:,:) :: f
26 real( kind = DP ), allocatable, dimension(:) :: e
27 real( kind = DP ), allocatable, dimension(:) :: rho
28 real( kind = DP ), allocatable, dimension(:) :: frho
29 real( kind = DP ), allocatable, dimension(:) :: mass
30 real( kind = DP ), allocatable, dimension(:,:) :: q0
31 real( kind = DP ) :: rlstsq, rcutsq
32 integer, allocatable, dimension(:) :: point
33 integer, allocatable, dimension(:) :: list
34 character(len=10), allocatable, dimension(:) :: model
35 real( kind = DP ), dimension(3) :: box
36 logical :: use_pbc
37 real( kind = DP ) :: force_time,comm_time
38
39
40 #ifdef MPI
41 !! for mpi simulation
42 real( kind = DP ), allocatable, dimension(:) :: e_row
43 real( kind = DP ), allocatable, dimension(:) :: e_col
44 real( kind = DP ), allocatable, dimension(:) :: e_tmp
45
46 integer, allocatable, dimension(:) :: ident_row
47 integer, allocatable, dimension(:) :: ident_col
48 integer, allocatable, dimension(:) :: tag_local
49 integer, allocatable, dimension(:) :: tag_row
50 integer, allocatable, dimension(:) :: tag_col
51 real( kind = DP ), allocatable, dimension(:,:) :: q_tmp
52 real( kind = DP ), allocatable, dimension(:,:) :: q_row
53 real( kind = DP ), allocatable, dimension(:,:) :: q_col
54 real( kind = DP ), allocatable, dimension(:,:) :: q_old
55 real( kind = DP ), allocatable, dimension(:,:) :: f_tmp
56 real( kind = DP ), allocatable, dimension(:,:) :: f_row
57 real( kind = DP ), allocatable, dimension(:,:) :: f_col
58 real( kind = DP ), allocatable, dimension(:,:) :: v_tmp
59 real( kind = DP ), allocatable, dimension(:) :: rho_row
60 real( kind = DP ), allocatable, dimension(:) :: rho_col
61 real( kind = DP ), allocatable, dimension(:) :: rho_tmp
62 real( kind = DP ), allocatable, dimension(:) :: frho_tmp
63
64 #endif
65
66
67
68
69 public :: nmol,natoms,na,atom_index,ident,temp,q,v,f
70 public :: mass,q0,rlstsq,rcutsq,point,list,model,box,use_pbc
71 public :: allocate_nmol_arrays, allocate_simulation, deallocate_simulation
72 #ifdef MPI
73 public :: q_tmp,q_row,q_col,q_old,f_tmp,f_row,f_col
74 public :: allocate_mpi_arrays
75 #endif
76
77 contains
78 subroutine allocate_nmol_arrays(n_size,allocate_error)
79 integer, intent(in) :: n_size
80 integer :: ierror
81 integer, intent(out), optional :: allocate_error
82
83 allocate(na(n_size),STAT=ierror)
84 if (ierror /= 0 ) then
85 allocate_error = -1
86 end if
87
88 allocate(atom_index(n_size,3),STAT=ierror)
89 if (ierror /= 0 ) then
90 allocate_error = -1
91 end if
92
93 allocate(model(n_size),STAT=ierror)
94 if (ierror /= 0 ) then
95 allocate_error = -1
96 end if
97 end subroutine allocate_nmol_arrays
98
99 subroutine allocate_simulation(n_size,n_col, allocate_error)
100 integer, intent(in) :: n_size
101 integer, optional, intent(in) :: n_col
102 integer :: ierror
103 integer, intent(out), optional :: allocate_error
104 integer :: list_size
105 #ifndef MPI
106
107 list_size = n_size * 80
108
109 allocate(point(n_size),STAT=ierror)
110 if (ierror /= 0 ) then
111 allocate_error = -1
112 end if
113
114
115 allocate(list(list_size),STAT=ierror)
116 if (ierror /= 0 ) then
117 allocate_error = -1
118 end if
119
120
121 #endif
122
123 allocate(e(n_size),STAT=ierror)
124 if (ierror /= 0 ) then
125 allocate_error = -1
126 end if
127
128 allocate(ident(n_size),STAT=ierror)
129 if (ierror /= 0 ) then
130 allocate_error = -1
131 end if
132
133 allocate(q(3,n_size),STAT=ierror)
134 if (ierror /= 0 ) then
135 allocate_error = -1
136 end if
137
138 allocate(v(3,n_size),STAT=ierror)
139 if (ierror /= 0 ) then
140 allocate_error = -1
141 end if
142
143 allocate(f(3,n_size),STAT=ierror)
144 if (ierror /= 0 ) then
145 allocate_error = -1
146 end if
147
148 allocate(mass(n_size),STAT=ierror)
149 if (ierror /= 0 ) then
150 allocate_error = -1
151 end if
152
153 allocate(q0(3,n_size),STAT=ierror)
154 if (ierror /= 0 ) then
155 allocate_error = -1
156 end if
157 allocate(rho(n_size),STAT=ierror)
158 if (ierror /= 0 ) then
159 allocate_error = -1
160 end if
161 allocate(frho(n_size),STAT=ierror)
162 if (ierror /= 0 ) then
163 allocate_error = -1
164 end if
165
166
167
168 end subroutine allocate_simulation
169 #ifdef MPI
170 subroutine allocate_mpi_arrays(n_size,allocate_error)
171 integer, intent(in) :: n_size
172 integer :: ierror
173 integer, intent(out), optional :: allocate_error
174
175 allocate(e_tmp(n_size),STAT=ierror)
176 if (ierror /= 0 ) then
177 allocate_error = -1
178 end if
179 allocate(q_tmp(3,n_size),STAT=ierror)
180 if (ierror /= 0 ) then
181 allocate_error = -1
182 end if
183 allocate(q_old(3,n_size),STAT=ierror)
184 if (ierror /= 0 ) then
185 allocate_error = -1
186 end if
187 allocate(f_tmp(3,n_size),STAT=ierror)
188 if (ierror /= 0 ) then
189 allocate_error = -1
190 end if
191 allocate(v_tmp(3,n_size),STAT=ierror)
192 if (ierror /= 0 ) then
193 allocate_error = -1
194 end if
195 allocate(rho_tmp(n_size),STAT=ierror)
196 if (ierror /= 0 ) then
197 allocate_error = -1
198 end if
199 allocate(frho_tmp(n_size),STAT=ierror)
200 if (ierror /= 0 ) then
201 allocate_error = -1
202 end if
203 allocate(tag_local(n_size),STAT=ierror)
204 if (ierror /= 0 ) then
205 allocate_error = -1
206 end if
207 end subroutine allocate_mpi_arrays
208
209
210
211 subroutine allocate_mpi_row_arrays(n_size,allocate_error)
212 integer, intent(in) :: n_size
213 integer :: ierror
214 integer, intent(out), optional :: allocate_error
215
216
217 allocate(point(n_size+1),STAT=ierror)
218 if (ierror /= 0 ) then
219 allocate_error = -1
220 end if
221
222 allocate(list(80*n_size),STAT=ierror)
223 if (ierror /= 0 ) then
224 allocate_error = -1
225 end if
226
227 allocate(q_row(3,n_size),STAT=ierror)
228 if (ierror /= 0 ) then
229 allocate_error = -1
230 end if
231
232 allocate(e_row(n_size),STAT=ierror)
233 if (ierror /= 0 ) then
234 allocate_error = -1
235 end if
236
237 allocate(f_row(3,n_size),STAT=ierror)
238 if (ierror /= 0 ) then
239 allocate_error = -1
240 end if
241 allocate(rho_row(n_size),STAT=ierror)
242 if (ierror /= 0 ) then
243 allocate_error = -1
244 end if
245
246 allocate(ident_row(n_size),STAT=ierror)
247 if (ierror /= 0 ) then
248 allocate_error = -1
249 end if
250 allocate(tag_row(n_size),STAT=ierror)
251 if (ierror /= 0 ) then
252 allocate_error = -1
253 end if
254
255
256 end subroutine allocate_mpi_row_arrays
257
258 subroutine allocate_mpi_col_arrays(n_size,allocate_error)
259 integer, intent(in) :: n_size
260 integer :: ierror
261 integer, intent(out), optional :: allocate_error
262
263 allocate(q_col(3,n_size),STAT=ierror)
264 if (ierror /= 0 ) then
265 allocate_error = -1
266 end if
267 allocate(rho_col(n_size),STAT=ierror)
268 if (ierror /= 0 ) then
269 allocate_error = -1
270 end if
271
272 allocate(e_col(n_size),STAT=ierror)
273 if (ierror /= 0 ) then
274 allocate_error = -1
275 end if
276 allocate(ident_col(n_size),STAT=ierror)
277 if (ierror /= 0 ) then
278 allocate_error = -1
279 end if
280 allocate(tag_col(n_size),STAT=ierror)
281 if (ierror /= 0 ) then
282 allocate_error = -1
283 end if
284
285 allocate(f_col(3,n_size),STAT=ierror)
286 if (ierror /= 0 ) then
287 allocate_error = -1
288 end if
289
290
291
292 end subroutine allocate_mpi_col_arrays
293
294 subroutine deallocate_mpi_arrays()
295 deallocate(q_tmp)
296 deallocate(q_row)
297 deallocate(q_col)
298 deallocate(q_old)
299 deallocate(f_tmp)
300 deallocate(f_row)
301 deallocate(f_col)
302 deallocate(ident_col)
303 deallocate(e_col)
304 deallocate(ident_row)
305 deallocate(e_row)
306 deallocate(e_tmp)
307 deallocate(e)
308 end subroutine deallocate_mpi_arrays
309 #endif
310 subroutine deallocate_simulation()
311
312 deallocate(point)
313 deallocate(list)
314 deallocate(na)
315 deallocate(atom_index)
316 deallocate(ident)
317 deallocate(v)
318 deallocate(f)
319 deallocate(mass)
320 deallocate(q0)
321 deallocate(model)
322 deallocate(q)
323
324 end subroutine deallocate_simulation
325 end module simulation