1 |
C $Header: /u/gcmpack/MITgcm/pkg/opps/opps_do_diags.F,v 1.2 2005/04/06 18:44:50 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "OPPS_OPTIONS.h" |
5 |
|
6 |
#undef MULTIPLE_RECORD_OPPS_STATE_FILES |
7 |
CBOP |
8 |
C !ROUTINE: OPPS_DO_DIAGS |
9 |
C !INTERFACE: |
10 |
SUBROUTINE OPPS_DO_DIAGS( myCurrentTime, myIter, myThid ) |
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE OPPS_DO_DIAGS |
14 |
C | o Do OPPS diagnostic output. |
15 |
C *========================================================== |
16 |
C | The following CPP flag (MULTIPLE_RECORD_OPPS_STATE_FILES) is |
17 |
C | #define/#undefed here since it is specific to this routine |
18 |
C | and very user-preference specific. |
19 |
C | |
20 |
C | If #undefed (default) the state files are written as in all versions |
21 |
C | prior to checkpoint32, where a file is created per variable, per time |
22 |
C | and per tile. This *has* to be the default because most users use this |
23 |
C | mode and all utilities and scripts (diagnostic) assume this form. |
24 |
C | It is also robust, as explained below. |
25 |
C | |
26 |
C | If #defined, subsequent snap-shots are written as records in the |
27 |
C | same file (no iteration number in filenames). |
28 |
C | Advantages: - fewer files |
29 |
C | - for small problems, is easy to copy the output around |
30 |
C | Disadvantages: |
31 |
C | - breaks a lot of diagnostic scripts |
32 |
C | - for large or long problems this creates huge files |
33 |
C | - is an unexpected, unsolicited change in behaviour which came |
34 |
C | as a surprise (in c32) and inconvenience to several users |
35 |
C | - can not accomodate changing the frequency of output |
36 |
C | after a pickup (this is trivial in previous method |
37 |
C | but needs new code and parameters in this new method) |
38 |
C *==========================================================* |
39 |
C \ev |
40 |
|
41 |
C !USES: |
42 |
IMPLICIT NONE |
43 |
C === Global variables === |
44 |
#include "SIZE.h" |
45 |
#include "EEPARAMS.h" |
46 |
#include "PARAMS.h" |
47 |
#include "OPPS.h" |
48 |
#include "OPPS_DIAGS.h" |
49 |
|
50 |
C !INPUT/OUTPUT PARAMETERS: |
51 |
C == Routine arguments == |
52 |
C myCurrentTime - Current time of simulation ( s ) |
53 |
C myIter - Iteration number |
54 |
C myThid - Number of this instance of INI_FORCING |
55 |
_RL myCurrentTime |
56 |
INTEGER myIter |
57 |
INTEGER myThid |
58 |
|
59 |
#ifdef ALLOW_OPPS |
60 |
|
61 |
C !LOCAL VARIABLES: |
62 |
C == Local variables == |
63 |
CHARACTER*(MAX_LEN_MBUF) suff |
64 |
LOGICAL DIFFERENT_MULTIPLE |
65 |
EXTERNAL DIFFERENT_MULTIPLE |
66 |
INTEGER bi, bj, K |
67 |
_RL DDTT |
68 |
CEOP |
69 |
|
70 |
CMLC---------------------------------------------------------------- |
71 |
CMLC Dump snapshot of OPPS variables. |
72 |
CMLC---------------------------------------------------------------- |
73 |
CML |
74 |
CML IF ( |
75 |
CML & DIFFERENT_MULTIPLE(OPPSdumpFreq, |
76 |
CML & myCurrentTime,deltaTClock) |
77 |
CML & ) THEN |
78 |
CML |
79 |
CML if (OPPSwriteState) then |
80 |
CML#ifdef MULTIPLE_RECORD_OPPS_STATE_FILES |
81 |
CMLC Write each snap-shot as a new record in one file per variable |
82 |
CMLC - creates relatively few files but these files can become huge |
83 |
CML CALL WRITE_REC_XYZ_RL('OPPSconv',OPPSconvectCount,opps_drctrec, |
84 |
CML & myIter,myThid) |
85 |
CML#else /* MULTIPLE_RECORD_OPPS_STATE_FILES */ |
86 |
CMLC Write each snap-shot as a new file |
87 |
CMLC - creates many files but for large configurations is easier to |
88 |
CMLC transfer analyse a particular snap-shots |
89 |
CML WRITE(suff,'(I10.10)') myIter |
90 |
CML CALL WRITE_FLD_XYZ_RL('OPPSconv.',suff,OPPSconvectCount, |
91 |
CML & myIter,myThid) |
92 |
CML#endif /* MULTIPLE_RECORD_OPPS_STATE_FILES */ |
93 |
CML endif |
94 |
CML |
95 |
CMLC-- Increment record counter |
96 |
CML opps_drctrec = opps_drctrec + 1 |
97 |
CML |
98 |
CML ENDIF |
99 |
|
100 |
C---------------------------------------------------------------- |
101 |
C Do OPPS time averaging. |
102 |
C---------------------------------------------------------------- |
103 |
|
104 |
#ifdef ALLOW_TIMEAVE |
105 |
|
106 |
C Initialize averages to zero |
107 |
IF ( myIter.EQ.nIter0 ) THEN |
108 |
DO bj = myByLo(myThid), myByHi(myThid) |
109 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
110 |
CALL TIMEAVE_RESET(OPPSconvectCountTave,Nr,bi,bj,myThid) |
111 |
DO k=1,Nr |
112 |
opps_TimeAve(k,bi,bj)=0. |
113 |
ENDDO |
114 |
ENDDO |
115 |
ENDDO |
116 |
ENDIF |
117 |
|
118 |
C Time Average OPPS fields |
119 |
IF ( myIter .EQ. nIter0 .OR. |
120 |
& DIFFERENT_MULTIPLE(OPPStaveFreq,myCurrentTime,deltaTClock) |
121 |
& ) THEN |
122 |
DDTT=0.5*deltaTclock |
123 |
ELSE |
124 |
DDTT=deltaTclock |
125 |
ENDIF |
126 |
DO bj = myByLo(myThid), myByHi(myThid) |
127 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
128 |
C Keep record of how much time has been integrated over |
129 |
DO k=1,Nr |
130 |
opps_TimeAve(k,bi,bj)=opps_TimeAve(k,bi,bj)+DDTT |
131 |
ENDDO |
132 |
ENDDO |
133 |
ENDDO |
134 |
|
135 |
C Dump files and restart average computation if needed |
136 |
IF ( myIter.NE.nIter0 .AND. |
137 |
& DIFFERENT_MULTIPLE(OPPStaveFreq, |
138 |
& myCurrentTime,deltaTClock) |
139 |
& ) THEN |
140 |
|
141 |
C Normalize by integrated time |
142 |
DO bj = myByLo(myThid), myByHi(myThid) |
143 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
144 |
CALL TIMEAVE_NORMALIZ(OPPSconvectCountTave,opps_timeave, |
145 |
& Nr, bi,bj,myThid) |
146 |
ENDDO |
147 |
ENDDO |
148 |
|
149 |
#ifdef MULTIPLE_RECORD_OPPS_STATE_FILES |
150 |
C Write each snap-shot as a new record in one file per variable |
151 |
C - creates relatively few files but these files can become huge |
152 |
CALL WRITE_REC_XYZ_RL('OPPSconvtave',OPPSconvectCountTave, |
153 |
& opps_drctrecTave,myIter,myThid) |
154 |
C-- Increment record counter |
155 |
opps_drctrecTave = opps_drctrecTave + 1 |
156 |
|
157 |
#else /* MULTIPLE_RECORD_OPPS_STATE_FILES */ |
158 |
|
159 |
C Write each snap-shot as a new file |
160 |
C - creates many files but for large configurations is easier to |
161 |
C transfer analyse a particular snap-shots |
162 |
WRITE(suff,'(I10.10)') myIter |
163 |
CALL WRITE_FLD_XYZ_RL('OPPSconvtave.',suff,OPPSconvectCountTave, |
164 |
& myIter,myThid) |
165 |
#endif /* MULTIPLE_RECORD_OPPS_STATE_FILES */ |
166 |
|
167 |
C Reset averages to zero |
168 |
DO bj = myByLo(myThid), myByHi(myThid) |
169 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
170 |
CALL TIMEAVE_RESET(OPPSconvectCountTave, Nr,bi,bj,myThid) |
171 |
DO k=1,Nr |
172 |
opps_TimeAve(k,bi,bj)=0. |
173 |
ENDDO |
174 |
ENDDO |
175 |
ENDDO |
176 |
|
177 |
C Time Average OPPS fields |
178 |
DDTT=0.5*deltaTclock |
179 |
DO bj = myByLo(myThid), myByHi(myThid) |
180 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
181 |
CALL TIMEAVE_CUMULATE( |
182 |
& OPPSconvectCountTave, OPPSconvectCount, |
183 |
& Nr,DDTT,bi,bj,myThid) |
184 |
C Keep record of how much time has been integrated over |
185 |
DO k=1,Nr |
186 |
opps_TimeAve(k,bi,bj)=opps_TimeAve(k,bi,bj)+DDTT |
187 |
ENDDO |
188 |
ENDDO |
189 |
ENDDO |
190 |
ENDIF |
191 |
|
192 |
#endif /* ALLOW_TIMEAVE */ |
193 |
|
194 |
#endif /* ALLOW_OPPS */ |
195 |
|
196 |
RETURN |
197 |
END |