/[MITgcm]/MITgcm/pkg/timeave/timeave_statv_write.F
ViewVC logotype

Contents of /MITgcm/pkg/timeave/timeave_statv_write.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download)
Thu May 1 22:17:42 2003 UTC (21 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.5: +6 -1 lines
add time-average diagnostic of U*V and diff_Kr*theta

1 C $Header: /u/gcmpack/MITgcm/pkg/timeave/timeave_statv_write.F,v 1.5 2002/10/07 16:29:04 jmc Exp $
2 C $Name: $
3 #include "CPP_OPTIONS.h"
4
5 SUBROUTINE TIMEAVE_STATV_WRITE(myTime, myIter, myThid)
6 C /==========================================================\
7 C | SUBROUTINE TIMEAVE_STATV_WRITE |
8 C | o At the end of average period, write the time-average |
9 C | state-variables on file ; then reset for next period |
10 C \==========================================================/
11 IMPLICIT NONE
12
13 C == Global variables ===
14 #include "SIZE.h"
15 #include "EEPARAMS.h"
16 #include "PARAMS.h"
17 #include "DYNVARS.h"
18 #include "GRID.h"
19 #include "TIMEAVE_STATV.h"
20
21 LOGICAL DIFFERENT_MULTIPLE
22 EXTERNAL DIFFERENT_MULTIPLE
23 INTEGER IO_ERRCOUNT
24 EXTERNAL IO_ERRCOUNT
25
26 C == Routine arguments ==
27 C myThid - Thread number for this instance of the routine.
28 C myIter - Iteration number
29 C myTime - Current time of simulation ( s )
30 INTEGER myThid
31 INTEGER myIter
32 _RL myTime
33
34 #ifdef ALLOW_TIMEAVE
35
36 C == Local variables ==
37 C suff - Hold suffix part of a filename
38 C TimeAve - total time over average
39 INTEGER prevPrec
40 CHARACTER*(MAX_LEN_FNAM) suff
41 INTEGER bi,bj,k
42 INTEGER beginIOErrCount
43 INTEGER endIOErrCount
44 CHARACTER*(MAX_LEN_MBUF) msgBuf
45
46 C- Final Time Averages and Dump Files if needed
47 IF(DIFFERENT_MULTIPLE(taveFreq,myTime,myTime-deltaTClock) )THEN
48
49 WRITE(suff,'(I10.10)') myIter
50
51 DO bj = myByLo(myThid), myByHi(myThid)
52 DO bi = myBxLo(myThid), myBxHi(myThid)
53 C- Normalize by integrated time
54 CALL TIMEAVE_NORMALIZ(etatave, TimeAve_half,1 ,bi,bj,myThid)
55 CALL TIMEAVE_NORMALIZ(thetatave,TimeAve_half,Nr,bi,bj,myThid)
56 CALL TIMEAVE_NORMALIZ(salttave, TimeAve_half,Nr,bi,bj,myThid)
57 CALL TIMEAVE_NORMALIZ(uVeltave, TimeAve_half,Nr,bi,bj,myThid)
58 CALL TIMEAVE_NORMALIZ(vVeltave, TimeAve_half,Nr,bi,bj,myThid)
59 CALL TIMEAVE_NORMALIZ(wVeltave, TimeAve_half,Nr,bi,bj,myThid)
60 CALL TIMEAVE_NORMALIZ(Eta2tave, TimeAve_half,1 ,bi,bj,myThid)
61 CALL TIMEAVE_NORMALIZ(TTtave, TimeAve_half,Nr,bi,bj,myThid)
62 CALL TIMEAVE_NORMALIZ(UUtave, TimeAve_half,Nr,bi,bj,myThid)
63 CALL TIMEAVE_NORMALIZ(VVtave, TimeAve_half,Nr,bi,bj,myThid)
64 CALL TIMEAVE_NORMALIZ(UVtave, TimeAve_half,Nr,bi,bj,myThid)
65 c CALL TIMEAVE_NORMALIZ(KEtave, TimeAve_half,Nr,bi,bj,myThid)
66 #ifdef NONLIN_FRSURF
67 C- Normalize by integrated time
68 CALL TIMEAVE_NORMALIZ(hUtave, TimeAve_half,Nr,bi,bj,myThid)
69 CALL TIMEAVE_NORMALIZ(hVtave, TimeAve_half,Nr,bi,bj,myThid)
70 c CALL TIMEAVE_NORMALIZ(hFacCtave,TimeAve_half,Nr,bi,bj,myThid)
71 c CALL TIMEAVE_NORMALIZ(hFacWtave,TimeAve_half,Nr,bi,bj,myThid)
72 c CALL TIMEAVE_NORMALIZ(hFacStave,TimeAve_half,Nr,bi,bj,myThid)
73 #endif /* NONLIN_FRSURF */
74 CALL TIMEAVE_NORMALIZ(UTtave, TimeAve_half,Nr,bi,bj,myThid)
75 CALL TIMEAVE_NORMALIZ(VTtave, TimeAve_half,Nr,bi,bj,myThid)
76 CALL TIMEAVE_NORMALIZ(WTtave, TimeAve_half,Nr,bi,bj,myThid)
77
78 CALL TIMEAVE_NORMALIZ(TdiffRtave,TimeAve_full,Nr,
79 & bi,bj,myThid)
80 CALL TIMEAVE_NORMALIZ(phiHydtave,TimeAve_full,Nr,
81 & bi,bj,myThid)
82 CALL TIMEAVE_NORMALIZ(phiHydLowtave,TimeAve_full,1,
83 & bi,bj,myThid)
84 CALL TIMEAVE_NORMALIZ(phiHydLow2Tave,TimeAve_full,1,
85 & bi,bj,myThid)
86 CALL TIMEAVE_NORMALIZ(ConvectCountTave,TimeAve_full,Nr,
87 & bi,bj,myThid)
88 ENDDO
89 ENDDO
90
91 C Write to files
92 _BARRIER
93 _BEGIN_MASTER( myThid )
94
95 C-- Set IO "context" for writing state
96 #ifdef USE_DFILE
97 CALL DFILE_SET_RW
98 CALL DFILE_SET_CONT_ON_ERROR
99 #endif
100 C-- Read IO error counter
101 beginIOErrCount = IO_ERRCOUNT(myThid)
102 c prevPrec = writeBinaryPrec
103 c writeBinaryPrec = precFloat32
104 CALL WRITE_FLD_XY_RL('ETAtave.',suff,etatave,myIter,myThid)
105 CALL WRITE_FLD_XY_RL('Eta2tave.',suff,Eta2tave,myIter,myThid)
106
107 CALL WRITE_FLD_XYZ_RL('Ttave.',suff,thetatave,myIter,myThid)
108 CALL WRITE_FLD_XYZ_RL('Stave.',suff,salttave,myIter,myThid)
109 CALL WRITE_FLD_XYZ_RL('uVeltave.',suff,uVeltave,myIter,myThid)
110 CALL WRITE_FLD_XYZ_RL('vVeltave.',suff,vVeltave,myIter,myThid)
111 CALL WRITE_FLD_XYZ_RL('wVeltave.',suff,wVeltave,myIter,myThid)
112 CALL WRITE_FLD_XYZ_RL('TTtave.',suff,TTtave,myIter,myThid)
113 CALL WRITE_FLD_XYZ_RL('UUtave.',suff,UUtave,myIter,myThid)
114 CALL WRITE_FLD_XYZ_RL('VVtave.',suff,VVtave,myIter,myThid)
115 CALL WRITE_FLD_XYZ_RL('UVtave.',suff,UVtave,myIter,myThid)
116 c CALL WRITE_FLD_XYZ_RL('KEtave.',suff,KEtave,myIter,myThid)
117 CALL WRITE_FLD_XYZ_RL('UTtave.',suff,UTtave,myIter,myThid)
118 CALL WRITE_FLD_XYZ_RL('VTtave.',suff,VTtave,myIter,myThid)
119 CALL WRITE_FLD_XYZ_RL('WTtave.',suff,WTtave,myIter,myThid)
120
121 CALL WRITE_FLD_XYZ_RL('Tdiftave.',suff,TdiffRtave,myIter,myThid)
122 CALL WRITE_FLD_XYZ_RL('PhHytave.',suff,phiHydtave,myIter,myThid)
123 IF ( buoyancyRelation .NE. 'ATMOSPHERIC' ) THEN
124 CALL WRITE_FLD_XY_RL('PHLtave.',suff,phiHydLowtave,
125 & myIter,myThid)
126 CALL WRITE_FLD_XY_RL('PHL2tave.',suff,phiHydLow2tave,
127 & myIter,myThid)
128 CALL WRITE_FLD_XYZ_RL('Convtave.',suff,ConvectCountTave,
129 & myIter,myThid)
130 ENDIF
131
132 #ifdef NONLIN_FRSURF
133 CALL WRITE_FLD_XYZ_RL('hUtave.',suff,hUtave,myIter,myThid)
134 CALL WRITE_FLD_XYZ_RL('hVtave.',suff,hVtave,myIter,myThid)
135 c CALL WRITE_FLD_XYZ_RL('hFacCtave.',suff,hFacCtave,myIter,myThid)
136 c CALL WRITE_FLD_XYZ_RL('hFacWtave.',suff,hFacWtave,myIter,myThid)
137 c CALL WRITE_FLD_XYZ_RL('hFacStave.',suff,hFacStave,myIter,myThid)
138 #endif /* NONLIN_FRSURF */
139
140 c writeBinaryPrec = prevPrec
141 C-- Reread IO error counter
142 endIOErrCount = IO_ERRCOUNT(myThid)
143
144 C-- Check for IO errors
145 IF ( endIOErrCount .NE. beginIOErrCount ) THEN
146 WRITE(msgBuf,'(A)') 'S/R WRITE_TIME_AVERAGES'
147 CALL PRINT_ERROR( msgBuf, 1 )
148 WRITE(msgBuf,'(A)') 'Error writing out data'
149 CALL PRINT_ERROR( msgBuf, 1 )
150 WRITE(msgBuf,'(A,I10)') 'Timestep ',myIter
151 CALL PRINT_ERROR( msgBuf, 1 )
152 ELSE
153 WRITE(msgBuf,'(A,I10)')
154 & '// Time-average data written, t-step', myIter
155 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
156 & SQUEEZE_RIGHT, 1 )
157 WRITE(msgBuf,'(A)') ' '
158 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
159 & SQUEEZE_RIGHT, 1 )
160 ENDIF
161
162 _END_MASTER( myThid )
163 _BARRIER
164
165 DO bj = myByLo(myThid), myByHi(myThid)
166 DO bi = myBxLo(myThid), myBxHi(myThid)
167
168 C-- Like before the 1rst iteration,
169 C ==> call TIMEAVE_STATVARS with myIter=nIter0 :
170 C 1) Reset the averages to zero ;
171 C 2) Start to cumulate state-variables with Half time step.
172
173 CALL TIMEAVE_STATVARS(myTime, nIter0, bi, bj, myThid)
174
175 ENDDO
176 ENDDO
177
178 ENDIF
179
180 #endif /* ALLOW_TIMEAVE */
181
182 RETURN
183 END

  ViewVC Help
Powered by ViewVC 1.1.22