-
Notifications
You must be signed in to change notification settings - Fork 1
/
hydro.f90
executable file
·307 lines (262 loc) · 12.2 KB
/
hydro.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
!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 Controls the main hydro cycle.
!> @author Wayne Gaudin
!> @details Controls the top level cycle, invoking all the drivers and checks
!> for outputs and completion.
MODULE hydro_cycle_module
CONTAINS
SUBROUTINE hydro_cycle(c, &
x_min, &
x_max, &
y_min, &
y_max, &
density0, &
density1, &
energy0, &
energy1, &
pressure, &
soundspeed, &
viscosity, &
xvel0, &
yvel0, &
xvel1, &
yvel1, &
vol_flux_x, &
vol_flux_y, &
mass_flux_x, &
mass_flux_y, &
volume, &
work_array1, &
work_array2, &
work_array3, &
work_array4, &
work_array5, &
work_array6, &
work_array7, &
cellx, &
celly, &
celldx, &
celldy, &
vertexx, &
vertexdx, &
vertexy, &
vertexdy, &
xarea, &
yarea, &
left_snd_buffer, &
left_rcv_buffer, &
right_snd_buffer, &
right_rcv_buffer, &
bottom_snd_buffer, &
bottom_rcv_buffer, &
top_snd_buffer, &
top_rcv_buffer)
USE clover_module
USE timestep_module
USE viscosity_module
USE PdV_module
USE accelerate_module
USE flux_calc_module
USE advection_module
USE reset_field_module
IMPLICIT NONE
INTEGER :: c,x_min,x_max,y_min,y_max
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: density0
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: density1
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: energy0
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: energy1
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: soundspeed
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: pressure
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: viscosity
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: xvel0
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: yvel0
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: xvel1
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: yvel1
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+2) :: vol_flux_x
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+3) :: vol_flux_y
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+2) :: mass_flux_x
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+3) :: mass_flux_y
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+2) :: volume
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array1
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array2
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array3
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array4
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array5
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array6
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+3) :: work_array7
REAL(KIND=8), DIMENSION(x_min-2:x_max+2) :: cellx
REAL(KIND=8), DIMENSION(y_min-2:y_max+2) :: celly
REAL(KIND=8), DIMENSION(x_min-2:x_max+2) :: celldx
REAL(KIND=8), DIMENSION(y_min-2:y_max+2) :: celldy
REAL(KIND=8), DIMENSION(x_min-2:x_max+3) :: vertexx
REAL(KIND=8), DIMENSION(x_min-2:x_max+3) :: vertexdx
REAL(KIND=8), DIMENSION(y_min-2:y_max+3) :: vertexy
REAL(KIND=8), DIMENSION(y_min-2:y_max+3) :: vertexdy
REAL(KIND=8), DIMENSION(x_min-2:x_max+3 ,y_min-2:y_max+2) :: xarea
REAL(KIND=8), DIMENSION(x_min-2:x_max+2 ,y_min-2:y_max+3) :: yarea
REAL(KIND=8) :: left_snd_buffer(:),left_rcv_buffer(:),right_snd_buffer(:),right_rcv_buffer(:)
REAL(KIND=8) :: bottom_snd_buffer(:),bottom_rcv_buffer(:),top_snd_buffer(:),top_rcv_buffer(:)
INTEGER :: cells
REAL(KIND=8) :: timer,timerstart
REAL(KIND=8) :: grind_time
REAL(KIND=8) :: step_time,step_grind
!DIR$ OFFLOAD_TRANSFER TARGET(MIC:g_mic_device) &
!DIR$ IN(density0 : free_if(.false.)) &
!DIR$ IN(density1 : free_if(.false.)) &
!DIR$ IN(energy0 : free_if(.false.)) &
!DIR$ IN(energy1 : free_if(.false.)) &
!DIR$ IN(pressure : free_if(.false.)) &
!DIR$ IN(viscosity : free_if(.false.)) &
!DIR$ IN(soundspeed : free_if(.false.)) &
!DIR$ IN(xvel0 : free_if(.false.)) &
!DIR$ IN(xvel1 : free_if(.false.)) &
!DIR$ IN(yvel0 : free_if(.false.)) &
!DIR$ IN(yvel1 : free_if(.false.)) &
!DIR$ IN(vol_flux_x : free_if(.false.)) &
!DIR$ IN(mass_flux_x : free_if(.false.)) &
!DIR$ IN(vol_flux_y : free_if(.false.)) &
!DIR$ IN(mass_flux_y : free_if(.false.)) &
!DIR$ IN(work_array1 : free_if(.false.)) &
!DIR$ IN(work_array2 : free_if(.false.)) &
!DIR$ IN(work_array3 : free_if(.false.)) &
!DIR$ IN(work_array4 : free_if(.false.)) &
!DIR$ IN(work_array5 : free_if(.false.)) &
!DIR$ IN(work_array6 : free_if(.false.)) &
!DIR$ IN(work_array7 : free_if(.false.)) &
!DIR$ IN(volume : free_if(.false.)) &
!DIR$ IN(xarea : free_if(.false.)) &
!DIR$ IN(yarea : free_if(.false.)) &
!DIR$ IN(cellx : free_if(.false.)) &
!DIR$ IN(celly : free_if(.false.)) &
!DIR$ IN(celldx : free_if(.false.)) &
!DIR$ IN(celldy : free_if(.false.)) &
!DIR$ IN(vertexx : free_if(.false.)) &
!DIR$ IN(vertexdx : free_if(.false.)) &
!DIR$ IN(vertexy : free_if(.false.)) &
!DIR$ IN(vertexdy : free_if(.false.)) &
!DIR$ IN(left_snd_buffer : free_if(.false.)) &
!DIR$ IN(left_rcv_buffer : free_if(.false.)) &
!DIR$ IN(right_snd_buffer : free_if(.false.)) &
!DIR$ IN(right_rcv_buffer : free_if(.false.)) &
!DIR$ IN(bottom_snd_buffer : free_if(.false.)) &
!DIR$ IN(bottom_rcv_buffer : free_if(.false.)) &
!DIR$ IN(top_snd_buffer : free_if(.false.)) &
!DIR$ IN(top_rcv_buffer : free_if(.false.))
timerstart = timer()
DO
step_time = timer()
step = step + 1
CALL timestep()
CALL PdV(.TRUE.)
CALL accelerate()
CALL PdV(.FALSE.)
CALL flux_calc()
CALL advection()
CALL reset_field()
advect_x = .NOT. advect_x
time = time + dt
IF(summary_frequency.NE.0) THEN
IF(MOD(step, summary_frequency).EQ.0) CALL field_summary()
ENDIF
IF(visit_frequency.NE.0) THEN
IF(MOD(step, visit_frequency).EQ.0) CALL visit()
ENDIF
IF(time+g_small.GT.end_time.OR.step.GE.end_step) THEN
complete=.TRUE.
CALL field_summary()
IF(visit_frequency.NE.0) CALL visit()
IF ( parallel%boss ) THEN
WRITE(g_out,*)
WRITE(g_out,*) 'Calculation complete'
WRITE(g_out,*) 'Clover is finishing'
WRITE(g_out,*) 'Wall clock ', timer() - timerstart
WRITE( 0,*) 'Wall clock ', timer() - timerstart
ENDIF
CALL clover_finalize
EXIT
END IF
IF (parallel%boss) THEN
WRITE(g_out,*)"Wall clock ",timer()-timerstart
WRITE(0 ,*)"Wall clock ",timer()-timerstart
cells = grid%x_cells * grid%y_cells
grind_time = (timer() - timerstart) / (step * cells)
step_grind = (timer() - step_time)/cells
WRITE(0 ,*)"Average time per cell ",grind_time
WRITE(g_out,*)"Average time per cell ",grind_time
WRITE(0 ,*)"Step time per cell ",step_grind
WRITE(g_out,*)"Step time per cell ",step_grind
END IF
END DO
END SUBROUTINE hydro_cycle
END MODULE hydro_cycle_module
SUBROUTINE hydro
USE clover_module
USE hydro_cycle_module
IMPLICIT NONE
INTEGER :: cells
REAL(KIND=8) :: timer,timerstart
REAL(KIND=8) :: grind_time
REAL(KIND=8) :: step_time,step_grind
timerstart = timer()
CALL hydro_cycle(parallel%task+1, &
chunks(parallel%task+1)%field%x_min, &
chunks(parallel%task+1)%field%x_max, &
chunks(parallel%task+1)%field%y_min, &
chunks(parallel%task+1)%field%y_max, &
chunks(parallel%task+1)%field%density0, &
chunks(parallel%task+1)%field%density1, &
chunks(parallel%task+1)%field%energy0, &
chunks(parallel%task+1)%field%energy1, &
chunks(parallel%task+1)%field%pressure, &
chunks(parallel%task+1)%field%soundspeed, &
chunks(parallel%task+1)%field%viscosity, &
chunks(parallel%task+1)%field%xvel0, &
chunks(parallel%task+1)%field%yvel0, &
chunks(parallel%task+1)%field%xvel1, &
chunks(parallel%task+1)%field%yvel1, &
chunks(parallel%task+1)%field%vol_flux_x, &
chunks(parallel%task+1)%field%vol_flux_y, &
chunks(parallel%task+1)%field%mass_flux_x,&
chunks(parallel%task+1)%field%mass_flux_y,&
chunks(parallel%task+1)%field%volume, &
chunks(parallel%task+1)%field%work_array1,&
chunks(parallel%task+1)%field%work_array2,&
chunks(parallel%task+1)%field%work_array3,&
chunks(parallel%task+1)%field%work_array4,&
chunks(parallel%task+1)%field%work_array5,&
chunks(parallel%task+1)%field%work_array6,&
chunks(parallel%task+1)%field%work_array7,&
chunks(parallel%task+1)%field%cellx, &
chunks(parallel%task+1)%field%celly, &
chunks(parallel%task+1)%field%celldx, &
chunks(parallel%task+1)%field%celldy, &
chunks(parallel%task+1)%field%vertexx, &
chunks(parallel%task+1)%field%vertexdx, &
chunks(parallel%task+1)%field%vertexy, &
chunks(parallel%task+1)%field%vertexdy, &
chunks(parallel%task+1)%field%xarea, &
chunks(parallel%task+1)%field%yarea, &
chunks(parallel%task+1)%left_snd_buffer, &
chunks(parallel%task+1)%left_rcv_buffer, &
chunks(parallel%task+1)%right_snd_buffer, &
chunks(parallel%task+1)%right_rcv_buffer, &
chunks(parallel%task+1)%bottom_snd_buffer,&
chunks(parallel%task+1)%bottom_rcv_buffer,&
chunks(parallel%task+1)%top_snd_buffer, &
chunks(parallel%task+1)%top_rcv_buffer)
END SUBROUTINE hydro