forked from UK-MAC/CloverLeaf_ref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.f90
151 lines (105 loc) · 3.31 KB
/
start.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
!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 Main set up routine
!> @author Wayne Gaudin
!> @details Invokes the mesh decomposer and sets up chunk connectivity. It then
!> allocates the communication buffers and call the chunk initialisation and
!> generation routines. It calls the equation of state to calculate initial
!> pressure before priming the halo cells and writing an initial field summary.
SUBROUTINE start
USE clover_module
USE parse_module
USE update_halo_module
USE ideal_gas_module
IMPLICIT NONE
INTEGER :: c, tile
INTEGER :: x_cells,y_cells
INTEGER:: right,left,top,bottom
INTEGER :: fields(NUM_FIELDS) !, chunk_task_responsible_for
LOGICAL :: profiler_off
IF(parallel%boss)THEN
WRITE(g_out,*) 'Setting up initial geometry'
WRITE(g_out,*)
ENDIF
time = 0.0
step = 0
dtold = dtinit
dt = dtinit
CALL clover_barrier
CALL clover_get_num_chunks(number_of_chunks)
CALL clover_decompose(grid%x_cells,grid%y_cells,left,right,bottom,top)
!create the chunks
chunk%task = parallel%task
!chunk_task_responsible_for = parallel%task+1
x_cells = right -left +1
y_cells = top -bottom+1
chunk%left = left
chunk%bottom = bottom
chunk%right = right
chunk%top = top
chunk%left_boundary = 1
chunk%bottom_boundary = 1
chunk%right_boundary = grid%x_cells
chunk%top_boundary = grid%y_cells
chunk%x_min = 1
chunk%y_min = 1
chunk%x_max = x_cells
chunk%y_max = y_cells
! create the tiles
ALLOCATE( chunk%tiles(1:tiles_per_chunk) )
CALL clover_tile_decompose(x_cells, y_cells)
CALL build_field()
CALL clover_barrier
CALL clover_allocate_buffers()
IF(parallel%boss)THEN
WRITE(g_out,*) 'Generating chunks'
ENDIF
DO tile=1,tiles_per_chunk
CALL initialise_chunk(tile)
CALL generate_chunk(tile)
ENDDO
advect_x=.TRUE.
CALL clover_barrier
! Do no profile the start up costs otherwise the total times will not add up
! at the end
profiler_off=profiler_on
profiler_on=.FALSE.
DO tile = 1, tiles_per_chunk
CALL ideal_gas(tile,.FALSE.)
END DO
! Prime all halo data for the first step
fields=0
fields(FIELD_DENSITY0)=1
fields(FIELD_ENERGY0)=1
fields(FIELD_PRESSURE)=1
fields(FIELD_VISCOSITY)=1
fields(FIELD_DENSITY1)=1
fields(FIELD_ENERGY1)=1
fields(FIELD_XVEL0)=1
fields(FIELD_YVEL0)=1
fields(FIELD_XVEL1)=1
fields(FIELD_YVEL1)=1
CALL update_halo(fields,2)
IF(parallel%boss)THEN
WRITE(g_out,*)
WRITE(g_out,*) 'Problem initialised and generated'
ENDIF
CALL field_summary()
IF(visit_frequency.NE.0) CALL visit()
CALL clover_barrier
profiler_on=profiler_off
END SUBROUTINE start