-
Notifications
You must be signed in to change notification settings - Fork 5
/
read_input.f90
276 lines (242 loc) · 9.27 KB
/
read_input.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
!Crown Copyright 2012 AWE.
!
! This file is part of CloverLeaf.
!
! CloverLeaf is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the
! Free Software Foundation, either version 3 of the License, or (at your option)
! any later version.
!
! CloverLeaf is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! CloverLeaf. If not, see http://www.gnu.org/licenses/.
!> @brief Reads the user input
!> @author Wayne Gaudin
!> @details Reads and parses the user input from the processed file and sets
!> the variables used in the generation phase. Default values are also set
!> here.
SUBROUTINE read_input()
USE clover_module
USE parse_module
USE report_module
IMPLICIT NONE
INTEGER :: state,stat,state_max,n
REAL(KIND=8) :: dx,dy
CHARACTER(LEN=500) :: word
test_problem=0
state_max=0
grid%xmin= 0.0
grid%ymin= 0.0
grid%xmax=100.0
grid%ymax=100.0
grid%x_cells=10
grid%y_cells=10
end_time=10.0
end_step=g_ibig
complete=.FALSE.
visit_frequency=0
summary_frequency=10
dtinit=0.1
dtmax=1.0
dtmin=0.0000001
dtrise=1.5
dtc_safe=0.7
dtu_safe=0.5
dtv_safe=0.5
dtdiv_safe=0.7
use_fortran_kernels=.TRUE.
use_C_kernels=.FALSE.
use_cuda_kernels=.FALSE.
use_vector_loops=.FALSE.
profiler_on=.FALSE.
profiler%timestep=0.0
profiler%acceleration=0.0
profiler%PdV=0.0
profiler%cell_advection=0.0
profiler%mom_advection=0.0
profiler%viscosity=0.0
profiler%ideal_gas=0.0
profiler%visit=0.0
profiler%summary=0.0
profiler%reset=0.0
profiler%revert=0.0
profiler%flux=0.0
profiler%halo_exchange=0.0
IF(parallel%boss)WRITE(g_out,*) 'Reading input file'
IF(parallel%boss)WRITE(g_out,*)
stat=parse_init(g_in,'*clover')
DO
stat=parse_getline(dummy)
IF (stat.ne.0) exit
DO
word=parse_getword(.FALSE.)
IF(word.EQ.'')EXIT
IF (word.EQ.'state') THEN
state_max=MAX(state_max,parse_getival(parse_getword(.TRUE.)))
EXIT
ENDIF
ENDDO
ENDDO
number_of_states=state_max
IF(number_of_states.LT.1) CALL report_error('read_input','No states defined.')
stat=parse_init(g_in,'*clover')
ALLOCATE(states(number_of_states))
states(:)%defined=.FALSE.
states(:)%energy=0.0
states(:)%density=0.0
states(:)%xvel=0.0
states(:)%yvel=0.0
DO
stat=parse_getline(dummy)
IF(stat.NE.0)EXIT
DO
word=parse_getword(.FALSE.)
IF(word.EQ.'')EXIT
SELECT CASE(word)
CASE('initial_timestep')
dtinit=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'initial_timestep ',dtinit
CASE('max_timestep')
dtmax=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'max_timestep',dtinit
CASE('timestep_rise')
dtrise=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'timestep_rise',dtrise
CASE('end_time')
end_time=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'end_time',end_time
CASE('end_step')
end_step=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,i12)")'end_step',end_step
CASE('xmin')
grid%xmin=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'xmin',grid%xmin
CASE('xmax')
grid%xmax=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'xmax',grid%xmax
CASE('ymin')
grid%ymin=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'ymin',grid%ymin
CASE('ymax')
grid%ymax=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'ymax',grid%ymax
CASE('x_cells')
grid%x_cells=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,i12)")'x_cells',grid%x_cells
CASE('y_cells')
grid%y_cells=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,i12)")'y_cells',grid%y_cells
CASE('visit_frequency')
visit_frequency=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,i12)")'visit_frequency',visit_frequency
CASE('summary_frequency')
summary_frequency=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,i12)")'summary_frequency',summary_frequency
CASE('use_fortran_kernels')
use_fortran_kernels=.TRUE.
use_C_kernels=.FALSE.
use_cuda_kernels=.FALSE.
CASE('use_c_kernels')
use_fortran_kernels=.FALSE.
use_C_kernels=.TRUE.
use_cuda_kernels=.FALSE.
CASE('use_cuda_kernels')
use_fortran_kernels=.FALSE.
use_C_kernels=.FALSE.
use_cuda_kernels=.TRUE.
CASE('use_vector_loops')
use_vector_loops=.TRUE.
CASE('profiler_on')
profiler_on=.TRUE.
IF(parallel%boss)WRITE(g_out,"(1x,a25)")'Profiler on'
CASE('test_problem')
test_problem=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,i12)")'test_problem',test_problem
CASE('state')
state=parse_getival(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,*)'Reading specification for state ',state
IF (states(state)%defined) CALL report_error('read_input','State defined twice.')
IF(parallel%boss) WRITE(g_out,*)
states(state)%defined=.TRUE.
DO
word=parse_getword(.FALSE.)
IF(word.EQ.'') EXIT
SELECT CASE(word)
CASE('xvel')
states(state)%xvel=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'xvel ',states(state)%xvel
CASE('yvel')
states(state)%yvel=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'yvel ',states(state)%yvel
CASE('xmin')
states(state)%xmin=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state xmin ',states(state)%xmin
CASE('ymin')
states(state)%ymin=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state ymin ',states(state)%ymin
CASE('xmax')
states(state)%xmax=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state xmax ',states(state)%xmax
CASE('ymax')
states(state)%ymax=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state ymax ',states(state)%ymax
CASE('radius')
states(state)%radius=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state radius ',states(state)%radius
CASE('density')
states(state)%density=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state density ',states(state)%density
CASE('energy')
states(state)%energy=parse_getrval(parse_getword(.TRUE.))
IF(parallel%boss)WRITE(g_out,"(1x,a25,e12.4)")'state energy ',states(state)%energy
CASE('geometry')
word=TRIM(parse_getword(.TRUE.))
SELECT CASE(word)
CASE("rectangle")
states(state)%geometry=g_rect
IF(parallel%boss)WRITE(g_out,"(1x,a26)")'state geometry rectangular'
CASE("circle")
states(state)%geometry=g_circ
IF(parallel%boss)WRITE(g_out,"(1x,a25)")'state geometry circular'
CASE("point")
states(state)%geometry=g_point
IF(parallel%boss)WRITE(g_out,"(1x,a25)")'state geometry point'
END SELECT
END SELECT
ENDDO
IF(parallel%boss) WRITE(g_out,*)
END SELECT
ENDDO
ENDDO
IF(parallel%boss) THEN
WRITE(g_out,*)
IF(use_fortran_kernels) THEN
WRITE(g_out,"(1x,a25)")'Using Fortran Kernels'
ELSEIF(use_c_kernels) THEN
WRITE(g_out,"(1x,a25)")'Using C Kernels'
ELSEIF(use_cuda_kernels) THEN
WRITE(g_out,"(1x,a25)")'Using CUDA Kernels'
ENDIF
WRITE(g_out,*)
WRITE(g_out,*) 'Input read finished.'
WRITE(g_out,*)
ENDIF
! If a state boundary falls exactly on a cell boundary then round off can
! cause the state to be put one cell further that expected. This is compiler
! /system dependent. To avoid this, a state boundary is reduced/increased by a 100th
! of a cell width so it lies well with in the intended cell.
! Because a cell is either full or empty of a specified state, this small
! modification to the state extents does not change the answers.
dx=(grid%xmax-grid%xmin)/float(grid%x_cells)
dy=(grid%ymax-grid%ymin)/float(grid%y_cells)
DO n=2,number_of_states
states(n)%xmin=states(n)%xmin+(dx/100.0)
states(n)%ymin=states(n)%ymin+(dy/100.0)
states(n)%xmax=states(n)%xmax-(dx/100.0)
states(n)%ymax=states(n)%ymax-(dy/100.0)
ENDDO
END SUBROUTINE read_input