-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_field.f90
189 lines (147 loc) · 8.7 KB
/
build_field.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
!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 Allocates the data for each mesh chunk
!> @author Wayne Gaudin
!> @details The data fields for the mesh chunk are allocated based on the mesh
!> size.
SUBROUTINE build_field()
USE clover_module
IMPLICIT NONE
INTEGER :: tile,j,k
DO tile=1, tiles_per_chunk
ALLOCATE(chunk%tiles(tile)%field%density0 (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%density1 (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%energy0 (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
! print *, 'fb:', chunk%tiles(tile)%t_xmin-2, ' ', chunk%tiles(tile)%t_xmax+2, &
! 'sb', chunk%tiles(tile)%t_ymin-2, ' ', chunk%tiles(tile)%t_ymax+2
ALLOCATE(chunk%tiles(tile)%field%energy1 (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%pressure (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%viscosity (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%soundspeed(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%xvel0(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%xvel1(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%yvel0(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%yvel1(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%vol_flux_x (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%mass_flux_x(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%vol_flux_y (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%mass_flux_y(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array1(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array2(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array3(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array4(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array5(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array6(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%work_array7(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%cellx (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2))
ALLOCATE(chunk%tiles(tile)%field%celly (chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%vertexx (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3))
ALLOCATE(chunk%tiles(tile)%field%vertexy (chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%celldx (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2))
ALLOCATE(chunk%tiles(tile)%field%celldy (chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%vertexdx(chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3))
ALLOCATE(chunk%tiles(tile)%field%vertexdy(chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
ALLOCATE(chunk%tiles(tile)%field%volume (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%xarea (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+3, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+2))
ALLOCATE(chunk%tiles(tile)%field%yarea (chunk%tiles(tile)%t_xmin-2:chunk%tiles(tile)%t_xmax+2, &
chunk%tiles(tile)%t_ymin-2:chunk%tiles(tile)%t_ymax+3))
! Zeroing isn't strictly neccessary but it ensures physical pages
! are allocated. This prevents first touch overheads in the main code
! cycle which can skew timings in the first step
DO k=chunk%tiles(tile)%t_ymin-2,chunk%tiles(tile)%t_ymax+3
DO j=chunk%tiles(tile)%t_xmin-2,chunk%tiles(tile)%t_xmax+3
chunk%tiles(tile)%field%work_array1(j,k)=0.0
chunk%tiles(tile)%field%work_array2(j,k)=0.0
chunk%tiles(tile)%field%work_array3(j,k)=0.0
chunk%tiles(tile)%field%work_array4(j,k)=0.0
chunk%tiles(tile)%field%work_array5(j,k)=0.0
chunk%tiles(tile)%field%work_array6(j,k)=0.0
chunk%tiles(tile)%field%work_array7(j,k)=0.0
chunk%tiles(tile)%field%xvel0(j,k)=0.0
chunk%tiles(tile)%field%xvel1(j,k)=0.0
chunk%tiles(tile)%field%yvel0(j,k)=0.0
chunk%tiles(tile)%field%yvel1(j,k)=0.0
ENDDO
ENDDO
DO k=chunk%tiles(tile)%t_ymin-2,chunk%tiles(tile)%t_ymax+2
DO j=chunk%tiles(tile)%t_xmin-2,chunk%tiles(tile)%t_xmax+2
chunk%tiles(tile)%field%density0(j,k)=0.0
chunk%tiles(tile)%field%density1(j,k)=0.0
chunk%tiles(tile)%field%energy0(j,k)=0.0
chunk%tiles(tile)%field%energy1(j,k)=0.0
chunk%tiles(tile)%field%pressure(j,k)=0.0
chunk%tiles(tile)%field%viscosity(j,k)=0.0
chunk%tiles(tile)%field%soundspeed(j,k)=0.0
chunk%tiles(tile)%field%volume(j,k)=0.0
ENDDO
ENDDO
DO k=chunk%tiles(tile)%t_ymin-2,chunk%tiles(tile)%t_ymax+2
DO j=chunk%tiles(tile)%t_xmin-2,chunk%tiles(tile)%t_xmax+3
chunk%tiles(tile)%field%vol_flux_x(j,k)=0.0
chunk%tiles(tile)%field%mass_flux_x(j,k)=0.0
chunk%tiles(tile)%field%xarea(j,k)=0.0
ENDDO
ENDDO
DO k=chunk%tiles(tile)%t_ymin-2,chunk%tiles(tile)%t_ymax+3
DO j=chunk%tiles(tile)%t_xmin-2,chunk%tiles(tile)%t_xmax+2
chunk%tiles(tile)%field%vol_flux_y(j,k)=0.0
chunk%tiles(tile)%field%mass_flux_y(j,k)=0.0
chunk%tiles(tile)%field%yarea(j,k)=0.0
ENDDO
ENDDO
DO j=chunk%tiles(tile)%t_xmin-2,chunk%tiles(tile)%t_xmax+2
chunk%tiles(tile)%field%cellx(j)=0.0
chunk%tiles(tile)%field%celldx(j)=0.0
ENDDO
DO k=chunk%tiles(tile)%t_ymin-2,chunk%tiles(tile)%t_ymax+2
chunk%tiles(tile)%field%celly(k)=0.0
chunk%tiles(tile)%field%celldy(k)=0.0
ENDDO
DO j=chunk%tiles(tile)%t_xmin-2,chunk%tiles(tile)%t_xmax+3
chunk%tiles(tile)%field%vertexx(j)=0.0
chunk%tiles(tile)%field%vertexdx(j)=0.0
ENDDO
DO k=chunk%tiles(tile)%t_ymin-2,chunk%tiles(tile)%t_ymax+3
chunk%tiles(tile)%field%vertexy(k)=0.0
chunk%tiles(tile)%field%vertexdy(k)=0.0
ENDDO
END DO
END SUBROUTINE build_field