1 |
jmc |
1.7 |
C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagnostics_fract_fill.F,v 1.6 2009/09/03 20:46:12 jmc Exp $ |
2 |
jmc |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "DIAG_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
CBOP |
7 |
|
|
C !ROUTINE: DIAGNOSTICS_FRACT_FILL |
8 |
|
|
C !INTERFACE: |
9 |
|
|
SUBROUTINE DIAGNOSTICS_FRACT_FILL( |
10 |
jmc |
1.2 |
I inpFld, fractFld, scaleFact, power, chardiag, |
11 |
jmc |
1.5 |
I kLev, nLevs, bibjFlg, biArg, bjArg, myThid ) |
12 |
jmc |
1.1 |
|
13 |
|
|
C !DESCRIPTION: |
14 |
|
|
C*********************************************************************** |
15 |
jmc |
1.6 |
C Wrapper routine to increment the diagnostics arrays with a RL field |
16 |
jmc |
1.2 |
C using a scaling factor & square option (power=2) |
17 |
jmc |
1.6 |
C and using a RL fraction-weight (assumed to be the |
18 |
|
|
C counter-mate of the current diagnostics) |
19 |
jmc |
1.1 |
C Note: 1) fraction-weight has to correspond to the diagnostics |
20 |
|
|
C counter-mate (filled independently with a call to |
21 |
|
|
C DIAGNOSTICS_FILL) |
22 |
|
|
C 2) assume for now that inpFld & fractFld are both _RL and |
23 |
|
|
C have the same horizontal shape (overlap,bi,bj ...) |
24 |
|
|
C*********************************************************************** |
25 |
|
|
C !USES: |
26 |
|
|
IMPLICIT NONE |
27 |
|
|
|
28 |
|
|
C == Global variables === |
29 |
|
|
#include "EEPARAMS.h" |
30 |
|
|
#include "SIZE.h" |
31 |
|
|
#include "DIAGNOSTICS_SIZE.h" |
32 |
|
|
#include "DIAGNOSTICS.h" |
33 |
|
|
|
34 |
|
|
C !INPUT PARAMETERS: |
35 |
|
|
C*********************************************************************** |
36 |
|
|
C Arguments Description |
37 |
|
|
C ---------------------- |
38 |
|
|
C inpFld :: Field to increment diagnostics array |
39 |
|
|
C fractFld :: fraction used for weighted average diagnostics |
40 |
|
|
C scaleFact :: scaling factor |
41 |
jmc |
1.2 |
C power :: option to fill-in with the field square (power=2) |
42 |
jmc |
1.1 |
C chardiag :: Character expression for diag to fill |
43 |
|
|
C kLev :: Integer flag for vertical levels: |
44 |
|
|
C > 0 (any integer): WHICH single level to increment in qdiag. |
45 |
|
|
C 0,-1 to increment "nLevs" levels in qdiag, |
46 |
|
|
C 0 : fill-in in the same order as the input array |
47 |
|
|
C -1: fill-in in reverse order. |
48 |
|
|
C nLevs :: indicates Number of levels of the input field array |
49 |
|
|
C (whether to fill-in all the levels (kLev<1) or just one (kLev>0)) |
50 |
|
|
C bibjFlg :: Integer flag to indicate instructions for bi bj loop |
51 |
|
|
C 0 indicates that the bi-bj loop must be done here |
52 |
|
|
C 1 indicates that the bi-bj loop is done OUTSIDE |
53 |
|
|
C 2 indicates that the bi-bj loop is done OUTSIDE |
54 |
|
|
C AND that we have been sent a local array (with overlap regions) |
55 |
|
|
C 3 indicates that the bi-bj loop is done OUTSIDE |
56 |
|
|
C AND that we have been sent a local array |
57 |
|
|
C AND that the array has no overlap region (interior only) |
58 |
|
|
C NOTE - bibjFlg can be NEGATIVE to indicate not to increment counter |
59 |
|
|
C biArg :: X-direction tile number - used for bibjFlg=1-3 |
60 |
|
|
C bjArg :: Y-direction tile number - used for bibjFlg=1-3 |
61 |
|
|
C myThid :: my thread Id number |
62 |
|
|
C*********************************************************************** |
63 |
|
|
C NOTE: User beware! If a local (1 tile only) array |
64 |
|
|
C is sent here, bibjFlg MUST NOT be set to 0 |
65 |
|
|
C or there will be out of bounds problems! |
66 |
|
|
C*********************************************************************** |
67 |
|
|
_RL inpFld(*) |
68 |
|
|
_RL fractFld(*) |
69 |
|
|
_RL scaleFact |
70 |
jmc |
1.2 |
INTEGER power |
71 |
jmc |
1.1 |
CHARACTER*8 chardiag |
72 |
|
|
INTEGER kLev, nLevs, bibjFlg, biArg, bjArg |
73 |
|
|
INTEGER myThid |
74 |
|
|
CEOP |
75 |
|
|
|
76 |
|
|
C !LOCAL VARIABLES: |
77 |
|
|
C ndId :: diagnostic Id number (in available diagnostics list) |
78 |
|
|
INTEGER m, n, j, k, l, bi, bj |
79 |
|
|
INTEGER ndId, ipt, iSp |
80 |
|
|
INTEGER region2fill(0:nRegions) |
81 |
|
|
INTEGER mate, nLevFract |
82 |
jmc |
1.5 |
CHARACTER*10 gcode |
83 |
jmc |
1.1 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
84 |
jmc |
1.6 |
INTEGER arrType |
85 |
|
|
_RS dummyRS(1) |
86 |
|
|
C =============== |
87 |
jmc |
1.1 |
|
88 |
jmc |
1.6 |
arrType = 0 |
89 |
jmc |
1.1 |
IF ( bibjFlg.EQ.0 ) THEN |
90 |
jmc |
1.4 |
bi = myBxLo(myThid) |
91 |
|
|
bj = myByLo(myThid) |
92 |
jmc |
1.1 |
ELSE |
93 |
|
|
bi = biArg |
94 |
|
|
bj = bjArg |
95 |
|
|
ENDIF |
96 |
|
|
C-- 2D/3D Diagnostics : |
97 |
|
|
C Run through list of active diagnostics to make sure |
98 |
|
|
C we are trying to fill a valid diagnostic |
99 |
|
|
DO n=1,nlists |
100 |
|
|
DO m=1,nActive(n) |
101 |
|
|
IF ( chardiag.EQ.flds(m,n) .AND. idiag(m,n).GT.0 ) THEN |
102 |
|
|
ipt = idiag(m,n) |
103 |
|
|
IF ( ndiag(ipt,bi,bj).GE.0 ) THEN |
104 |
|
|
ndId = jdiag(m,n) |
105 |
jmc |
1.3 |
ipt = ipt + pdiag(n,bi,bj)*kdiag(ndId) |
106 |
jmc |
1.1 |
C- check for a counter-mate: |
107 |
|
|
mate = 0 |
108 |
jmc |
1.5 |
gcode = gdiag(ndId)(1:10) |
109 |
|
|
IF ( gcode(5:5).EQ.'C' ) mate = hdiag(ndId) |
110 |
jmc |
1.1 |
IF ( mate.LE.0 ) THEN |
111 |
|
|
WRITE(msgBuf,'(2A)') 'DIAGNOSTICS_FRACT_FILL: ', |
112 |
|
|
& 'did not find a valid counter-mate' |
113 |
|
|
CALL PRINT_ERROR( msgBuf , myThid ) |
114 |
jmc |
1.5 |
WRITE(msgBuf,'(2A,I6,2A)') 'DIAGNOSTICS_FRACT_FILL: ', |
115 |
jmc |
1.1 |
& 'for diag(#',ndId,' ) :', chardiag |
116 |
|
|
CALL PRINT_ERROR( msgBuf , myThid ) |
117 |
|
|
STOP 'ABNORMAL END: S/R DIAGNOSTICS_FRACT_FILL' |
118 |
|
|
ENDIF |
119 |
|
|
C- set the nb of levels of fraction-weight field (not > kdiag(mate)) |
120 |
|
|
nLevFract = MIN(nLevs,kdiag(mate)) |
121 |
|
|
C- diagnostic is valid & active, has a counter-mate, do the filling: |
122 |
|
|
CALL DIAGNOSTICS_FILL_FIELD( |
123 |
jmc |
1.6 |
I inpFld, fractFld, dummyRS, dummyRS, |
124 |
|
|
I scaleFact, power, arrType, nLevFract, |
125 |
jmc |
1.2 |
I ndId, ipt, kLev, nLevs, |
126 |
|
|
I bibjFlg, biArg, bjArg, myThid ) |
127 |
jmc |
1.1 |
ENDIF |
128 |
|
|
ENDIF |
129 |
|
|
ENDDO |
130 |
|
|
ENDDO |
131 |
|
|
|
132 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
133 |
|
|
C-- Global/Regional Statistics : |
134 |
|
|
|
135 |
|
|
C Run through list of active statistics-diagnostics to make sure |
136 |
|
|
C we are trying to compute & fill a valid diagnostic |
137 |
|
|
|
138 |
|
|
DO n=1,diagSt_nbLists |
139 |
|
|
DO m=1,diagSt_nbActv(n) |
140 |
|
|
IF ( chardiag.EQ.diagSt_Flds(m,n) .AND. iSdiag(m,n).GT.0 ) THEN |
141 |
|
|
iSp = iSdiag(m,n) |
142 |
|
|
IF ( qSdiag(0,0,iSp,bi,bj).GE.0. ) THEN |
143 |
|
|
ndId = jSdiag(m,n) |
144 |
|
|
C- check for a counter-mate: |
145 |
|
|
mate = 0 |
146 |
jmc |
1.5 |
gcode = gdiag(ndId)(1:10) |
147 |
|
|
c IF ( gcode(5:5).EQ.'C' ) READ(gcode,'(5X,I3)') mate |
148 |
|
|
IF ( gcode(5:5).EQ.'C' ) mate = hdiag(ndId) |
149 |
jmc |
1.1 |
IF ( mate.LE.0 ) THEN |
150 |
|
|
WRITE(msgBuf,'(2A)') 'DIAGNOSTICS_FRACT_FILL: ', |
151 |
|
|
& 'did not find a valid counter-mate' |
152 |
|
|
CALL PRINT_ERROR( msgBuf , myThid ) |
153 |
jmc |
1.5 |
WRITE(msgBuf,'(2A,I6,2A)') 'DIAGNOSTICS_FRACT_FILL: ', |
154 |
jmc |
1.1 |
& 'for diag(#',ndId,' ) :', chardiag |
155 |
|
|
CALL PRINT_ERROR( msgBuf , myThid ) |
156 |
|
|
STOP 'ABNORMAL END: S/R DIAGNOSTICS_FRACT_FILL' |
157 |
|
|
ENDIF |
158 |
|
|
C- set the nb of levels of fraction-weight field (not > kdiag(mate)) |
159 |
|
|
nLevFract = MIN(nLevs,kdiag(mate)) |
160 |
|
|
C- Find list of regions to fill: |
161 |
|
|
DO j=0,nRegions |
162 |
|
|
region2fill(j) = diagSt_region(j,n) |
163 |
|
|
ENDDO |
164 |
|
|
C- if this diagnostics appears in several lists (with same freq) |
165 |
|
|
C then add regions from other lists |
166 |
|
|
DO l=1,diagSt_nbLists |
167 |
|
|
DO k=1,diagSt_nbActv(l) |
168 |
|
|
IF ( iSdiag(k,l).EQ.-iSp ) THEN |
169 |
|
|
DO j=0,nRegions |
170 |
|
|
region2fill(j) = MAX(region2fill(j),diagSt_region(j,l)) |
171 |
|
|
ENDDO |
172 |
|
|
ENDIF |
173 |
|
|
ENDDO |
174 |
|
|
ENDDO |
175 |
|
|
C- diagnostics is valid and Active, has a counter mate: Now do the filling |
176 |
|
|
CALL DIAGSTATS_FILL( |
177 |
jmc |
1.6 |
I inpFld, fractFld, |
178 |
|
|
#ifndef REAL4_IS_SLOW |
179 |
|
|
I dummyRS, dummyRS, |
180 |
|
|
#endif |
181 |
|
|
I scaleFact, power, arrType, nLevFract, |
182 |
jmc |
1.2 |
I ndId, iSp, region2fill, kLev, nLevs, |
183 |
|
|
I bibjFlg, biArg, bjArg, myThid ) |
184 |
jmc |
1.1 |
ENDIF |
185 |
|
|
ENDIF |
186 |
|
|
ENDDO |
187 |
|
|
ENDDO |
188 |
|
|
|
189 |
|
|
RETURN |
190 |
|
|
END |