8 |
C !ROUTINE: GETDIAG |
C !ROUTINE: GETDIAG |
9 |
|
|
10 |
C !INTERFACE: |
C !INTERFACE: |
11 |
SUBROUTINE GETDIAG (levreal,ipoint,undef,qtmp,myThid) |
SUBROUTINE GETDIAG( |
12 |
|
I levreal, undef, |
13 |
|
O qtmp, |
14 |
|
I ndId, mate, ip, im, bi, bj, myThid ) |
15 |
|
|
16 |
C !DESCRIPTION: |
C !DESCRIPTION: |
17 |
C Retrieve averaged model diagnostic |
C Retrieve averaged model diagnostic |
18 |
|
|
19 |
C !USES: |
C !USES: |
20 |
implicit none |
IMPLICIT NONE |
21 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
22 |
#include "SIZE.h" |
#include "SIZE.h" |
23 |
#include "DIAGNOSTICS_SIZE.h" |
#include "DIAGNOSTICS_SIZE.h" |
24 |
#include "DIAGNOSTICS.h" |
#include "DIAGNOSTICS.h" |
|
CEOP |
|
25 |
|
|
26 |
#ifdef ALLOW_FIZHI |
C !INPUT PARAMETERS: |
27 |
#include "fizhi_SIZE.h" |
C levreal :: Diagnostic LEVEL |
28 |
#else |
C undef :: UNDEFINED VALUE |
29 |
integer Nrphys |
C ndId :: DIAGNOSTIC NUMBER FROM MENU |
30 |
parameter (Nrphys=0) |
C mate :: counter DIAGNOSTIC NUMBER if any ; 0 otherwise |
31 |
#endif |
C ip :: pointer to storage array location for diag. |
32 |
|
C im :: pointer to storage array location for mate |
33 |
C INPUT: |
C bi :: X-direction tile number |
34 |
C levreal .... Diagnostic LEVEL |
C bj :: Y-direction tile number |
35 |
C ipoint ..... DIAGNOSTIC NUMBER FROM MENU |
C myThid :: my thread Id number |
|
C undef ..... UNDEFINED VALUE |
|
|
C bi ..... X-direction process(or) number |
|
|
C bj ..... Y-direction process(or) number |
|
36 |
_RL levreal |
_RL levreal |
|
integer myThid,ipoint |
|
37 |
_RL undef |
_RL undef |
38 |
|
INTEGER ndId, mate, ip, im |
39 |
|
INTEGER bi,bj, myThid |
40 |
|
|
41 |
C OUTPUT: |
C !OUTPUT PARAMETERS: |
42 |
C qtmp ..... AVERAGED DIAGNOSTIC QUANTITY |
C qtmp ..... AVERAGED DIAGNOSTIC QUANTITY |
43 |
_RL qtmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr+Nrphys,nSx,nSy) |
_RL qtmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
44 |
|
CEOP |
45 |
|
|
46 |
|
C !LOCAL VARIABLES: |
47 |
_RL factor |
_RL factor |
48 |
integer i,j,ipnt,klev |
INTEGER i, j, ipnt,ipCt |
49 |
integer bi,bj |
INTEGER lev, levCt, klev |
|
integer lev |
|
50 |
|
|
51 |
if (ipoint.ge.1) then |
IF (ndId.GE.1) THEN |
52 |
lev = NINT(levreal) |
lev = NINT(levreal) |
53 |
|
klev = kdiag(ndId) |
54 |
|
IF (lev.LE.klev) THEN |
55 |
|
|
56 |
klev = kdiag(ipoint) |
IF ( mate.EQ.0 ) THEN |
57 |
if (klev.ge.lev) then |
C- No counter diagnostics => average = Sum / ndiag : |
|
ipnt = idiag(ipoint) + lev - 1 |
|
|
factor = 1.0 |
|
|
if (ndiag(ipoint).ne.0) factor = 1.0/ndiag(ipoint) |
|
|
|
|
|
do bj=myByLo(myThid), myByHi(myThid) |
|
|
do bi=myBxLo(myThid), myBxHi(myThid) |
|
|
|
|
|
do j = 1,sNy |
|
|
do i = 1,sNx |
|
|
if ( qdiag(i,j,ipnt,bi,bj) .le. undef ) then |
|
|
qtmp(i,j,lev,bi,bj) = qdiag(i,j,ipnt,bi,bj)*factor |
|
|
else |
|
|
qtmp(i,j,lev,bi,bj) = undef |
|
|
endif |
|
|
enddo |
|
|
enddo |
|
58 |
|
|
59 |
enddo |
ipnt = ip + lev - 1 |
60 |
enddo |
factor = FLOAT(ndiag(ip,bi,bj)) |
61 |
|
IF (ndiag(ip,bi,bj).NE.0) factor = 1. _d 0 / factor |
62 |
|
|
63 |
|
DO j = 1,sNy+1 |
64 |
|
DO i = 1,sNx+1 |
65 |
|
IF ( qdiag(i,j,ipnt,bi,bj) .LE. undef ) THEN |
66 |
|
qtmp(i,j) = qdiag(i,j,ipnt,bi,bj)*factor |
67 |
|
ELSE |
68 |
|
qtmp(i,j) = undef |
69 |
|
ENDIF |
70 |
|
ENDDO |
71 |
|
ENDDO |
72 |
|
|
73 |
|
ELSE |
74 |
|
C- With counter diagnostics => average = Sum / counter: |
75 |
|
|
76 |
|
ipnt = ip + lev - 1 |
77 |
|
levCt= MIN(lev,kdiag(mate)) |
78 |
|
ipCt = im + levCt - 1 |
79 |
|
DO j = 1,sNy+1 |
80 |
|
DO i = 1,sNx+1 |
81 |
|
IF ( qdiag(i,j,ipCt,bi,bj) .NE. 0. ) THEN |
82 |
|
qtmp(i,j) = qdiag(i,j,ipnt,bi,bj) |
83 |
|
& / qdiag(i,j,ipCt,bi,bj) |
84 |
|
ELSE |
85 |
|
qtmp(i,j) = undef |
86 |
|
ENDIF |
87 |
|
ENDDO |
88 |
|
ENDDO |
89 |
|
|
90 |
endif |
ENDIF |
91 |
endif |
ENDIF |
92 |
|
ENDIF |
93 |
|
|
94 |
RETURN |
RETURN |
95 |
END |
END |
96 |
|
|
97 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
|
CBOP 0 |
|
|
C !ROUTINE: GETDIAG2 |
|
98 |
|
|
99 |
|
CBOP 0 |
100 |
|
C !ROUTINE: DIAGNOSTICS_COUNT |
101 |
C !INTERFACE: |
C !INTERFACE: |
102 |
SUBROUTINE GETDIAG2 (levreal,ipoint,undef,qtmp,myThid) |
SUBROUTINE DIAGNOSTICS_COUNT (chardiag, |
103 |
|
I biArg, bjArg, myThid) |
104 |
|
|
105 |
C !DESCRIPTION: |
C !DESCRIPTION: |
106 |
C*********************************************************************** |
C*********************************************************************** |
107 |
C PURPOSE |
C routine to increment the diagnostic counter only |
|
C Retrieve averaged model diagnostic |
|
|
C INPUT: |
|
|
C levreal .... Diagnostic LEVEL |
|
|
C ipoint ..... DIAGNOSTIC NUMBER FROM MENU |
|
|
C undef ..... UNDEFINED VALUE |
|
|
C |
|
|
C OUTPUT: |
|
|
C qtmp ..... AVERAGED DIAGNOSTIC QUANTITY |
|
|
C |
|
108 |
C*********************************************************************** |
C*********************************************************************** |
|
|
|
109 |
C !USES: |
C !USES: |
110 |
implicit none |
IMPLICIT NONE |
|
#include "EEPARAMS.h" |
|
|
#include "SIZE.h" |
|
|
#include "DIAGNOSTICS_SIZE.h" |
|
|
#include "DIAGNOSTICS.h" |
|
|
CEOP |
|
|
|
|
|
#ifdef ALLOW_FIZHI |
|
|
#include "fizhi_SIZE.h" |
|
|
#else |
|
|
integer Nrphys |
|
|
parameter (Nrphys=0) |
|
|
#endif |
|
|
|
|
|
_RL levreal |
|
|
integer myThid,ipoint |
|
|
_RL undef |
|
|
_RL qtmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr+Nrphys,nSx,nSy) |
|
|
|
|
|
integer i,j,ipnt,klev |
|
|
integer bi,bj |
|
|
integer lev |
|
|
|
|
|
if (ipoint.ge.1) then |
|
|
lev = NINT(levreal) |
|
|
|
|
|
klev = kdiag(ipoint) |
|
|
if (klev.ge.lev) then |
|
|
ipnt = idiag(ipoint) + lev - 1 |
|
|
|
|
|
do bj=myByLo(myThid), myByHi(myThid) |
|
|
do bi=myBxLo(myThid), myBxHi(myThid) |
|
|
|
|
|
do j = 1,sNy |
|
|
do i = 1,sNx |
|
|
if ( qdiag(i,j,ipnt,bi,bj) .le. undef ) then |
|
|
qtmp(i,j,lev,bi,bj) = qdiag(i,j,ipnt,bi,bj) |
|
|
else |
|
|
qtmp(i,j,lev,bi,bj) = undef |
|
|
endif |
|
|
enddo |
|
|
enddo |
|
|
|
|
|
enddo |
|
|
enddo |
|
|
|
|
|
endif |
|
|
endif |
|
|
|
|
|
RETURN |
|
|
END |
|
|
|
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
|
|
|
|
|
subroutine clrindx (listnum, myThid) |
|
|
C*********************************************************************** |
|
|
C |
|
|
C PURPOSE |
|
|
C DRIVER TO CLEAR DIAGNOSTICS SPECIFIED IN DIAGNOSTIC INDEX LIST |
|
|
C |
|
|
C ARGUMENT DESCRIPTION |
|
|
C listnum .... diagnostics list number |
|
|
C |
|
|
C*********************************************************************** |
|
111 |
|
|
112 |
implicit none |
C == Global variables === |
113 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
114 |
#include "SIZE.h" |
#include "SIZE.h" |
115 |
#include "DIAGNOSTICS_SIZE.h" |
#include "DIAGNOSTICS_SIZE.h" |
116 |
#include "DIAGNOSTICS.h" |
#include "DIAGNOSTICS.h" |
117 |
|
|
118 |
integer myThid, listnum |
C !INPUT PARAMETERS: |
|
|
|
|
integer m, n |
|
|
character*8 parms1 |
|
|
character*3 mate_index |
|
|
integer mate |
|
|
|
|
|
do n=1,nfields(listnum) |
|
|
do m=1,ndiagt |
|
|
if( flds(n,listnum).eq.cdiag(m) .and. idiag(m).ne.0 ) then |
|
|
call clrdiag (m, myThid) |
|
|
|
|
|
c Check for Counter Diagnostic |
|
|
c ---------------------------- |
|
|
parms1 = gdiag(m)(1:8) |
|
|
if ( parms1(5:5).eq.'C' ) then |
|
|
mate_index = parms1(6:8) |
|
|
read (mate_index,'(I3)') mate |
|
|
call clrdiag (mate, myThid) |
|
|
endif |
|
|
endif |
|
|
enddo |
|
|
enddo |
|
|
|
|
|
RETURN |
|
|
END |
|
|
|
|
|
|
|
|
subroutine clrdiag (index, myThid) |
|
|
C*********************************************************************** |
|
|
C PURPOSE |
|
|
C ZERO OUT MODEL DIAGNOSTIC ARRAY ELEMENTS |
|
119 |
C*********************************************************************** |
C*********************************************************************** |
120 |
|
C Arguments Description |
121 |
|
C ---------------------- |
122 |
|
C chardiag :: Character expression for diag to increment the counter |
123 |
|
C biArg :: X-direction tile number, or 0 if called outside bi,bj loops |
124 |
|
C bjArg :: Y-direction tile number, or 0 if called outside bi,bj loops |
125 |
|
C myThid :: my thread Id number |
126 |
|
C*********************************************************************** |
127 |
|
CHARACTER*8 chardiag |
128 |
|
INTEGER biArg, bjArg |
129 |
|
INTEGER myThid |
130 |
|
CEOP |
131 |
|
|
132 |
implicit none |
C !LOCAL VARIABLES: |
133 |
#include "EEPARAMS.h" |
C =============== |
134 |
#include "SIZE.h" |
INTEGER m, n |
135 |
#include "DIAGNOSTICS_SIZE.h" |
INTEGER bi, bj |
136 |
#include "DIAGNOSTICS.h" |
INTEGER ipt |
137 |
|
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
|
integer myThid, index |
|
|
|
|
|
integer bi,bj |
|
|
integer i,j,k |
|
|
|
|
|
C ********************************************************************** |
|
|
C **** SET DIAGNOSTIC AND COUNTER TO ZERO **** |
|
|
C ********************************************************************** |
|
|
|
|
|
do bj=myByLo(myThid), myByHi(myThid) |
|
|
do bi=myBxLo(myThid), myBxHi(myThid) |
|
|
do k = 1,kdiag(index) |
|
|
do j = 1-OLy,sNy+OLy |
|
|
do i = 1-OLx,sNx+OLx |
|
|
qdiag(i,j,idiag(index)+k-1,bi,bj) = 0.0 |
|
|
enddo |
|
|
enddo |
|
|
enddo |
|
|
enddo |
|
|
enddo |
|
138 |
|
|
139 |
ndiag(index) = 0 |
C-- Run through list of active diagnostics to find which counter |
140 |
|
C to increment (needs to be a valid & active diagnostic-counter) |
141 |
|
DO n=1,nlists |
142 |
|
DO m=1,nActive(n) |
143 |
|
IF ( chardiag.EQ.flds(m,n) .AND. idiag(m,n).GT.0 ) THEN |
144 |
|
ipt = idiag(m,n) |
145 |
|
IF (ndiag(ipt,1,1).GE.0) THEN |
146 |
|
C- Increment the counter for the diagnostic |
147 |
|
IF ( biArg.EQ.0 .AND. bjArg.EQ.0 ) THEN |
148 |
|
DO bj=myByLo(myThid), myByHi(myThid) |
149 |
|
DO bi=myBxLo(myThid), myBxHi(myThid) |
150 |
|
ndiag(ipt,bi,bj) = ndiag(ipt,bi,bj) + 1 |
151 |
|
ENDDO |
152 |
|
ENDDO |
153 |
|
ELSE |
154 |
|
bi = MIN(biArg,nSx) |
155 |
|
bj = MIN(bjArg,nSy) |
156 |
|
ndiag(ipt,bi,bj) = ndiag(ipt,bi,bj) + 1 |
157 |
|
ENDIF |
158 |
|
C- Increment is done |
159 |
|
ENDIF |
160 |
|
ENDIF |
161 |
|
ENDDO |
162 |
|
ENDDO |
163 |
|
|
164 |
RETURN |
RETURN |
165 |
END |
END |
167 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
168 |
|
|
169 |
CBOP 0 |
CBOP 0 |
170 |
C !ROUTINE: DIAGNOSTICS_IS_ON |
C !ROUTINE: DIAGS_MK_UNITS |
171 |
|
|
172 |
C !INTERFACE: |
C !INTERFACE: |
173 |
LOGICAL FUNCTION DIAGNOSTICS_IS_ON( diagName, myThid ) |
CHARACTER*16 FUNCTION DIAGS_MK_UNITS( |
174 |
|
I diagUnitsInPieces, myThid ) |
175 |
|
|
176 |
C !DESCRIPTION: |
C !DESCRIPTION: |
177 |
C *==========================================================* |
C *==========================================================* |
178 |
C | FUNCTION DIAGNOSTIC_IS_ON |
C | FUNCTION DIAGS_MK_UNITS |
179 |
C | o Return TRUE if diagnostics "diagName" is Active |
C | o Return the diagnostic units string (16c) removing |
180 |
|
C | blanks from the input string |
181 |
C *==========================================================* |
C *==========================================================* |
182 |
|
|
183 |
C !USES: |
C !USES: |
184 |
IMPLICIT NONE |
IMPLICIT NONE |
185 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
|
#include "SIZE.h" |
|
|
#include "DIAGNOSTICS_SIZE.h" |
|
|
#include "DIAGNOSTICS.h" |
|
186 |
|
|
187 |
C !INPUT PARAMETERS: |
C !INPUT PARAMETERS: |
188 |
C diagName :: diagnostic identificator name (8 characters long) |
C diagUnitsInPieces :: string for diagnostic units: in several |
189 |
C myThid :: my thread Id number |
C pieces, with blanks in between |
190 |
CHARACTER*8 diagName |
C myThid :: my thread Id number |
191 |
|
CHARACTER*(*) diagUnitsInPieces |
192 |
INTEGER myThid |
INTEGER myThid |
193 |
CEOP |
CEOP |
194 |
|
|
195 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
196 |
INTEGER j,n,m |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
197 |
|
INTEGER i,j,n |
198 |
|
|
199 |
DIAGNOSTICS_IS_ON = .FALSE. |
DIAGS_MK_UNITS = ' ' |
200 |
DO n=1,nlists |
n = LEN(diagUnitsInPieces) |
201 |
DO m=1,nActive(n) |
|
202 |
IF ( diagName.EQ.flds(m,n) ) THEN |
j = 0 |
203 |
j = jdiag(m,n) |
DO i=1,n |
204 |
IF ( idiag(j).NE.0 .AND. ndiag(j).GE.0 ) |
IF (diagUnitsInPieces(i:i) .NE. ' ' ) THEN |
205 |
& DIAGNOSTICS_IS_ON = .TRUE. |
j = j+1 |
206 |
ENDIF |
IF ( j.LE.16 ) DIAGS_MK_UNITS(j:j) = diagUnitsInPieces(i:i) |
207 |
ENDDO |
ENDIF |
208 |
ENDDO |
ENDDO |
209 |
|
|
210 |
|
IF ( j.GT.16 ) THEN |
211 |
|
WRITE(msgBuf,'(2A,I4,A)') '**WARNING** ', |
212 |
|
& 'DIAGS_MK_UNITS: too long (',j,' >16) input string' |
213 |
|
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
214 |
|
& SQUEEZE_RIGHT , myThid) |
215 |
|
WRITE(msgBuf,'(3A)') '**WARNING** ', |
216 |
|
& 'DIAGS_MK_UNITS: input=', diagUnitsInPieces |
217 |
|
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
218 |
|
& SQUEEZE_RIGHT , myThid) |
219 |
|
ENDIF |
220 |
|
|
221 |
RETURN |
RETURN |
222 |
END |
END |