ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/nano_mpi/src/parameter_module.F90
Revision: 9
Committed: Mon Jul 1 15:27:33 2002 UTC (22 years ago) by chuckv
File size: 13382 byte(s)
Log Message:
nose hoover chains added

File Contents

# Content
1 !=======================================================================
2 ! Parameter module
3 !=======================================================================
4 ! Handles reading and distribution of parameters read from param file
5 ! . Contains:
6 !
7 ! . Subroutines:
8 ! . handle_args Interpets command line arguments
9 ! . read_params reads in parameter file
10 ! . mpi_dist_params distrubutes parameters to all nodes
11
12 module parameter
13 use definitions, ONLY: DP
14 use io_units, ONLY : output_unit,error_unit
15 implicit none
16
17 public :: handle_args
18 public :: read_params
19
20 character(len=80),public :: paramfile
21 character(len=80),public :: file_prefix
22 character(len=80),public :: command
23 character(len=80),public :: sim_type
24 character(len=80),public :: ensemble
25 character(len=80),public :: force_field
26 character(len=80),public :: eam_pot_dir
27 real( kind = DP ),public :: dt
28 real( kind = DP ),public :: rcut
29 real( kind = DP ),public :: skin_thickness
30 real( kind = DP ),public :: therm_variance
31 real( kind = DP ),public :: run_time
32 real( kind = DP ),public :: target_temp
33 integer,public :: iseed
34 integer,public :: check_temp_steps
35 integer,public :: write_config_steps
36 logical,public :: checktemp
37
38 ! used only in cluster sims:
39 character(len=10),public :: core_model
40 character(len=10),public :: shell_model
41 real( kind = DP ),public :: r_core
42 real( kind = DP ),public :: r_shell
43 real( kind = DP ),public :: cell
44 real( kind = DP ),public :: vacancy_radius
45 real( kind = DP ),public :: vacancy_fraction
46
47 ! used only in liquid sims:
48 character(len=10),public :: solute_model
49 character(len=10),public :: solvent_model
50 real( kind = DP ),public :: solute_x
51 real( kind = DP ),public :: density
52 integer,public :: ncells
53
54 ! for MPI
55
56 logical, public :: newtons_thrd
57
58 ! langevin variables
59 real ( kind = DP ) :: eta !. viscosity in poise
60 real ( kind = DP ) :: bath_temp
61 real ( kind = DP ) :: langevin_skin_delta
62 logical :: use_langevin_skin
63 logical :: use_target_temp
64
65 ! vacancy parameter
66 logical,public :: print_vac
67
68 ! parameters for Nose-Hoover
69 ! real ( kind = DP ),public :: Q_mass
70
71 contains
72
73
74 subroutine handle_args(this_error)
75
76 integer, intent(out) :: this_error
77
78 this_error = 0
79
80 select case (command)
81 case ('input')
82 checktemp = .false.
83 case ('resample')
84 if ((ensemble.eq.'NVT') .or. &
85 (ensemble.eq.'langevin')) &
86 then
87 checktemp = .false.
88 else
89 checktemp = .true.
90 endif
91 case ('setup')
92 if ((ensemble.eq.'NVT') .or. &
93 (ensemble.eq.'langevin')) &
94 then
95 checktemp = .false.
96 else
97 checktemp = .true.
98 endif
99 case default
100 this_error = -1
101 end select
102
103 return
104 end subroutine handle_args
105
106 subroutine read_params(this_error)
107 use file_units, ONLY : next_unit
108 integer, optional :: this_error
109 integer :: read_error
110 character(len=120) :: msg
111 real( kind = DP ) :: time_between_configs, checktemptime
112 integer :: param_unit
113 integer :: file_open_error
114
115 ! . Get next available stream unit
116 param_unit = next_unit()
117 ! . Init file subroutine error reporting
118 if (present(this_error)) this_error = 0
119
120 open(unit=param_unit, file=paramfile, status='old', iostat=file_open_error, &
121 action='read')
122 if (file_open_error /= 0) then
123 write(msg,*) 'Error in opening paramfile ', paramfile
124 if (present(this_error)) this_error = -1
125 return
126 end if
127
128 !! Read each of the parameters in and check for correctness
129 read(unit=param_unit,fmt=*,iostat=read_error) sim_type !Simulation type
130 if (read_error == 0) then
131 select case (sim_type)
132 case ('liquid')
133 case ('cluster')
134 case default
135 write(error_unit,*) "Error in paramfile line 1: "
136 write(error_unit,*) "Simulation must be liquid or cluster"
137 if (present(this_error)) this_error = -1
138 return
139 end select
140 else
141 write(error_unit,*) "Error reading paramfile sim_type line 1: "
142
143 if (present(this_error)) this_error = -1
144 return
145 end if
146
147
148 read(unit=param_unit,fmt=*,iostat=read_error) ensemble ! ensemble for simulation
149 if (read_error == 0) then
150 select case (ensemble)
151 case ('NVE')
152 case ('NVT')
153 checktemp = .false.
154 case ('langevin')
155 case default
156 write(error_unit,*) "Error in paramfile line 2: "
157 write(error_unit,*) "Ensemble must be NVE or NVT or langevin"
158
159 if (present(this_error)) this_error = -1
160 return
161 end select
162 else
163 write(error_unit,*) "Error reading paramfile ensemble line 2: "
164 if (present(this_error)) this_error = -1
165 return
166 end if
167
168
169 read(unit=param_unit,fmt=*,iostat=read_error) force_field !Force field model used in simulation
170 if (read_error == 0) then
171 select case (force_field)
172 case ('lj')
173 case ('eam')
174 case ('glue')
175 case ('goddard')
176 case default
177 write(error_unit,*) "Error in paramfile line 3: "
178 write(error_unit,*) "Valid forcefieds are: "
179 write(error_unit,*) "lj"
180 write(error_unit,*) "eam"
181 write(error_unit,*) "goddard"
182 write(error_unit,*) "glue"
183 if (present(this_error)) this_error = -1
184 return
185 end select
186 else
187 write(error_unit,*) "Error reading paramfile force_field line 3: "
188 if (present(this_error)) this_error = -1
189 return
190 end if
191
192
193 read(unit=param_unit,fmt=*,iostat=read_error) eam_pot_dir
194 if (read_error /= 0) then
195 write(error_unit,*) "Error reading paramfile eam pot dir line 4: "
196 if (present(this_error)) this_error = -1
197 return
198 end if
199
200
201 read(unit=param_unit,fmt=*,iostat=read_error) dt
202 if (read_error /= 0) then
203 write(error_unit,*) "Error reading paramfile time step line 5: "
204 if (present(this_error)) this_error = -1
205 return
206 end if
207
208 read(unit=param_unit,fmt=*,iostat=read_error) rcut ! OK if zero, will be set by forcefield if possible
209 if (read_error /= 0) then
210 write(error_unit,*) "Error reading paramfile rcut line 6: "
211 if (present(this_error)) this_error = -1
212 return
213 end if
214
215 read(unit=param_unit,fmt=*,iostat=read_error) skin_thickness
216 if (read_error /= 0) then
217 write(error_unit,*) "Error reading paramfile skin_thinkness line 7: "
218 if (present(this_error)) this_error = -1
219 return
220 end if
221
222 read(unit=param_unit,fmt=*,iostat=read_error) checktemptime
223 if (read_error /= 0) then
224 write(error_unit,*) "Error reading paramfile checktemptime line 8: "
225 if (present(this_error)) this_error = -1
226 return
227 end if
228
229 check_temp_steps = &
230 idint(checktemptime/dt)
231
232 read(unit=param_unit,fmt=*,iostat=read_error) therm_variance
233 if (read_error /= 0) then
234 write(error_unit,*) "Error reading paramfile therm_variance line 9: "
235 if (present(this_error)) this_error = -1
236 return
237 end if
238
239 read(unit=param_unit,fmt=*,iostat=read_error) time_between_configs
240 if (read_error /= 0) then
241 write(error_unit,*) "Error reading paramfile dump config time line 10: "
242 if (present(this_error)) this_error = -1
243 return
244 end if
245
246 write_config_steps = &
247 idint(time_between_configs/dt)
248
249 read(unit=param_unit,fmt=*,iostat=read_error) iseed
250 if (read_error /= 0) then
251 write(error_unit,*) "Error reading paramfile iseed line 11: "
252 if (present(this_error)) this_error = -1
253 return
254 end if
255
256 ! read cluster params
257 read(unit=param_unit,fmt=*,iostat=read_error) core_model
258 if (read_error /= 0) then
259 write(error_unit,*) "Error reading paramfile core model line 12: "
260 if (present(this_error)) this_error = -1
261 return
262 end if
263
264 read(unit=param_unit,fmt=*,iostat=read_error) shell_model
265 if (read_error /= 0) then
266 write(error_unit,*) "Error reading paramfile shell model line 13: "
267 if (present(this_error)) this_error = -1
268 return
269 end if
270
271 read(unit=param_unit,fmt=*,iostat=read_error) r_core
272 if (read_error /= 0) then
273 write(error_unit,*) "Error reading paramfile core radius line 14: "
274 if (present(this_error)) this_error = -1
275 return
276 end if
277
278 read(unit=param_unit,fmt=*,iostat=read_error) r_shell
279 if (read_error /= 0) then
280 write(error_unit,*) "Error reading paramfile shell radius line 15: "
281 if (present(this_error)) this_error = -1
282 return
283 end if
284
285 read(unit=param_unit,fmt=*,iostat=read_error) cell
286 if (read_error /= 0) then
287 write(error_unit,*) "Error reading paramfile cell length line 16: "
288 if (present(this_error)) this_error = -1
289 return
290 end if
291
292 read(unit=param_unit,fmt=*,iostat=read_error) vacancy_radius
293 if (read_error /= 0) then
294 write(error_unit,*) "Error reading paramfile vacancy radius line 17: "
295 if (present(this_error)) this_error = -1
296 return
297 end if
298
299 read(unit=param_unit,fmt=*,iostat=read_error) vacancy_fraction
300 if (read_error /= 0) then
301 write(error_unit,*) "Error reading paramfile vacancy fraction line 18: "
302 if (present(this_error)) this_error = -1
303 return
304 end if
305
306 ! read liquid params
307 read(unit=param_unit,fmt=*,iostat=read_error) solute_model
308 if (read_error /= 0) then
309 write(error_unit,*) "Error reading paramfile solute Model line 19: "
310 if (present(this_error)) this_error = -1
311 return
312 end if
313
314 read(unit=param_unit,fmt=*,iostat=read_error) solvent_model
315 if (read_error /= 0) then
316 write(error_unit,*) "Error reading paramfile solvent model line 20: "
317 if (present(this_error)) this_error = -1
318 return
319 end if
320
321 read(unit=param_unit,fmt=*,iostat=read_error) solute_x
322 if (read_error /= 0) then
323 write(error_unit,*) "Error reading mol fraction line 21: "
324 if (present(this_error)) this_error = -1
325 return
326 end if
327
328 read(unit=param_unit,fmt=*,iostat=read_error) density
329 if (read_error /= 0) then
330 write(error_unit,*) "Error reading paramfile density line 22: "
331 if (present(this_error)) this_error = -1
332 return
333 end if
334
335 read(unit=param_unit,fmt=*,iostat=read_error) ncells
336 if (read_error /= 0) then
337 write(error_unit,*) "Error reading paramfile Number of cells line 23: "
338 if (present(this_error)) this_error = -1
339 return
340 end if
341
342 ! read MPI
343
344 read(unit=param_unit,fmt=*,iostat=read_error) newtons_thrd
345 if (read_error /= 0) then
346 write(error_unit,*) "Error reading paramfile Newtons third law line 24: "
347 if (present(this_error)) this_error = -1
348 return
349 end if
350
351 ! . gamma for langevin dynamics
352 read(unit=param_unit,fmt=*,iostat=read_error) eta
353 if (read_error /= 0) then
354 write(error_unit,*) "Error reading paramfile eta line 25: "
355 if (present(this_error)) this_error = -1
356 return
357 end if
358
359 ! . bath temperature for langevin dynamics
360 read(unit=param_unit,fmt=*,iostat=read_error) bath_temp
361 if (read_error /= 0) then
362 write(error_unit,*) "Error reading paramfile bath_temp line 26: "
363 if (present(this_error)) this_error = -1
364 return
365 end if
366 read(unit=param_unit,fmt=*,iostat=read_error) use_target_temp
367 if (read_error /= 0) then
368 write(error_unit,*) "Error reading paramfile use_target_temp line 27: "
369 if (present(this_error)) this_error = -1
370 return
371 end if
372
373 ! . skin radius for langevin dynamics
374 read(unit=param_unit,fmt=*,iostat=read_error) langevin_skin_delta
375 if (read_error /= 0) then
376 write(error_unit,*) "Error reading paramfile langevin skin delta line 27: "
377 if (present(this_error)) this_error = -1
378 return
379 end if
380
381 ! . logical to use skin radius
382 read(unit=param_unit,fmt=*,iostat=read_error) use_langevin_skin
383 if (read_error /= 0) then
384 write(error_unit,*) "Error reading paramfile langevin skin delta line 27: "
385 if (present(this_error)) this_error = -1
386 return
387 end if
388
389 ! . vacancy param
390 read(unit=param_unit,fmt=*,iostat=read_error) print_vac
391 if (read_error /= 0) then
392 write(error_unit,*) "Error reading paramfile print_vac line 30: "
393 if (present(this_error)) this_error = -1
394 return
395 end if
396
397 ! . Nose hoover param
398 ! read(unit=param_unit,fmt=*,iostat=read_error) Q_mass
399 ! if (read_error /= 0) then
400 ! write(error_unit,*) "Error reading paramfile Q_mass line 31: "
401 ! if (present(this_error)) this_error = -1
402 ! return
403 ! end if
404
405 close(param_unit)
406
407 if (use_target_temp) then
408 bath_temp = target_temp
409 end if
410
411
412
413 end subroutine read_params
414
415
416
417 end module parameter