This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.f90
158 lines (121 loc) · 3.91 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
152
153
154
155
156
157
158
!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
INTEGER :: x_cells,y_cells
INTEGER, ALLOCATABLE :: right(:),left(:),top(:),bottom(:)
INTEGER :: fields(NUM_FIELDS)
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)
ALLOCATE(chunks(1:number_of_chunks))
ALLOCATE(left(1:number_of_chunks))
ALLOCATE(right(1:number_of_chunks))
ALLOCATE(bottom(1:number_of_chunks))
ALLOCATE(top(1:number_of_chunks))
CALL clover_decompose(grid%x_cells,grid%y_cells,left,right,bottom,top)
DO c=1,number_of_chunks
! Needs changing so there can be more than 1 chunk per task
chunks(c)%task = c-1
x_cells = right(c) -left(c) +1
y_cells = top(c) -bottom(c)+1
IF(chunks(c)%task.EQ.parallel%task)THEN
CALL build_field(c,x_cells,y_cells)
ENDIF
chunks(c)%field%left = left(c)
chunks(c)%field%bottom = bottom(c)
chunks(c)%field%right = right(c)
chunks(c)%field%top = top(c)
chunks(c)%field%left_boundary = 1
chunks(c)%field%bottom_boundary = 1
chunks(c)%field%right_boundary = grid%x_cells
chunks(c)%field%top_boundary = grid%y_cells
chunks(c)%field%x_min = 1
chunks(c)%field%y_min = 1
chunks(c)%field%x_max = right(c)-left(c)+1
chunks(c)%field%y_max = top(c)-bottom(c)+1
ENDDO
DEALLOCATE(left,right,bottom,top)
CALL clover_barrier
DO c=1,number_of_chunks
IF(chunks(c)%task.EQ.parallel%task)THEN
CALL clover_allocate_buffers(c)
ENDIF
ENDDO
DO c=1,number_of_chunks
IF(chunks(c)%task.EQ.parallel%task)THEN
CALL initialise_chunk(c)
ENDIF
ENDDO
IF(parallel%boss)THEN
WRITE(g_out,*) 'Generating chunks'
ENDIF
DO c=1,number_of_chunks
IF(chunks(c)%task.EQ.parallel%task)THEN
CALL generate_chunk(c)
ENDIF
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 c = 1, number_of_chunks
CALL ideal_gas(c,.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