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