MFIX  2016-1
accum_resid.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Module name: ACCUM_RESID C
4 ! C
5 ! Purpose: Accumulate all the residuals and calculate max_resid C
6 ! C
7 ! C
8 ! Author: S. Pannala Date: 14-Jun-07 C
9 ! Reviewer: Date: C
10 ! C
11 ! C
12 ! Literature/Document References: C
13 ! C
14 ! Variables referenced: C
15 ! Variables modified: C
16 ! C
17 ! Local variables: C
18 ! C
19 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
20 !
21  SUBROUTINE accum_resid
22 !
23 !-----------------------------------------------
24 ! M o d u l e s
25 !-----------------------------------------------
26  USE param
27  USE param1
28  USE parallel
29  USE geometry
30  USE indices
31  USE compar
32  USE mpi_utility
33  USE residual
34  USE run
35  IMPLICIT NONE
36 !-----------------------------------------------
37 ! G l o b a l P a r a m e t e r s
38 !-----------------------------------------------
39 !-----------------------------------------------
40 ! D u m m y A r g u m e n t s
41 !-----------------------------------------------
42  INTEGER M, NN
43 
44 !-----------------------------------------------
45 ! Local variables
46 !-----------------------------------------------
47  INTEGER LOCAL_INDEX
48 
49 !
50  IF(debug_resid) Return
51 !
52  local_index = 0
53 
54 ! Pack the numerators and denominators into one vector for performing single global operation
55 
56 !!!$omp parallel do private( NN,M )&
57 !!!$omp& REDUCTION(+:LOCAL_INDEX)
58  DO nn = 2, nresid
59  DO m = 0, dimension_m
60  local_index = local_index + 1
61  resid_pack(local_index) = num_resid(nn,m)
62  local_index = local_index + 1
63  resid_pack(local_index) = den_resid(nn,m)
64  ENDDO
65  ENDDO
66 
68 
69 ! Unpack the numerators and denominators from the global sum vector
70 
71  local_index = 0
72 
73 !!!$omp parallel do private( NN,M )&
74 !!!$omp& REDUCTION(+:LOCAL_INDEX)
75  DO nn = 2, nresid
76  DO m = 0, dimension_m
77  local_index = local_index + 1
78  num_resid(nn,m) = resid_pack(local_index)
79  local_index = local_index + 1
80  den_resid(nn,m) = resid_pack(local_index)
81  ENDDO
82  ENDDO
83 
84 !!!$omp parallel do private( NN,M )
85  DO nn = 2, nresid
86  DO m = 0, dimension_m
87  IF (den_resid(nn,m) > zero) THEN
88  resid(nn,m) = num_resid(nn,m)/den_resid(nn,m)
89  ELSE IF (num_resid(nn,m) == zero) THEN
90  resid(nn,m) = zero
91  ELSE
92  resid(nn,m) = undefined
93 ! WRITE (LINE, *) 'Warning: All center coefficients are zero.'
94 ! CALL WRITE_ERROR ('ACCUM_RESID', LINE, 1)
95  ENDIF
96  ENDDO
97  ENDDO
98 
99  RETURN
100  END
double precision, dimension(:,:), allocatable den_resid
Definition: residual_mod.f:52
subroutine accum_resid
Definition: accum_resid.f:22
integer, parameter nresid
Definition: residual_mod.f:18
double precision, dimension(:,:), allocatable num_resid
Definition: residual_mod.f:49
double precision, parameter undefined
Definition: param1_mod.f:18
double precision, dimension(:), allocatable resid_pack
Definition: residual_mod.f:55
Definition: run_mod.f:13
Definition: param_mod.f:2
double precision, dimension(:,:), allocatable resid
Definition: residual_mod.f:37
integer dimension_m
Definition: param_mod.f:18
double precision, parameter zero
Definition: param1_mod.f:27
logical debug_resid
Definition: run_mod.f:244