1 |
C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagnostics_out.F,v 1.1 2004/12/13 21:43:54 jmc 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 |
c WRITE( diag_mnc_bn, '(A,A)' ) 'diag.', pref(1:ilen) |
87 |
WRITE( diag_mnc_bn, '(A)' ) pref(1:ilen) |
88 |
|
89 |
C Update the record dimension by writing the iteration number |
90 |
CALL MNC_CW_SET_UDIM(diag_mnc_bn, -1, myThid) |
91 |
CALL MNC_CW_I_W_S('I',diag_mnc_bn,0,0,'iter',myIter,myThid) |
92 |
CALL MNC_CW_SET_UDIM(diag_mnc_bn, 0, myThid) |
93 |
|
94 |
dn(1)(1:NLEN) = dn_blnk(1:NLEN) |
95 |
write(dn(1),'(a,i6.6)') 'Zd', nlevels(listnum) |
96 |
dim(1) = nlevels(listnum) |
97 |
ib(1) = 1 |
98 |
ie(1) = nlevels(listnum) |
99 |
|
100 |
CALL MNC_CW_ADD_GNAME('diag_levels', 1, |
101 |
& dim, dn, ib, ie, myThid) |
102 |
CALL MNC_CW_ADD_VNAME('level_indicies', 'diag_levels', |
103 |
& 0,0, myThid) |
104 |
CALL MNC_CW_ADD_VATTR_TEXT('level_indicies','description', |
105 |
& 'Idicies of vertical levels within the data source arrays', |
106 |
& myThid) |
107 |
|
108 |
CALL MNC_CW_RL_W('I',diag_mnc_bn,0,0, |
109 |
& 'level_indicies', levs(1,listnum), myThid) |
110 |
|
111 |
CALL MNC_CW_DEL_VNAME('level_indicies', myThid) |
112 |
CALL MNC_CW_DEL_GNAME('diag_levels', myThid) |
113 |
ENDIF |
114 |
#endif /* ALLOW_MNC */ |
115 |
|
116 |
do n = 1,nfields(listnum) |
117 |
do m = 1,ndiagt |
118 |
if( flds(n,listnum).eq.cdiag(m) .and. idiag(m).ne.0 ) then |
119 |
parms1 = gdiag(m) |
120 |
if (ndiag(m).ne.0.and.parse1(5).ne.'D') then |
121 |
if( myThid.eq.1 ) |
122 |
& write(6,2000) m,cdiag(m),ndiag(m),gdiag(m) |
123 |
if (parse1(5).ne.'C') then |
124 |
|
125 |
do k = 1,nlevels(listnum) |
126 |
call getdiag (levs(k,listnum),m,undef,qtmp1,myThid) |
127 |
enddo |
128 |
|
129 |
C Check for Mate of a Vector Diagnostic |
130 |
C ------------------------------------- |
131 |
if ( parse1(1).eq.'U' .or. parse1(1).eq.'V' ) then |
132 |
read (mate_index,100) mate |
133 |
if( idiag(mate).ne.0 ) then |
134 |
if( myThid.eq.1 ) |
135 |
& write(6,2001) cdiag(m),mate,cdiag(mate) |
136 |
else |
137 |
if( myThid.eq.1 ) |
138 |
& write(6,2002) cdiag(m),mate,cdiag(mate) |
139 |
endif |
140 |
endif |
141 |
|
142 |
else |
143 |
|
144 |
C Check for Mate of a Counter Diagnostic |
145 |
C -------------------------------------- |
146 |
read (mate_index,100) mate |
147 |
if( myThid.eq.1 ) |
148 |
& write(6,2003) cdiag(m),mate,cdiag(mate) |
149 |
do k = 1,nlevels(listnum) |
150 |
call getdiag2(levs(k,listnum),m,undef,qtmp1,myThid) |
151 |
call getdiag2(levs(k,listnum),mate,undef,qtmp2,myThid) |
152 |
do bj = myByLo(myThid), myByHi(myThid) |
153 |
do bi = myBxLo(myThid), myBxHi(myThid) |
154 |
do j = 1,sNy |
155 |
do i = 1,sNx |
156 |
if (qtmp2(i,j,k,bi,bj).ne.0.) then |
157 |
qtmp1(i,j,k,bi,bj) = |
158 |
& qtmp1(i,j,k,bi,bj) / qtmp2(i,j,k,bi,bj) |
159 |
else |
160 |
qtmp1(i,j,k,bi,bj) = undef |
161 |
endif |
162 |
enddo |
163 |
enddo |
164 |
enddo |
165 |
enddo |
166 |
enddo |
167 |
|
168 |
endif |
169 |
endif |
170 |
|
171 |
#ifdef ALLOW_MDSIO |
172 |
C Prepare for mdsio optionality |
173 |
IF (diag_mdsio) THEN |
174 |
call mdswritefield_new(fn,writeBinaryPrec,glf,'RL', |
175 |
& Nr+Nrphys,nlevels(listnum),qtmp1,n,myIter,myThid) |
176 |
ENDIF |
177 |
#endif /* ALLOW_MDSIO */ |
178 |
|
179 |
#ifdef ALLOW_MNC |
180 |
IF (useMNC .AND. diag_mnc) THEN |
181 |
|
182 |
_BEGIN_MASTER( myThid ) |
183 |
|
184 |
do ii = 1,CW_DIMS |
185 |
dn(ii)(1:NLEN) = dn_blnk(1:NLEN) |
186 |
enddo |
187 |
|
188 |
dn(1)(1:2) = 'Xd' |
189 |
dim(1) = sNx + 2*OLx |
190 |
ib(1) = OLx + 1 |
191 |
ie(1) = OLx + sNx |
192 |
dn(2)(1:2) = 'Yd' |
193 |
dim(2) = sNy + 2*OLy |
194 |
ib(2) = OLy + 1 |
195 |
ie(2) = OLy + sNy |
196 |
|
197 |
C Z is special since it varies |
198 |
write(dn(3),'(a,i6.6)') 'Zd', nlevels(listnum) |
199 |
dim(3) = Nr+Nrphys |
200 |
ib(3) = 1 |
201 |
ie(3) = nlevels(listnum) |
202 |
|
203 |
CALL MNC_CW_ADD_GNAME('diag_cw_temp', 3, |
204 |
& dim, dn, ib, ie, myThid) |
205 |
CALL MNC_CW_ADD_VNAME(cdiag(m), 'diag_cw_temp', |
206 |
& 4,5, myThid) |
207 |
CALL MNC_CW_ADD_VATTR_TEXT(cdiag(m),'description', |
208 |
& tdiag(m),myThid) |
209 |
CALL MNC_CW_ADD_VATTR_TEXT(cdiag(m),'units', |
210 |
& udiag(m),myThid) |
211 |
|
212 |
CALL MNC_CW_RL_W('D',diag_mnc_bn,0,0, |
213 |
& cdiag(m), qtmp1, myThid) |
214 |
|
215 |
CALL MNC_CW_DEL_VNAME(cdiag(m), myThid) |
216 |
CALL MNC_CW_DEL_GNAME('diag_cw_temp', myThid) |
217 |
|
218 |
_END_MASTER( myThid ) |
219 |
|
220 |
ENDIF |
221 |
#endif /* ALLOW_MNC */ |
222 |
|
223 |
endif |
224 |
enddo |
225 |
enddo |
226 |
|
227 |
100 format(i3) |
228 |
2000 format(1x,'Computing Diagnostic # ',i3,2x,a8,5x,'Counter: ', |
229 |
& i4,6x,'Parms: ',a16) |
230 |
2001 format(1x,' Vector Mate for ',a8,5x, |
231 |
& 'Diagnostic # ',i3,2x,a8,' exists ') |
232 |
2002 format(1x,' Vector Mate for ',a8,5x, |
233 |
& 'Diagnostic # ',i3,2x,a8,' not enabled') |
234 |
2003 format(1x,' use Counter Mate for ',a8,5x, |
235 |
& 'Diagnostic # ',i3,2x,a8) |
236 |
|
237 |
return |
238 |
end |
239 |
|
240 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |