-
Notifications
You must be signed in to change notification settings - Fork 5
/
field_summary.f90
135 lines (119 loc) · 5.49 KB
/
field_summary.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
!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 Driver for the field summary kernels
!> @author Wayne Gaudin
!> @details The user specified field summary kernel is invoked here. A summation
!> across all mesh chunks is then performed and the information outputed.
!> If the run is a test problem, the final result is compared with the expected
!> result and the difference output.
!> Note the reference solution is the value returned from an Intel compiler with
!> ieee options set on a single core crun.
SUBROUTINE field_summary()
USE clover_module
USE ideal_gas_module
USE field_summary_kernel_module
IMPLICIT NONE
REAL(KIND=8) :: vol,mass,ie,ke,press
REAL(KIND=8) :: qa_diff
!$ INTEGER :: OMP_GET_THREAD_NUM
INTEGER :: c
REAL(KIND=8) :: kernel_time,timer
IF(parallel%boss)THEN
WRITE(g_out,*)
WRITE(g_out,*) 'Time ',time
WRITE(g_out,'(a13,7a16)')' ','Volume','Mass','Density','Pressure','Internal Energy','Kinetic Energy','Total Energy'
ENDIF
IF(profiler_on) kernel_time=timer()
DO c=1,number_of_chunks
CALL ideal_gas(c,.FALSE.)
ENDDO
IF(profiler_on) profiler%ideal_gas=profiler%ideal_gas+(timer()-kernel_time)
IF(profiler_on) kernel_time=timer()
IF(use_fortran_kernels)THEN
DO c=1,number_of_chunks
IF(chunks(c)%task.EQ.parallel%task) THEN
CALL field_summary_kernel(chunks(c)%field%x_min, &
chunks(c)%field%x_max, &
chunks(c)%field%y_min, &
chunks(c)%field%y_max, &
chunks(c)%field%volume, &
chunks(c)%field%density0, &
chunks(c)%field%energy0, &
chunks(c)%field%pressure, &
chunks(c)%field%xvel0, &
chunks(c)%field%yvel0, &
vol,mass,ie,ke,press )
ENDIF
ENDDO
ELSEIF(use_cuda_kernels)THEN
DO c=1,number_of_chunks
IF(chunks(c)%task.EQ.parallel%task) THEN
CALL field_summary_kernel_cuda(vol,mass,ie,ke,press)
ENDIF
ENDDO
ELSEIF(use_C_kernels)THEN
DO c=1,number_of_chunks
IF(chunks(c)%task.EQ.parallel%task) THEN
CALL field_summary_kernel_c(chunks(c)%field%x_min, &
chunks(c)%field%x_max, &
chunks(c)%field%y_min, &
chunks(c)%field%y_max, &
chunks(c)%field%volume, &
chunks(c)%field%density0, &
chunks(c)%field%energy0, &
chunks(c)%field%pressure, &
chunks(c)%field%xvel0, &
chunks(c)%field%yvel0, &
vol,mass,ie,ke,press )
ENDIF
ENDDO
ENDIF
! For mpi I need a reduction here
CALL clover_sum(vol)
CALL clover_sum(mass)
CALL clover_sum(press)
CALL clover_sum(ie)
CALL clover_sum(ke)
IF(profiler_on) profiler%summary=profiler%summary+(timer()-kernel_time)
IF(parallel%boss) THEN
!$ IF(OMP_GET_THREAD_NUM().EQ.0) THEN
WRITE(g_out,'(a6,i7,7e16.4)')' step:',step,vol,mass,mass/vol,press/vol,ie,ke,ie+ke
WRITE(g_out,*)
!$ ENDIF
ENDIF
!Check if this is the final call and if it is a test problem, check the result.
IF(complete) THEN
IF(parallel%boss) THEN
IF(test_problem.GE.1) THEN
IF(test_problem.EQ.1) qa_diff=ABS((100.0_8*(ke/1.82280367310258_8))-100.0_8)
IF(test_problem.EQ.2) qa_diff=ABS((100.0_8*(ke/1.19316898756307_8))-100.0_8)
IF(test_problem.EQ.3) qa_diff=ABS((100.0_8*(ke/2.58984003503994_8))-100.0_8)
IF(test_problem.EQ.4) qa_diff=ABS((100.0_8*(ke/0.307475452287895_8))-100.0_8)
IF(test_problem.EQ.5) qa_diff=ABS((100.0_8*(ke/4.85350315783719_8))-100.0_8)
WRITE(*,'(a,i4,a,e16.7,a)')"Test problem", Test_problem," is within",qa_diff,"% of the expected solution"
WRITE(g_out,'(a,i4,a,e16.7,a)')"Test problem", Test_problem," is within",qa_diff,"% of the expected solution"
IF(qa_diff.LT.0.001) THEN
WRITE(*,*)"This test is considered PASSED"
WRITE(g_out,*)"This test is considered PASSED"
ELSE
WRITE(*,*)"This test is considered NOT PASSED"
WRITE(g_out,*)"This is test is considered NOT PASSED"
ENDIF
ENDIF
ENDIF
ENDIF
END SUBROUTINE field_summary