1 |
C $Header: /u/gcmpack/MITgcm/pkg/ggl90/ggl90_output.F,v 1.2 2010/01/03 18:55:06 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "GGL90_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: GGL90_OUTPUT |
8 |
C !INTERFACE: |
9 |
SUBROUTINE GGL90_OUTPUT( myTime, myIter, myThid ) |
10 |
|
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE GGL90_OUTPUT |
14 |
C | o Do GGL90 diagnostic output. |
15 |
C *========================================================== |
16 |
C | The following CPP flag (MULTIPLE_RECORD_GGL90_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 "GGL90.h" |
48 |
#include "GGL90_TAVE.h" |
49 |
|
50 |
C !INPUT/OUTPUT PARAMETERS: |
51 |
C == Routine arguments == |
52 |
C myTime :: my time in simulation ( s ) |
53 |
C myIter :: my Iteration number |
54 |
C myThid :: my Thread Id number |
55 |
_RL myTime |
56 |
INTEGER myIter |
57 |
INTEGER myThid |
58 |
|
59 |
#ifdef ALLOW_GGL90 |
60 |
|
61 |
C !FUNCTIONS: |
62 |
LOGICAL DIFFERENT_MULTIPLE |
63 |
EXTERNAL DIFFERENT_MULTIPLE |
64 |
|
65 |
C !LOCAL VARIABLES: |
66 |
C == Local variables == |
67 |
CHARACTER*(MAX_LEN_MBUF) suff |
68 |
#ifdef ALLOW_TIMEAVE |
69 |
INTEGER bi, bj |
70 |
_RL DDTT |
71 |
#endif |
72 |
CEOP |
73 |
|
74 |
C---------------------------------------------------------------- |
75 |
C Dump snapshot of GGL90 variables. |
76 |
C---------------------------------------------------------------- |
77 |
|
78 |
IF ( |
79 |
& DIFFERENT_MULTIPLE(GGL90dumpFreq,myTime,deltaTClock) |
80 |
& ) THEN |
81 |
|
82 |
IF (GGL90writeState) THEN |
83 |
C Write each snap-shot as a new file |
84 |
WRITE(suff,'(I10.10)') myIter |
85 |
IF ( myIter.NE.nIter0 ) THEN |
86 |
CALL WRITE_FLD_XYZ_RL( 'GGL90viscArU.', suff, |
87 |
& GGL90viscArU, myIter, myThid ) |
88 |
CALL WRITE_FLD_XYZ_RL( 'GGL90viscArV.', suff, |
89 |
& GGL90viscArV, myIter, myThid ) |
90 |
CALL WRITE_FLD_XYZ_RL( 'GGL90diffKr.', suff, |
91 |
& GGL90diffKr, myIter, myThid ) |
92 |
ENDIF |
93 |
CALL WRITE_FLD_XYZ_RL( 'GGL90TKE.', suff, |
94 |
& GGL90TKE, myIter, myThid ) |
95 |
ENDIF |
96 |
|
97 |
ENDIF |
98 |
|
99 |
C---------------------------------------------------------------- |
100 |
C Do GGL90 time averaging. |
101 |
C---------------------------------------------------------------- |
102 |
|
103 |
#ifdef ALLOW_TIMEAVE |
104 |
IF ( GGL90taveFreq .GT. 0. _d 0 ) THEN |
105 |
|
106 |
IF ( myIter.EQ.nIter0 ) THEN |
107 |
C Initialize averages to zero |
108 |
DO bj = myByLo(myThid), myByHi(myThid) |
109 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
110 |
CALL TIMEAVE_RESET( GGL90viscArUtave, Nr, bi, bj, myThid ) |
111 |
CALL TIMEAVE_RESET( GGL90viscArVtave, Nr, bi, bj, myThid ) |
112 |
CALL TIMEAVE_RESET( GGL90diffKrtave, Nr, bi, bj, myThid ) |
113 |
CALL TIMEAVE_RESET( GGL90TKEtave, Nr, bi, bj, myThid ) |
114 |
GGL90_timeAve(bi,bj) = 0. |
115 |
ENDDO |
116 |
ENDDO |
117 |
|
118 |
ELSE |
119 |
C Cumulate GGL90 fields (for Time Average) |
120 |
DDTT=deltaTclock |
121 |
DO bj = myByLo(myThid), myByHi(myThid) |
122 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
123 |
CALL TIMEAVE_CUMULATE( GGL90viscArUtave, GGL90viscArU, |
124 |
& Nr, DDTT, bi, bj, myThid ) |
125 |
CALL TIMEAVE_CUMULATE( GGL90viscArVtave, GGL90viscArV, |
126 |
& Nr, DDTT, bi, bj, myThid ) |
127 |
CALL TIMEAVE_CUMULATE( GGL90diffKrtave, GGL90diffKr, |
128 |
& Nr, DDTT, bi, bj, myThid ) |
129 |
CALL TIMEAVE_CUMULATE( GGL90TKEtave, GGL90TKE, |
130 |
& Nr, DDTT, bi, bj, myThid ) |
131 |
C Keep record of how much time has been integrated over |
132 |
GGL90_timeAve(bi,bj) = GGL90_timeAve(bi,bj)+DDTT |
133 |
ENDDO |
134 |
ENDDO |
135 |
ENDIF |
136 |
|
137 |
C Dump files and restart average computation if needed |
138 |
IF ( myIter.NE.nIter0 .AND. |
139 |
& DIFFERENT_MULTIPLE(GGL90taveFreq,myTime,deltaTClock) |
140 |
& ) THEN |
141 |
|
142 |
C Normalize by integrated time |
143 |
DO bj = myByLo(myThid), myByHi(myThid) |
144 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
145 |
CALL TIMEAVE_NORMALIZE( GGL90viscArUtave, |
146 |
& GGL90_timeAve, Nr, bi, bj, myThid ) |
147 |
CALL TIMEAVE_NORMALIZE( GGL90viscArVtave, |
148 |
& GGL90_timeAve, Nr, bi, bj, myThid ) |
149 |
CALL TIMEAVE_NORMALIZE( GGL90diffKrtave, |
150 |
& GGL90_timeAve, Nr, bi, bj, myThid ) |
151 |
CALL TIMEAVE_NORMALIZE( GGL90TKEtave, |
152 |
& GGL90_timeAve, Nr, bi, bj, myThid ) |
153 |
ENDDO |
154 |
ENDDO |
155 |
|
156 |
C Write each snap-shot as a new file |
157 |
WRITE(suff,'(I10.10)') myIter |
158 |
CALL WRITE_FLD_XYZ_RL( 'GGL90viscArU-T.', suff, |
159 |
& GGL90viscArUtave, myIter, myThid ) |
160 |
CALL WRITE_FLD_XYZ_RL( 'GGL90viscArV-T.', suff, |
161 |
& GGL90viscArVtave, myIter, myThid ) |
162 |
CALL WRITE_FLD_XYZ_RL( 'GGL90diffKr-T.', suff, |
163 |
& GGL90diffKrTave, myIter, myThid ) |
164 |
CALL WRITE_FLD_XYZ_RL( 'GGL90TKE-T.', suff, |
165 |
& GGL90TKETave, myIter, myThid ) |
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( GGL90viscArUtave, Nr, bi, bj, myThid ) |
171 |
CALL TIMEAVE_RESET( GGL90viscArVtave, Nr, bi, bj, myThid ) |
172 |
CALL TIMEAVE_RESET( GGL90diffKrtave, Nr, bi, bj, myThid ) |
173 |
CALL TIMEAVE_RESET( GGL90TKEtave, Nr, bi, bj, myThid ) |
174 |
GGL90_timeAve(bi,bj) = 0. |
175 |
ENDDO |
176 |
ENDDO |
177 |
|
178 |
C- end dump-files block |
179 |
ENDIF |
180 |
|
181 |
C- end if GGL90taveFreq > 0 |
182 |
ENDIF |
183 |
#endif /* ALLOW_TIMEAVE */ |
184 |
|
185 |
#endif /* ALLOW_GGL90 */ |
186 |
|
187 |
RETURN |
188 |
END |