1 |
C $Header: /u/gcmpack/MITgcm/pkg/ptracers/ptracers_monitor.F,v 1.14 2007/11/05 18:48:04 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PTRACERS_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: PTRACERS_MONITOR |
8 |
|
9 |
C !INTERFACE: ========================================================== |
10 |
SUBROUTINE PTRACERS_MONITOR( |
11 |
I myIter, myTime, myThid ) |
12 |
|
13 |
C !DESCRIPTION: |
14 |
C writes out ptracer statistics |
15 |
|
16 |
C !USES: =============================================================== |
17 |
IMPLICIT NONE |
18 |
#include "SIZE.h" |
19 |
#include "EEPARAMS.h" |
20 |
#include "PARAMS.h" |
21 |
#include "GRID.h" |
22 |
#include "PTRACERS_SIZE.h" |
23 |
#include "PTRACERS_PARAMS.h" |
24 |
#include "PTRACERS_FIELDS.h" |
25 |
#ifdef ALLOW_MONITOR |
26 |
#include "MONITOR.h" |
27 |
#endif |
28 |
|
29 |
C !INPUT PARAMETERS: =================================================== |
30 |
C myTime :: current time |
31 |
C myIter :: current timestep |
32 |
C myThid :: thread number |
33 |
_RL myTime |
34 |
INTEGER myIter |
35 |
INTEGER myThid |
36 |
|
37 |
C === Functions ==== |
38 |
LOGICAL DIFFERENT_MULTIPLE |
39 |
EXTERNAL DIFFERENT_MULTIPLE |
40 |
LOGICAL MASTER_CPU_IO |
41 |
EXTERNAL MASTER_CPU_IO |
42 |
|
43 |
#ifdef ALLOW_PTRACERS |
44 |
#ifdef ALLOW_MONITOR |
45 |
|
46 |
C !LOCAL VARIABLES: ==================================================== |
47 |
C i,j :: loop indices |
48 |
C ip :: ptracer number |
49 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
50 |
CHARACTER*(MAX_LEN_MBUF) suff |
51 |
INTEGER ip |
52 |
CEOP |
53 |
|
54 |
IF ( DIFFERENT_MULTIPLE( PTRACERS_monitorFreq,myTime,deltaTClock ) |
55 |
& ) THEN |
56 |
|
57 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
58 |
|
59 |
C-- Ptracers field monitor start |
60 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
61 |
C-- only the master thread is allowed to switch On/Off mon_write_stdout |
62 |
C & mon_write_mnc (since it's the only thread that uses those flags): |
63 |
|
64 |
IF (monitor_stdio) THEN |
65 |
mon_write_stdout = .TRUE. |
66 |
ELSE |
67 |
mon_write_stdout = .FALSE. |
68 |
ENDIF |
69 |
mon_write_mnc = .FALSE. |
70 |
#ifdef ALLOW_MNC |
71 |
IF (useMNC .AND. PTRACERS_monitor_mnc) THEN |
72 |
WRITE(mon_fname,'(A)') 'monitor_ptracer' |
73 |
CALL MNC_CW_APPEND_VNAME( |
74 |
& 'T', '-_-_--__-__t', 0,0, myThid) |
75 |
CALL MNC_CW_SET_UDIM(mon_fname, -1, myThid) |
76 |
CALL MNC_CW_I_W_S( |
77 |
& 'I',mon_fname,1,1,'T', myIter, myThid) |
78 |
CALL MNC_CW_SET_UDIM(mon_fname, 0, myThid) |
79 |
mon_write_mnc = .TRUE. |
80 |
ENDIF |
81 |
#endif /* ALLOW_MNC */ |
82 |
|
83 |
IF ( mon_write_stdout ) THEN |
84 |
WRITE(msgBuf,'(2A)') '// ==========================', |
85 |
& '=============================' |
86 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
87 |
WRITE(msgBuf,'(A)') |
88 |
& '// Begin MONITOR ptracer field statistics' |
89 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
90 |
WRITE(msgBuf,'(2A)') '// ==========================', |
91 |
& '=============================' |
92 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
93 |
ENDIF |
94 |
|
95 |
C-- endif master cpu io |
96 |
ENDIF |
97 |
|
98 |
C-- Ptracers field monitor : compute stats & write |
99 |
IF ( PTRACERS_monitorFreq .NE. monitorFreq |
100 |
& .OR. (useMNC.AND.PTRACERS_monitor_mnc) ) THEN |
101 |
C repeat printing of time to make grepping easier, default is not |
102 |
C to do this, because the default is to use the same monitorFreq |
103 |
C for ptracers as for the dynamics variables. |
104 |
CALL MON_SET_PREF('trctime',myThid) |
105 |
CALL MON_OUT_I( '_tsnumber', myIter,mon_string_none,myThid) |
106 |
CALL MON_OUT_RL('_secondsf', myTime,mon_string_none,myThid) |
107 |
ENDIF |
108 |
C Print the basic statistics of ptracer variables |
109 |
CALL MON_SET_PREF('trcstat_',myThid) |
110 |
DO ip = 1, PTRACERS_numInUse |
111 |
WRITE(suff,'(A7,A2)') 'ptracer',PTRACERS_ioLabel(ip) |
112 |
c WRITE(suff,'(A6,I4.4)') 'ptrac', ip |
113 |
CALL MON_PRINTSTATS_RL( |
114 |
& Nr, pTracer(1-Olx,1-Oly,1,1,1,ip), |
115 |
& suff, maskC,hFacC,rA ,drF,myThid) |
116 |
ENDDO |
117 |
|
118 |
C-- Ptracers field monitor finish |
119 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
120 |
C- only the master thread is allowed to switch On/Off mon_write_stdout |
121 |
C & mon_write_mnc (since it's the only thread that uses those flags): |
122 |
|
123 |
IF ( mon_write_stdout ) THEN |
124 |
WRITE(msgBuf,'(2A)') '// ==========================', |
125 |
& '=============================' |
126 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
127 |
WRITE(msgBuf,'(A)') |
128 |
& '// End MONITOR ptracers field statistics' |
129 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
130 |
WRITE(msgBuf,'(2A)') '// ==========================', |
131 |
& '=============================' |
132 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
133 |
ENDIF |
134 |
|
135 |
mon_write_stdout = .FALSE. |
136 |
mon_write_mnc = .FALSE. |
137 |
|
138 |
C- endif master cpu io |
139 |
ENDIF |
140 |
|
141 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
142 |
|
143 |
C--- endif different multiple |
144 |
ENDIF |
145 |
|
146 |
#endif /* ALLOW_MONITOR */ |
147 |
#endif /* ALLOW_PTRACERS */ |
148 |
|
149 |
RETURN |
150 |
END |