1 |
C $Header: /u/gcmpack/MITgcm/pkg/monitor/monitor_ad.F,v 1.4 2008/03/28 18:48:04 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MONITOR_OPTIONS.h" |
5 |
#include "PACKAGES_CONFIG.h" |
6 |
#include "AD_CONFIG.h" |
7 |
#include "CPP_OPTIONS.h" |
8 |
|
9 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
10 |
CBOP |
11 |
C !ROUTINE: MONITOR |
12 |
|
13 |
C !INTERFACE: |
14 |
SUBROUTINE ADMONITOR( |
15 |
I myTime, myIter, myThid ) |
16 |
|
17 |
C !DESCRIPTION: |
18 |
C Monitor key dynamical variables: calculate over the full domain |
19 |
C some simple statistics (e.g., min,max,average) and write them. |
20 |
|
21 |
C !USES: |
22 |
IMPLICIT NONE |
23 |
#include "SIZE.h" |
24 |
#include "EEPARAMS.h" |
25 |
#include "PARAMS.h" |
26 |
#include "GRID.h" |
27 |
#include "DYNVARS.h" |
28 |
#include "FFIELDS.h" |
29 |
#include "MONITOR.h" |
30 |
#ifdef ALLOW_MNC |
31 |
# include "MNC_PARAMS.h" |
32 |
#endif |
33 |
#ifdef ALLOW_AUTODIFF |
34 |
# ifdef ALLOW_AUTODIFF_MONITOR |
35 |
# include "adcommon.h" |
36 |
# endif |
37 |
#endif |
38 |
|
39 |
C !INPUT PARAMETERS: |
40 |
_RL myTime |
41 |
INTEGER myIter |
42 |
INTEGER myThid |
43 |
CEOP |
44 |
|
45 |
#if (defined (ALLOW_ADJOINT_RUN) || defined (ALLOW_ADMTLM)) |
46 |
#if (defined (ALLOW_AUTODIFF) && defined (ALLOW_AUTODIFF_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 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
56 |
_RL dT |
57 |
_RL statsTemp(6) |
58 |
c INTEGER time_as_int |
59 |
#ifdef ALLOW_MNC |
60 |
INTEGER i |
61 |
#endif |
62 |
|
63 |
IF ( DIFFERENT_MULTIPLE(adjmonitorFreq,myTime,deltaTClock) ) THEN |
64 |
|
65 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
66 |
C-- only the master thread is allowed to switch On/Off mon_write_stdout |
67 |
C & mon_write_mnc (since it's the only thread that uses those flags): |
68 |
|
69 |
IF (monitor_stdio) THEN |
70 |
mon_write_stdout = .TRUE. |
71 |
ELSE |
72 |
mon_write_stdout = .FALSE. |
73 |
ENDIF |
74 |
mon_write_mnc = .FALSE. |
75 |
#ifdef ALLOW_MNC |
76 |
IF (useMNC .AND. monitor_mnc) THEN |
77 |
DO i = 1,MAX_LEN_MBUF |
78 |
mon_fname(i:i) = ' ' |
79 |
ENDDO |
80 |
mon_fname(1:7) = 'admonitor' |
81 |
CALL MNC_CW_APPEND_VNAME( |
82 |
& 'T', '-_-_--__-__t', 0,0, myThid) |
83 |
CALL MNC_CW_SET_UDIM(mon_fname, -1, myThid) |
84 |
CALL MNC_CW_RL_W_S( |
85 |
& 'D',mon_fname,1,1,'T', myTime, myThid) |
86 |
CALL MNC_CW_SET_UDIM(mon_fname, 0, myThid) |
87 |
mon_write_mnc = .TRUE. |
88 |
ENDIF |
89 |
#endif /* ALLOW_MNC */ |
90 |
|
91 |
C Dynamics field monitor start |
92 |
IF ( mon_write_stdout ) THEN |
93 |
WRITE(msgBuf,'(2A)') '// ==========================', |
94 |
& '=============================' |
95 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
96 |
WRITE(msgBuf,'(A)') |
97 |
& '// Begin MONITOR dynamic field statistics' |
98 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
99 |
WRITE(msgBuf,'(2A)') '// ==========================', |
100 |
& '=============================' |
101 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
102 |
ENDIF |
103 |
|
104 |
C-- endif master cpu io |
105 |
ENDIF |
106 |
|
107 |
C Print the time to make grepping the stdout easier |
108 |
CALL MON_SET_PREF('ad_time',myThid) |
109 |
CALL MON_OUT_I( '_tsnumber', myIter,mon_string_none,myThid) |
110 |
CALL MON_OUT_RL('_secondsf', myTime,mon_string_none,myThid) |
111 |
C - cause floating point error on some platform (cf Martin Losch) |
112 |
C time_as_int = NINT( myTime ) |
113 |
C CALL MON_OUT_I( '_secondsi', time_as_int,mon_string_none,myThid) |
114 |
|
115 |
C Print the basic statistics of model state variables |
116 |
CALL MON_SET_PREF('ad_dynstat',myThid) |
117 |
CALL MON_PRINTSTATS_RL(1,adEtaN,'_adeta', |
118 |
& maskH,maskH,rA ,drF,myThid) |
119 |
CALL MON_PRINTSTATS_RL(Nr,aduVel,'_aduvel', |
120 |
& maskW,hFacW,rAw,drF,myThid) |
121 |
CALL MON_PRINTSTATS_RL(Nr,advVel,'_advvel', |
122 |
& maskS,hFacS,rAs,drF,myThid) |
123 |
CALL MON_PRINTSTATS_RL(Nr,adwVel,'_adwvel', |
124 |
& maskC,maskC,rA ,drC,myThid) |
125 |
CALL MON_WRITESTATS_RL(Nr,adtheta,'_adtheta', |
126 |
& maskC,hFacC,rA ,drF, |
127 |
& statsTemp, myThid) |
128 |
CALL MON_PRINTSTATS_RL(Nr,adsalt,'_adsalt', |
129 |
& maskC,hFacC,rA ,drF,myThid) |
130 |
CALL MON_PRINTSTATS_RL(1,adtheta(1-olx,1-oly,1,1,1),'_adsst', |
131 |
& maskC,hFacC,rA ,drF,myThid) |
132 |
CALL MON_PRINTSTATS_RL(1,adsalt(1-olx,1-oly,1,1,1),'_adsss', |
133 |
& maskC,hFacC,rA ,drF,myThid) |
134 |
|
135 |
C Print the basic statistics of external forcing |
136 |
CALL MON_SET_PREF('ad_extforcing',myThid) |
137 |
CALL MON_PRINTSTATS_RL(1,adQnet,'_adqnet', |
138 |
& maskH,maskH,rA ,drF,myThid) |
139 |
#ifdef SHORTWAVE_HEATING |
140 |
CALL MON_PRINTSTATS_RL(1,adQsw,'_adqsw', |
141 |
& maskH,maskH,rA ,drF,myThid) |
142 |
#endif |
143 |
CALL MON_PRINTSTATS_RL(1,adEmPmR,'_adempmr', |
144 |
& maskH,maskH,rA ,drF,myThid) |
145 |
CALL MON_PRINTSTATS_RL(1,adfu,'_adfu', |
146 |
& maskW,hFacW,rAw,drF,myThid) |
147 |
CALL MON_PRINTSTATS_RL(1,adfv,'_adfv', |
148 |
& maskS,hFacS,rAs,drF,myThid) |
149 |
|
150 |
C Print the numerical stablility parameters for current state |
151 |
CALL MON_SET_PREF('ad_advcfl',myThid) |
152 |
dT=MAX(dTtracerLev(1),deltaTmom) |
153 |
CALL MON_ADVCFL('_aduvel',aduVel,recip_dxc,dT,myThid) |
154 |
CALL MON_ADVCFL('_advvel',advVel,recip_dyc,dT,myThid) |
155 |
CALL MON_ADVCFLW('_adwvel',adwVel,recip_drc,dT,myThid) |
156 |
CALL MON_ADVCFLW2('_adW_hf',adwVel,recip_hFacC, |
157 |
& recip_drC,dT,myThid) |
158 |
|
159 |
C Dynamics field monitor finish |
160 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
161 |
C-- only the master thread is allowed to switch On/Off mon_write_stdout |
162 |
C & mon_write_mnc (since it's the only thread that uses those flags): |
163 |
|
164 |
IF ( mon_write_stdout ) THEN |
165 |
WRITE(msgBuf,'(2A)') '// ==========================', |
166 |
& '=============================' |
167 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
168 |
WRITE(msgBuf,'(A)') |
169 |
& '// End MONITOR dynamic field statistics' |
170 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
171 |
WRITE(msgBuf,'(2A)') '// ==========================', |
172 |
& '=============================' |
173 |
CALL PRINT_MESSAGE( msgBuf, mon_ioUnit, SQUEEZE_RIGHT , 1) |
174 |
ENDIF |
175 |
|
176 |
mon_write_stdout = .FALSE. |
177 |
mon_write_mnc = .FALSE. |
178 |
|
179 |
C-- endif master cpu io |
180 |
ENDIF |
181 |
|
182 |
C endif different multiple |
183 |
ENDIF |
184 |
|
185 |
#endif /* ALLOW_AUTODIFF_MONITOR */ |
186 |
#endif /* ALLOW_ADJOINT_RUN */ |
187 |
|
188 |
RETURN |
189 |
END |