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

File Contents

# Content
1 program nano
2 use definitions, ONLY : ndim,DP,machdep_init
3
4 use parameter, ONLY : read_params,handle_args,sim_type, &
5 command,paramfile,file_prefix, &
6 target_temp,run_time,ensemble,checktemp
7 use simulation, ONLY : deallocate_simulation,use_pbc
8 use init_simulation, ONLY : nano_build_system
9 use force_module, ONLY : init_forcefield_parameters,initialize_forcefield
10 use velocity, ONLY : randomize_velocities
11 use xyz_io, ONLY : open_xyz_files,read_initial_config,write_final_config
12 #ifdef MPI
13 use status, ONLY : info,error,warning,start_info,end_info,&
14 mpi_start_info,init_info
15 #else
16 use status, ONLY : info,error,warning,start_info,end_info,&
17 init_info
18 #endif
19
20 use dynamics, ONLY : run_dynamics
21 use F2KCLI, ONLY : command_argument_count,get_command_argument
22 #ifdef MPI
23 use mpi_module, ONLY : mpi_bcast,mpi_finalize,mpi_handle_atypes, &
24 mpi_err,mpi_comm_world,node,mpi_integer,mpi_dist_params,init_mpi
25 #endif
26
27
28 integer :: j, n_args, my_args
29 real( kind = DP) :: current_temp
30 character(len=80) :: junk
31 character(len=120) :: msg
32 character(len=60) :: prog_name
33 logical :: assign_positions
34
35 !errors
36 integer :: arg_error
37 integer :: command_error
38 integer :: param_error
39 integer :: open_file_error
40 integer :: read_config_error
41 #ifdef MPI
42 call init_mpi()
43 if (node == 0) then
44 #endif
45
46 n_args = command_argument_count()
47 #ifdef MPI
48 ! my_args = n_args - 4
49 my_args = 5
50 #else
51 my_args = n_args
52 #endif
53 if (my_args /= 5) then
54 arg_error = 0
55 else
56 arg_error = 1
57 endif
58
59
60 #ifdef MPI
61 endif
62 call mpi_bcast(arg_error,1,mpi_integer,0,mpi_comm_world,mpi_err)
63 #endif
64
65
66
67
68
69
70 if (arg_error == 0) then
71 call error('NANO', &
72 'usage: nano paramfile file_prefix command temperature run_time')
73 end if
74
75 ! set a null program name for other nodes
76 prog_name = "Null"
77 #ifdef MPI
78 if (node.eq.0) then
79 #endif
80 !! get the current program name
81 call get_command_argument(0,prog_name)
82 prog_name = trim(prog_name)
83
84 call get_command_argument(1,junk)
85 read(junk, *) paramfile
86 call get_command_argument(2,junk)
87 read(junk, *) file_prefix
88 call get_command_argument(3,junk)
89 read(junk, *) command
90 call get_command_argument(4,junk)
91 read(junk, *) target_temp
92 call get_command_argument(5,junk)
93 read(junk, *) run_time
94 #ifdef MPI
95 endif
96 #endif
97
98 call machdep_init()
99
100 #ifdef MPI
101 if (node.eq.0) then
102 #endif
103
104
105 call handle_args(this_error = command_error)
106 #ifdef MPI
107 endif
108 #endif
109
110 ! Distrubute error result to all nodes
111 #ifdef MPI
112 call mpi_bcast(command_error,1,mpi_integer,0,mpi_comm_world,mpi_err)
113 #endif
114 if (command_error /= 0) then
115 write(msg,*) "Unknown command", command
116 call error("PROGRAM",msg)
117 endif
118
119 #ifdef MPI
120 if (node == 0) then
121 #endif
122 call read_params(this_error=param_error)
123 call init_info()
124 ! Distrubute error result to all nodes
125 #ifdef MPI
126 endif
127 call mpi_bcast(param_error,1,mpi_integer,0,mpi_comm_world,mpi_err)
128 #endif
129 ! exit program gracefully if paramfile error
130 if (param_error /= 0) then
131 call error("MAIN","Error reading parmfile... Exiting")
132 endif
133 #ifdef MPI
134 if (node == 0) then
135 #endif
136 call open_xyz_files(this_error=open_file_error)
137 #ifdef MPI
138 endif
139 call mpi_bcast(open_file_error,1,mpi_integer,0,mpi_comm_world,mpi_err)
140 #endif
141 ! exit program gracefully if paramfile error
142 if (open_file_error /= 0) then
143 call error("MAIN","Error opening files... Exiting")
144 endif
145
146
147 #ifdef MPI
148 call mpi_dist_params()
149 #endif
150
151
152 call start_info(prog_name)
153
154 call init_forcefield_parameters()
155
156
157 use_pbc = .false.
158 assign_positions = .false.
159 if (command == 'setup') assign_positions = .true.
160 if (sim_type == 'liquid') then
161 use_pbc = .true.
162 endif
163
164
165 call nano_build_system(assign_positions)
166
167 #ifdef MPI
168 call mpi_start_info()
169 #endif
170
171 if (command /= 'setup') then
172 call read_initial_config(read_config_error)
173 end if
174
175
176
177 ! set up the neighborlist
178 call initialize_forcefield()
179
180
181
182 #ifdef MPI
183 call mpi_handle_atypes()
184 #endif
185
186
187 if(command == 'setup') then
188 call randomize_velocities(target_temp)
189 end if
190
191
192
193 call run_dynamics()
194
195 call write_final_config()
196 call end_info()
197 call deallocate_simulation()
198
199 #ifdef MPI
200 call mpi_finalize(mpi_err)
201 #endif
202
203
204 stop
205 end program nano
206
207