-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.f90
164 lines (127 loc) · 4.26 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
159
160
161
162
163
164
!Crown Copyright 2014 AWE.
!
! This file is part of TeaLeaf.
!
! TeaLeaf 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.
!
! TeaLeaf 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
! TeaLeaf. If not, see http://www.gnu.org/licenses/.
!> @brief Main set up routine
!> @author David Beckingsale, 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 and primes the halo cells and writes an initial field summary.
SUBROUTINE start
USE tea_module
USE parse_module
USE update_halo_module
USE definitions_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
dt = dtinit
CALL tea_barrier
CALL tea_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 tea_decompose(grid%x_cells,grid%y_cells,left,right,bottom,top)
DO c=1,chunks_per_task
! Needs changing so there can be more than 1 chunk per task
chunks(c)%task = parallel%task
!chunk_task_responsible_for = parallel%task+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 tea_barrier
! Substitute for PETSc Setup Call
IF(use_trilinos_kernels)THEN
DO c=1,chunks_per_task
CALL setup_trilinos(grid%x_cells, &
grid%y_cells, &
chunks(c)%field%x_max, &
chunks(c)%field%y_max, &
chunks(c)%field%left, &
chunks(c)%field%right, &
chunks(c)%field%bottom,&
chunks(c)%field%top, &
(grid%xmax-grid%xmin)/ &
float(grid%x_cells), &
(grid%ymax-grid%ymin)/ &
float(grid%y_cells), &
max_iters, eps)
ENDDO
ENDIF
DO c=1,chunks_per_task
IF(chunks(c)%task.EQ.parallel%task)THEN
CALL tea_allocate_buffers(c)
ENDIF
ENDDO
DO c=1,chunks_per_task
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,chunks_per_task
IF(chunks(c)%task.EQ.parallel%task)THEN
CALL generate_chunk(c)
ENDIF
ENDDO
CALL tea_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.
! Prime all halo data for the first step
fields=0
fields(FIELD_DENSITY)=1
fields(FIELD_ENERGY0)=1
fields(FIELD_ENERGY1)=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 tea_barrier
profiler_on=profiler_off
END SUBROUTINE start