SPEED
READ_HEADER.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
62
63 subroutine read_header(headerfile,gridfile,matefile,mpifile,monfile,bkpfile,sdoffile, &
64 time_step,start_time,stop_time,&
65 option_out_var,&
66 trestart,&
67 ndt_monitor,&
68 deltat_fixed,&
69 depth_search_mon_pgm,ndt_mon_pgm,n_pgm,&
70 rotation_angle_mon_pgm,monfile_pgm,&
71 depth_search_mon_lst,n_lst,monfile_lst, &
72 depth_search_sys_lst,s_lst,sysfile_lst,&
73 dg_c,pen_c, scheme, order, stages, testmode, &
74 ntime_err, time_err, damping_type, &
75 n_testcase, tag_testcase, &
76 b_failoncoeffs, b_setuponly, b_failCFL, b_instabilitycontrol, instability_maxval)
77
80
81 implicit none
82
83 character*70 :: headerfile,gridfile,matefile,mpifile,monfile,bkpfile,sdoffile
84 character*70 :: inline
85 character*10 :: scheme
86 character*8 :: keyword
87 character*3 :: deltat_fixed
88
89 integer*4 :: testmode, trestart
90 integer*4 :: status, dummy
91 integer*4 :: ileft,iright, order, stages
92 integer*4 :: arglen
93 integer*4 :: i,j,im,is
94 integer*4 :: ndt_monitor
95 integer*4 :: ndt_mon_pgm,n_pgm
96 integer*4 :: monfile_pgm
97 integer*4 :: n_lst, s_lst, ntime_err, itime, n_testcase, tag_testcase
98 integer*4 :: monfile_lst, sysfile_lst, damping_type
99 integer*4 :: file_row = 0
100
101 integer*4, dimension (6) :: option_out_var
102
103 real*8 :: val,dg_c, pen_c
104 real*8 :: time_step,start_time,stop_time
105 real*8 :: depth_search_mon_pgm
106 real*8 :: rotation_angle_mon_pgm
107 real*8 :: depth_search_mon_lst, depth_search_sys_lst
108
109
110 real*8, dimension(ntime_err) :: time_err
111
112 ! If .TRUE., fails when a mandatory argument is missing
113 logical :: b_fail_unset_args = .false.
114
115 ! New settings
116 ! Instability
117 real*8 :: instability_maxval
118 logical :: b_instabilitycontrol
119 logical :: b_failoncoeffs, b_setuponly, b_failCFL
120
121
122 im = 0; is = 0; itime = 0;
123 n_pgm = 0; monfile_pgm = 0
124 n_lst = 0; monfile_lst = 0
125 s_lst = 0; sysfile_lst = 0; sdofout = 0; flag_outatalldofs = 0;
126 n_testcase = 0;
127
128 time_err = 0
129
130
131 open(40,file=headerfile)
132
133 do
134 read(40,'(A)',iostat = status) inline
135 file_row = file_row + 1
136
137 if (status.ne.0) exit
138
139 ! Skip comments
140 if (inline(1:1) .eq. ' ') then
141 cycle
142 endif
143
144 !!!! Parse keyword arguments
145 ileft = 1
146 iright = len_trim(inline)
147
148 ! Compute index to first non-keyword argument
149 do i = 1,iright
150 if (inline(i:i) .eq.' ') exit
151 enddo
152 ileft = i + 1
153 keyword = inline(1:(ileft-2))
154
155 ! Now ileft points after the first blank
156 arglen = len_trim(inline(ileft:iright))
157
158! write(*,*) 'keyword=', keyword, ' inline= ', inline
159! write(*,*) 'ileft= ', ileft, ' iright= ', iright, ' arglen=', arglen
160! write(*,*) 'inline(ileft:iright)=', inline(ileft:iright)
161! write(*,*)
162
163 ! Remove this for keywords without arguments!
164 if (arglen .eq. 0) then
165 write(*,'(A,I3,A,A,A)') 'FATAL in SPEED.input, row', file_row, ': no argument given for command "', trim(keyword), '"'
166 call exit(exit_syntax_error)
167 endif
168
169! write(*,*) 'Comparing ', inline(1:(ileft-2)), ', ileft=', ileft
170
171 select case (keyword)
172
173 case('GRIDFILE')
174 read(inline(ileft:iright),*) gridfile
175
176 case('DGMETHOD')
177 read(inline(ileft:iright),*) dg_c
178
179 case('PENALIZC')
180 read(inline(ileft:iright),*) pen_c
181
182 case('TIMESTEP')
183 read(inline(ileft:iright),*) time_step
184
185 case('STARTIME')
186 read(inline(ileft:iright),*) start_time
187
188 case('STOPTIME')
189 read(inline(ileft:iright),*) stop_time
190
191 case('RESTART')
192 !is = is +1
193 read(inline(ileft:iright),*) trestart
194
195 case('TIMEFIXE')
196 read(inline(ileft:iright),*) time_step
197 deltat_fixed = 'not'
198
199 case('TMONITOR')
200 read(inline(ileft:iright),*) ndt_monitor
201
202 case('TIMESCHM')
203 read(inline(ileft:iright),*) scheme, order, stages
204
205 case('TESTMODE')
206 testmode = 1
207
208 case('MATFILE')
209 read(inline(ileft:iright),*) matefile
210
211 case('MPIFILE')
212 read(inline(ileft:iright),*) mpifile
213
214 case('MONFILE')
215 read(inline(ileft:iright),*) monfile
216
217 case('BKPFILE')
218 read(inline(ileft:iright),*) bkpfile
219
220 case('SDOFFILE') !!! AH
221 read(inline(ileft:iright),*) sdoffile !!! location folder for sdof files
222
223 case('OPTIOUT')
224 read(inline(ileft:iright),*) option_out_var(1),option_out_var(2),&
225 option_out_var(3), option_out_var(4),option_out_var(5),option_out_var(6)
226
227 case('SDOFOUT') !!! AH
228 read(inline(ileft:iright),*) flag_outatalldofs, sdofout(1),sdofout(2),sdofout(3)
229
230 case('TIMEERR')
231 itime = itime + 1
232 read(inline(ileft:iright),*) time_err(itime)
233
234 case('DAMPING')
235 read(inline(ileft:iright),*) damping_type
236
237
238 case('PGDM')
239 n_pgm = 1
240 read(inline(ileft:iright),*) depth_search_mon_pgm, &
241 ndt_mon_pgm,rotation_angle_mon_pgm,monfile_pgm
242
243 case('MLST')
244 n_lst = 1
245 read(inline(ileft:iright),*) depth_search_mon_lst,monfile_lst
246
247 case('SYSLST') !!! AH
248 s_lst = 1
249 read(inline(ileft:iright),*) depth_search_sys_lst,sysfile_lst
250 sysfile_lst = 0
251 !Sri - since we are applying SDOF reaction forces at nearest LGL node (on ground surface)
252 ! Not allocating the SDOF inside any element now,
253 ! so we dont need SDOF coorinates in reference coordinates of consisting element
254
255 case('TESTCASE')
256 n_testcase = 1
257 read(inline(ileft:iright),*) tag_testcase
258
259 !! New flags
260
261 case('FAILCFL')
262 ! If specified as "FAILCFL T", quit if CFL condition does not hold
263 read(inline(ileft:(ileft+arglen)),'(L)') b_failcfl
264
265 case('FAILINST')
266 ! If specified as "FAILINST T", enable instability control
267 read(inline(ileft:iright),*) b_instabilitycontrol
268
269 case('SETUPONL')
270 ! If specified as "SETUPONL T", quit before starting the time loop
271 read(inline(ileft:iright),*) b_setuponly
272
273 case('FAILCOEF')
274 ! If specified as "FAILCOEF T", quit if any of the computed
275 ! anelastic coefficients is negative [damping 2]
276 read(inline(ileft:iright),*) b_failoncoeffs
277
278 case('INSTVAL')
279 ! If specified, overwrite preset instability threshold
280 read(inline(ileft:iright),*) instability_maxval
281 !b_instabilitycontrol = .true.
282
283 ! Ignored keywords (for compatibility)
284 case('r_f')
285 write(*,'(A,I3,A,A)') 'In SPEED.input, row', file_row, ': ignored field ', keyword
286
287 case('DEBUG')
288 read(inline(ileft:iright),*) dummy
289
290 ! Fail if keyword is not recognised
291 case default
292 write(*,'(A,I3,A,A)') 'FATAL in SPEED.input, row', file_row, ': unknown keyword ', keyword
293 call exit(exit_syntax_error)
294
295 end select
296
297 enddo
298
299
300! Snapshots reordering
301
302! if (nsnapshots.gt.1) then
303! do i = 1,nsnapshots-1
304! do j = i+1, nsnapshots
305! if (t_snapshot(i).gt.t_snapshot(j)) then
306! val = t_snapshot(i)
307! t_snapshot(i) = t_snapshot(j)
308! t_snapshot(j) = val
309! endif
310! enddo
311! enddo
312! endif
313
314 close(40)
315
316 return
317 end subroutine read_header
318
SPEED exit codes.
Definition MODULES.f90:25
integer, parameter exit_syntax_error
Definition MODULES.f90:37
Contains parameters for MDOF.
Definition MODULES.f90:725
integer *4, dimension(3) sdofout
displ, acc, f_react
Definition MODULES.f90:776
integer *4 flag_outatalldofs
Definition MODULES.f90:777