1 |
C $Header: /u/gcmpack/MITgcm/pkg/obcs/obcs_monitor.F,v 1.4 2011/05/24 14:31:14 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "OBCS_OPTIONS.h" |
5 |
|
6 |
C-- File obcs_monitor.F : write statistics of dynamical fields at OB section |
7 |
C-- Contents |
8 |
C-- o OBCS_MONITOR |
9 |
C-- o OBCS_MON_WRITESTATS |
10 |
|
11 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
12 |
CBOP |
13 |
C !ROUTINE: OBCS_MONITOR |
14 |
|
15 |
C !INTERFACE: |
16 |
SUBROUTINE OBCS_MONITOR( myTime, myIter, myThid ) |
17 |
|
18 |
C !DESCRIPTION: |
19 |
C *==========================================================* |
20 |
C | SUBROUTINE OBCS_MONITOR |
21 |
C | o Write out OB statistics |
22 |
C *==========================================================* |
23 |
|
24 |
C !USES: |
25 |
IMPLICIT NONE |
26 |
|
27 |
C === Global variables === |
28 |
#include "SIZE.h" |
29 |
#include "EEPARAMS.h" |
30 |
#include "PARAMS.h" |
31 |
#include "GRID.h" |
32 |
#include "DYNVARS.h" |
33 |
#include "OBCS_PARAMS.h" |
34 |
#include "OBCS_GRID.h" |
35 |
#ifdef ALLOW_MONITOR |
36 |
#include "MONITOR.h" |
37 |
#endif |
38 |
|
39 |
C !INPUT/OUTPUT PARAMETERS: |
40 |
_RL myTime |
41 |
INTEGER myIter |
42 |
INTEGER myThid |
43 |
CEOP |
44 |
|
45 |
#ifdef ALLOW_OBCS |
46 |
#ifdef ALLOW_MONITOR |
47 |
|
48 |
C !FUNCTIONS: |
49 |
LOGICAL DIFFERENT_MULTIPLE |
50 |
EXTERNAL DIFFERENT_MULTIPLE |
51 |
LOGICAL MASTER_CPU_IO |
52 |
EXTERNAL MASTER_CPU_IO |
53 |
|
54 |
C !LOCAL VARIABLES: |
55 |
C msgBuf :: Informational/error message buffer |
56 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
57 |
_RL fldStats(0:4,4) |
58 |
|
59 |
IF ( DIFFERENT_MULTIPLE( OBCS_monitorFreq,myTime,deltaTClock ) |
60 |
& ) THEN |
61 |
|
62 |
#ifdef ALLOW_DEBUG |
63 |
IF (debugMode) CALL DEBUG_ENTER('OBCS_MONITOR',myThid) |
64 |
#endif |
65 |
|
66 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
67 |
|
68 |
C-- OBCS monitor start |
69 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
70 |
C-- only the master thread is allowed to switch On/Off mon_write_stdout |
71 |
C & mon_write_mnc (since it is the only thread that uses those flags): |
72 |
|
73 |
c IF (monitor_stdio) THEN |
74 |
mon_write_stdout = .TRUE. |
75 |
c ELSE |
76 |
c mon_write_stdout = .FALSE. |
77 |
c ENDIF |
78 |
mon_write_mnc = .FALSE. |
79 |
|
80 |
IF ( mon_write_stdout ) THEN |
81 |
WRITE(msgBuf,'(2A)') '// ==========================', |
82 |
& '=============================' |
83 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
84 |
WRITE(msgBuf,'(A)') |
85 |
& '// Begin OBCS MONITOR field statistics' |
86 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
87 |
WRITE(msgBuf,'(2A)') '// ==========================', |
88 |
& '=============================' |
89 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
90 |
ENDIF |
91 |
|
92 |
C-- endif master cpu io |
93 |
ENDIF |
94 |
|
95 |
IF ( OBCS_monitorFreq .NE. monitorFreq |
96 |
& .OR. .NOT.monitor_stdio ) THEN |
97 |
CALL MON_SET_PREF('obc_time_',myThid) |
98 |
CALL MON_OUT_I( 'tsnumber', myIter,mon_string_none,myThid) |
99 |
CALL MON_OUT_RL('secondsf', myTime,mon_string_none,myThid) |
100 |
ENDIF |
101 |
|
102 |
CALL MON_SET_PREF('obc_',myThid) |
103 |
|
104 |
C-- Calculate and print Flow field Stats: |
105 |
IF ( OBCS_monSelect.GE.0 ) THEN |
106 |
|
107 |
CALL OBCS_MON_STATS_EW_RL( |
108 |
I tileHasOBE, tileHasOBW, |
109 |
I OB_Ie, OB_Iw, OB_indexNone, |
110 |
I Nr, Nr, 1, uVel, hFacW, dyG, drF, maskInC, |
111 |
O fldStats(0,1), |
112 |
I myThid ) |
113 |
CALL OBCS_MON_STATS_NS_RL( |
114 |
I tileHasOBN, tileHasOBS, |
115 |
I OB_Jn, OB_Js, OB_indexNone, |
116 |
I Nr, Nr, 2, vVel, hFacS, dxG, drF, maskInC, |
117 |
O fldStats(0,3), |
118 |
I myThid ) |
119 |
|
120 |
CALL OBCS_MON_WRITESTATS( |
121 |
I fldStats, 'Vel', |
122 |
I 3, myIter, myThid ) |
123 |
|
124 |
ENDIF |
125 |
|
126 |
C-- Calculate and print Temp. field Stats: |
127 |
IF ( OBCS_monSelect.GE.1 ) THEN |
128 |
|
129 |
CALL OBCS_MON_STATS_EW_RL( |
130 |
I tileHasOBE, tileHasOBW, |
131 |
I OB_Ie, OB_Iw, OB_indexNone, |
132 |
I Nr, Nr, 0, theta, hFacW, dyG, drF, maskInC, |
133 |
O fldStats(0,1), |
134 |
I myThid ) |
135 |
CALL OBCS_MON_STATS_NS_RL( |
136 |
I tileHasOBN, tileHasOBS, |
137 |
I OB_Jn, OB_Js, OB_indexNone, |
138 |
I Nr, Nr, 0, theta, hFacS, dxG, drF, maskInC, |
139 |
O fldStats(0,3), |
140 |
I myThid ) |
141 |
|
142 |
CALL OBCS_MON_WRITESTATS( |
143 |
I fldStats, 'theta', |
144 |
I 0, myIter, myThid ) |
145 |
|
146 |
ENDIF |
147 |
|
148 |
C-- Calculate and print Salt field Stats: |
149 |
IF ( OBCS_monSelect.GE.2 ) THEN |
150 |
|
151 |
CALL OBCS_MON_STATS_EW_RL( |
152 |
I tileHasOBE, tileHasOBW, |
153 |
I OB_Ie, OB_Iw, OB_indexNone, |
154 |
I Nr, Nr, 0, salt, hFacW, dyG, drF, maskInC, |
155 |
O fldStats(0,1), |
156 |
I myThid ) |
157 |
CALL OBCS_MON_STATS_NS_RL( |
158 |
I tileHasOBN, tileHasOBS, |
159 |
I OB_Jn, OB_Js, OB_indexNone, |
160 |
I Nr, Nr, 0, salt, hFacS, dxG, drF, maskInC, |
161 |
O fldStats(0,3), |
162 |
I myThid ) |
163 |
|
164 |
CALL OBCS_MON_WRITESTATS( |
165 |
I fldStats, 'salt', |
166 |
I 0, myIter, myThid ) |
167 |
|
168 |
ENDIF |
169 |
|
170 |
C-- OBCS monitor finish |
171 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
172 |
C-- only the master thread is allowed to switch On/Off mon_write_stdout |
173 |
C & mon_write_mnc (since it is the only thread that uses those flags): |
174 |
|
175 |
IF ( mon_write_stdout ) THEN |
176 |
WRITE(msgBuf,'(2A)') '// ==========================', |
177 |
& '=============================' |
178 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
179 |
WRITE(msgBuf,'(A)') |
180 |
& '// End OBCS MONITOR field statistics' |
181 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
182 |
WRITE(msgBuf,'(2A)') '// ==========================', |
183 |
& '=============================' |
184 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
185 |
ENDIF |
186 |
|
187 |
mon_write_stdout = .FALSE. |
188 |
mon_write_mnc = .FALSE. |
189 |
|
190 |
C-- endif master cpu io |
191 |
ENDIF |
192 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
193 |
|
194 |
#ifdef ALLOW_DEBUG |
195 |
IF (debugMode) CALL DEBUG_LEAVE('OBCS_MONITOR',myThid) |
196 |
#endif |
197 |
|
198 |
C endif different multiple |
199 |
ENDIF |
200 |
|
201 |
#endif /* ALLOW_MONITOR */ |
202 |
#endif /* ALLOW_OBCS */ |
203 |
|
204 |
RETURN |
205 |
END |
206 |
|
207 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
208 |
CBOP |
209 |
C !ROUTINE: OBCS_MON_WRITESTATS |
210 |
|
211 |
C !INTERFACE: |
212 |
SUBROUTINE OBCS_MON_WRITESTATS( |
213 |
I arrStats, arrName, |
214 |
I prtSelect, myIter, myThid ) |
215 |
|
216 |
C !DESCRIPTION: |
217 |
C *==========================================================* |
218 |
C | SUBROUTINE OBCS_MON_WRITESTATS |
219 |
C | o Write out OB statistics |
220 |
C *==========================================================* |
221 |
|
222 |
C !USES: |
223 |
IMPLICIT NONE |
224 |
|
225 |
C === Global variables === |
226 |
#include "SIZE.h" |
227 |
#include "EEPARAMS.h" |
228 |
#include "PARAMS.h" |
229 |
#ifdef ALLOW_MONITOR |
230 |
#include "MONITOR.h" |
231 |
#endif |
232 |
|
233 |
C !INPUT/OUTPUT PARAMETERS: |
234 |
_RL arrStats(0:4,4) |
235 |
CHARACTER*(*) arrName |
236 |
INTEGER prtSelect |
237 |
INTEGER myIter |
238 |
INTEGER myThid |
239 |
CEOP |
240 |
|
241 |
#ifdef ALLOW_OBCS |
242 |
#ifdef ALLOW_MONITOR |
243 |
|
244 |
C !LOCAL VARIABLES: |
245 |
C msgBuf :: Informational/error message buffer |
246 |
INTEGER j |
247 |
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
248 |
CHARACTER*(12) fldName |
249 |
_RL theMin, theMax, theMean, theSD |
250 |
|
251 |
j = 1 |
252 |
fldName = 'E_'//arrName |
253 |
IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'E_u'//arrName |
254 |
IF ( arrStats(0,j).GT.0. _d 0 ) THEN |
255 |
theMean= arrStats(1,j)/arrStats(0,j) |
256 |
theSD = arrStats(2,j)/arrStats(0,j) |
257 |
theSD = theSD - theMean*theMean |
258 |
IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD) |
259 |
theMin = arrStats(3,j) |
260 |
theMax = arrStats(4,j) |
261 |
CALL MON_OUT_RL( fldName, theMax, mon_foot_max, myThid ) |
262 |
CALL MON_OUT_RL( fldName, theMin, mon_foot_min, myThid ) |
263 |
CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid ) |
264 |
CALL MON_OUT_RL( fldName, theSD, mon_foot_sd, myThid ) |
265 |
IF ( prtSelect.GE.2 ) |
266 |
& CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int', myThid ) |
267 |
ENDIF |
268 |
|
269 |
j = 2 |
270 |
fldName = 'W_'//arrName |
271 |
IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'W_u'//arrName |
272 |
IF ( arrStats(0,j).GT.0. _d 0 ) THEN |
273 |
theMean= arrStats(1,j)/arrStats(0,j) |
274 |
theSD = arrStats(2,j)/arrStats(0,j) |
275 |
theSD = theSD - theMean*theMean |
276 |
IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD) |
277 |
theMin = arrStats(3,j) |
278 |
theMax = arrStats(4,j) |
279 |
CALL MON_OUT_RL( fldName, theMax, mon_foot_max, myThid ) |
280 |
CALL MON_OUT_RL( fldName, theMin, mon_foot_min, myThid ) |
281 |
CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid ) |
282 |
CALL MON_OUT_RL( fldName, theSD, mon_foot_sd, myThid ) |
283 |
IF ( prtSelect.GE.2 ) |
284 |
& CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int', myThid ) |
285 |
ENDIF |
286 |
|
287 |
j = 3 |
288 |
fldName = 'N_'//arrName |
289 |
IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'N_v'//arrName |
290 |
IF ( arrStats(0,j).GT.0. _d 0 ) THEN |
291 |
theMean= arrStats(1,j)/arrStats(0,j) |
292 |
theSD = arrStats(2,j)/arrStats(0,j) |
293 |
theSD = theSD - theMean*theMean |
294 |
IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD) |
295 |
theMin = arrStats(3,j) |
296 |
theMax = arrStats(4,j) |
297 |
CALL MON_OUT_RL( fldName, theMax, mon_foot_max, myThid ) |
298 |
CALL MON_OUT_RL( fldName, theMin, mon_foot_min, myThid ) |
299 |
CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid ) |
300 |
CALL MON_OUT_RL( fldName, theSD, mon_foot_sd, myThid ) |
301 |
IF ( prtSelect.GE.2 ) |
302 |
& CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int', myThid ) |
303 |
ENDIF |
304 |
|
305 |
j = 4 |
306 |
fldName = 'S_'//arrName |
307 |
IF ( MOD(prtSelect,2).EQ.1 ) fldName = 'S_v'//arrName |
308 |
IF ( arrStats(0,j).GT.0. _d 0 ) THEN |
309 |
theMean= arrStats(1,j)/arrStats(0,j) |
310 |
theSD = arrStats(2,j)/arrStats(0,j) |
311 |
theSD = theSD - theMean*theMean |
312 |
IF ( theSD.GT.0. _d 0 ) theSD = SQRT(theSD) |
313 |
theMin = arrStats(3,j) |
314 |
theMax = arrStats(4,j) |
315 |
CALL MON_OUT_RL( fldName, theMax, mon_foot_max, myThid ) |
316 |
CALL MON_OUT_RL( fldName, theMin, mon_foot_min, myThid ) |
317 |
CALL MON_OUT_RL( fldName, theMean, mon_foot_mean, myThid ) |
318 |
CALL MON_OUT_RL( fldName, theSD, mon_foot_sd, myThid ) |
319 |
IF ( prtSelect.GE.2 ) |
320 |
& CALL MON_OUT_RL( fldName, arrStats(1,j), '_Int', myThid ) |
321 |
ENDIF |
322 |
|
323 |
#endif /* ALLOW_MONITOR */ |
324 |
#endif /* ALLOW_OBCS */ |
325 |
|
326 |
RETURN |
327 |
END |