1 |
C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagout.F,v 1.24 2004/10/26 00:58:06 molod Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "DIAG_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP 0 |
8 |
C !ROUTINE: DIAGNOSTICS_OUT |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE DIAGNOSTICS_OUT( |
12 |
I listnum, |
13 |
I myIter, |
14 |
I myThid ) |
15 |
|
16 |
C !DESCRIPTION: |
17 |
C Write output for diagnostics fields. |
18 |
|
19 |
C !USES: |
20 |
implicit none |
21 |
#include "SIZE.h" |
22 |
#include "EEPARAMS.h" |
23 |
#include "PARAMS.h" |
24 |
|
25 |
#ifdef ALLOW_FIZHI |
26 |
#include "fizhi_SIZE.h" |
27 |
#else |
28 |
integer Nrphys |
29 |
parameter (Nrphys=0) |
30 |
#endif |
31 |
|
32 |
#include "DIAGNOSTICS_SIZE.h" |
33 |
#include "DIAGNOSTICS.h" |
34 |
|
35 |
C !INPUT PARAMETERS: |
36 |
integer myThid, myIter, listnum |
37 |
CEOP |
38 |
|
39 |
integer i, j, k, m, n, bi, bj |
40 |
character*8 parms1 |
41 |
character*1 parse1(8) |
42 |
character*3 mate_index |
43 |
integer mate |
44 |
_RL qtmp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr+Nrphys,nSx,nSy) |
45 |
_RL qtmp2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr+Nrphys,nSx,nSy) |
46 |
_RL undef, getcon |
47 |
external getcon |
48 |
integer ilnblnk |
49 |
external ilnblnk |
50 |
integer ilen |
51 |
|
52 |
equivalence ( parms1 , parse1(1) ) |
53 |
equivalence ( mate_index , parse1(6) ) |
54 |
|
55 |
CHARACTER*(MAX_LEN_FNAM) pref |
56 |
CHARACTER*(MAX_LEN_MBUF) suff |
57 |
CHARACTER*(80) fn |
58 |
logical glf |
59 |
#ifdef ALLOW_MNC |
60 |
integer ii |
61 |
CHARACTER*(MAX_LEN_FNAM) diag_mnc_bn |
62 |
|
63 |
integer CW_DIMS, NLEN |
64 |
parameter ( CW_DIMS = 10 ) |
65 |
parameter ( NLEN = 80 ) |
66 |
integer dim(CW_DIMS), ib(CW_DIMS), ie(CW_DIMS) |
67 |
character*(NLEN) dn(CW_DIMS) |
68 |
character*(NLEN) dn_blnk |
69 |
#endif /* ALLOW_MNC */ |
70 |
|
71 |
undef = getcon('UNDEF') |
72 |
glf = globalFiles |
73 |
WRITE(suff,'(I10.10)') myIter |
74 |
pref = fnames(listnum) |
75 |
ilen=ilnblnk( pref ) |
76 |
WRITE( fn, '(A,A,A)' ) pref(1:ilen),'.',suff(1:10) |
77 |
|
78 |
#ifdef ALLOW_MNC |
79 |
IF (useMNC .AND. diag_mnc) THEN |
80 |
DO i = 1,MAX_LEN_FNAM |
81 |
diag_mnc_bn(i:i) = ' ' |
82 |
ENDDO |
83 |
DO i = 1,NLEN |
84 |
dn_blnk(i:i) = ' ' |
85 |
ENDDO |
86 |
WRITE( diag_mnc_bn, '(A,A)' ) 'diag.', pref(1:ilen) |
87 |
|
88 |
C Update the record dimension by writing the iteration number |
89 |
CALL MNC_CW_SET_UDIM(diag_mnc_bn, -1, myThid) |
90 |
CALL MNC_CW_I_W_S('I',diag_mnc_bn,0,0,'iter',myIter,myThid) |
91 |
CALL MNC_CW_SET_UDIM(diag_mnc_bn, 0, myThid) |
92 |
|
93 |
dn(1)(1:NLEN) = dn_blnk(1:NLEN) |
94 |
write(dn(1),'(a,i6.6)') 'Zd', nlevels(listnum) |
95 |
dim(1) = nlevels(listnum) |
96 |
ib(1) = 1 |
97 |
ie(1) = nlevels(listnum) |
98 |
|
99 |
CALL MNC_CW_ADD_GNAME('diag_levels', 1, |
100 |
& dim, dn, ib, ie, myThid) |
101 |
CALL MNC_CW_ADD_VNAME('level_indicies', 'diag_levels', |
102 |
& 0,0, myThid) |
103 |
CALL MNC_CW_ADD_VATTR_TEXT('level_indicies','description', |
104 |
& 'Idicies of vertical levels within the data source arrays', |
105 |
& myThid) |
106 |
|
107 |
CALL MNC_CW_RL_W('I',diag_mnc_bn,0,0, |
108 |
& 'level_indicies', levs(1,listnum), myThid) |
109 |
|
110 |
CALL MNC_CW_DEL_VNAME('level_indicies', myThid) |
111 |
CALL MNC_CW_DEL_GNAME('diag_levels', myThid) |
112 |
ENDIF |
113 |
#endif /* ALLOW_MNC */ |
114 |
|
115 |
do n = 1,nfields(listnum) |
116 |
do m = 1,ndiagt |
117 |
if( flds(n,listnum).eq.cdiag(m) .and. idiag(m).ne.0 ) then |
118 |
parms1 = gdiag(m) |
119 |
if (ndiag(m).ne.0.and.parse1(5).ne.'D') then |
120 |
if( myThid.eq.1 ) |
121 |
& write(6,2000) m,cdiag(m),ndiag(m),gdiag(m) |
122 |
if (parse1(5).ne.'C') then |
123 |
|
124 |
do k = 1,nlevels(listnum) |
125 |
call getdiag (levs(k,listnum),m,undef,qtmp1,myThid) |
126 |
enddo |
127 |
|
128 |
C Check for Mate of a Vector Diagnostic |
129 |
C ------------------------------------- |
130 |
if ( parse1(1).eq.'U' .or. parse1(1).eq.'V' ) then |
131 |
read (mate_index,100) mate |
132 |
if( idiag(mate).ne.0 ) then |
133 |
if( myThid.eq.1 ) |
134 |
& write(6,2001) cdiag(m),mate,cdiag(mate) |
135 |
else |
136 |
if( myThid.eq.1 ) |
137 |
& write(6,2002) cdiag(m),mate,cdiag(mate) |
138 |
endif |
139 |
endif |
140 |
|
141 |
else |
142 |
|
143 |
C Check for Mate of a Counter Diagnostic |
144 |
C -------------------------------------- |
145 |
read (mate_index,100) mate |
146 |
if( myThid.eq.1 ) |
147 |
& write(6,2003) cdiag(m),mate,cdiag(mate) |
148 |
do k = 1,nlevels(listnum) |
149 |
call getdiag2(levs(k,listnum),m,undef,qtmp1,myThid) |
150 |
call getdiag2(levs(k,listnum),mate,undef,qtmp2,myThid) |
151 |
do bj = myByLo(myThid), myByHi(myThid) |
152 |
do bi = myBxLo(myThid), myBxHi(myThid) |
153 |
do j = 1,sNy |
154 |
do i = 1,sNx |
155 |
if (qtmp2(i,j,k,bi,bj).ne.0.) then |
156 |
qtmp1(i,j,k,bi,bj) = |
157 |
& qtmp1(i,j,k,bi,bj) / qtmp2(i,j,k,bi,bj) |
158 |
else |
159 |
qtmp1(i,j,k,bi,bj) = undef |
160 |
endif |
161 |
enddo |
162 |
enddo |
163 |
enddo |
164 |
enddo |
165 |
enddo |
166 |
|
167 |
endif |
168 |
endif |
169 |
|
170 |
#ifdef ALLOW_MDSIO |
171 |
C Prepare for mdsio optionality |
172 |
IF (diag_mdsio) THEN |
173 |
call mdswritefield_new(fn,writeBinaryPrec,glf,'RL', |
174 |
& Nr+Nrphys,nlevels(listnum),qtmp1,n,myIter,myThid) |
175 |
ENDIF |
176 |
#endif /* ALLOW_MDSIO */ |
177 |
|
178 |
#ifdef ALLOW_MNC |
179 |
IF (useMNC .AND. diag_mnc) THEN |
180 |
|
181 |
_BEGIN_MASTER( myThid ) |
182 |
|
183 |
do ii = 1,CW_DIMS |
184 |
dn(ii)(1:NLEN) = dn_blnk(1:NLEN) |
185 |
enddo |
186 |
|
187 |
dn(1)(1:2) = 'Xd' |
188 |
dim(1) = sNx + 2*OLx |
189 |
ib(1) = OLx + 1 |
190 |
ie(1) = OLx + sNx |
191 |
dn(2)(1:2) = 'Yd' |
192 |
dim(2) = sNy + 2*OLy |
193 |
ib(2) = OLy + 1 |
194 |
ie(2) = OLy + sNy |
195 |
|
196 |
C Z is special since it varies |
197 |
write(dn(3),'(a,i6.6)') 'Zd', nlevels(listnum) |
198 |
dim(3) = Nr+Nrphys |
199 |
ib(3) = 1 |
200 |
ie(3) = nlevels(listnum) |
201 |
|
202 |
CALL MNC_CW_ADD_GNAME('diag_cw_temp', 3, |
203 |
& dim, dn, ib, ie, myThid) |
204 |
CALL MNC_CW_ADD_VNAME(cdiag(m), 'diag_cw_temp', |
205 |
& 4,5, myThid) |
206 |
CALL MNC_CW_ADD_VATTR_TEXT(cdiag(m),'description', |
207 |
& tdiag(m),myThid) |
208 |
CALL MNC_CW_ADD_VATTR_TEXT(cdiag(m),'units', |
209 |
& udiag(m),myThid) |
210 |
|
211 |
CALL MNC_CW_RL_W('D',diag_mnc_bn,0,0, |
212 |
& cdiag(m), qtmp1, myThid) |
213 |
|
214 |
CALL MNC_CW_DEL_VNAME(cdiag(m), myThid) |
215 |
CALL MNC_CW_DEL_GNAME('diag_cw_temp', myThid) |
216 |
|
217 |
_END_MASTER( myThid ) |
218 |
|
219 |
ENDIF |
220 |
#endif /* ALLOW_MNC */ |
221 |
|
222 |
endif |
223 |
enddo |
224 |
enddo |
225 |
|
226 |
100 format(i3) |
227 |
2000 format(1x,'Computing Diagnostic # ',i3,2x,a8,5x,'Counter: ', |
228 |
& i4,6x,'Parms: ',a16) |
229 |
2001 format(1x,' Vector Mate for ',a8,5x, |
230 |
& 'Diagnostic # ',i3,2x,a8,' exists ') |
231 |
2002 format(1x,' Vector Mate for ',a8,5x, |
232 |
& 'Diagnostic # ',i3,2x,a8,' not enabled') |
233 |
2003 format(1x,' use Counter Mate for ',a8,5x, |
234 |
& 'Diagnostic # ',i3,2x,a8) |
235 |
|
236 |
return |
237 |
end |
238 |
|
239 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |