/[MITgcm]/MITgcm/pkg/ptracers/ptracers_write_timeave.F
ViewVC logotype

Contents of /MITgcm/pkg/ptracers/ptracers_write_timeave.F

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


Revision 1.10 - (show annotations) (download)
Sat Jan 2 23:45:46 2010 UTC (14 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint63, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x
Changes since 1.9: +40 -46 lines
-rename: PTRACERS_STATV.h --> PTRACERS_TAVE.h
-rename: ptracers_statvars.F --> ptracers_timeave.F
-use simpler (no level index) cumulative-time counter:ptracer_half/full(bi,bj)

1 C $Header: /u/gcmpack/MITgcm/pkg/ptracers/ptracers_write_timeave.F,v 1.9 2007/11/05 18:48:04 jmc Exp $
2 C $Name: $
3
4 #include "PTRACERS_OPTIONS.h"
5
6 CBOP 1
7 C !ROUTINE: PTRACERS_WRITE_TIMEAVE
8
9 C !INTERFACE:
10 SUBROUTINE PTRACERS_WRITE_TIMEAVE( myTime, myIter, myThid )
11
12 C !DESCRIPTION:
13 C At the end of average period, write the time-average
14 C state-variables on file; then reset for next period
15
16 C !USES:
17 IMPLICIT NONE
18 #include "SIZE.h"
19 #include "EEPARAMS.h"
20 #include "PARAMS.h"
21 #include "PTRACERS_SIZE.h"
22 #include "PTRACERS_PARAMS.h"
23 #include "PTRACERS_TAVE.h"
24
25 C !FUNCTIONS:
26 LOGICAL DIFFERENT_MULTIPLE
27 EXTERNAL DIFFERENT_MULTIPLE
28 INTEGER IO_ERRCOUNT
29 EXTERNAL IO_ERRCOUNT
30
31 C !INPUT PARAMETERS:
32 C myTime :: Current time of simulation ( s )
33 C myIter :: Iteration number
34 C myThid :: my Thread Id number
35 _RL myTime
36 INTEGER myIter
37 INTEGER myThid
38 CEOP
39
40 #if ( defined ALLOW_PTRACERS && defined ALLOW_TIMEAVE )
41
42 C !LOCAL VARIABLES:
43 C suff :: Hold suffix part of a filename
44 CHARACTER*(MAX_LEN_FNAM) suff
45 INTEGER bi, bj, iTr
46 INTEGER beginIOErrCount
47 INTEGER endIOErrCount
48 CHARACTER*(MAX_LEN_MBUF) msgBuf
49 #ifdef ALLOW_MNC
50 INTEGER jj, ilnb
51 C Functions
52 INTEGER ILNBLNK
53 EXTERNAL ILNBLNK
54 CHARACTER*(1) pf
55 #endif /* ALLOW_MNC */
56
57 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
58
59 C Final Time Averages and Dump Files if needed
60 IF ( DIFFERENT_MULTIPLE( PTRACERS_taveFreq, myTime, deltaTClock )
61 & ) THEN
62
63 DO bj = myByLo(myThid), myByHi(myThid)
64 DO bi = myBxLo(myThid), myBxHi(myThid)
65 C-- Normalize by integrated time
66 DO iTr=1,PTRACERS_numInUse
67 CALL TIMEAVE_NORMALIZE(
68 & ptracerFluxtave(1-Olx,1-Oly, 1,1,iTr),
69 & ptracer_full, 1, bi, bj, myThid )
70 CALL TIMEAVE_NORMALIZE(
71 & ptracertave (1-Olx,1-Oly,1,1,1,iTr),
72 & ptracer_half, Nr, bi, bj, myThid )
73 ENDDO
74 ENDDO
75 ENDDO
76
77 C-- Write to files
78
79 #ifdef ALLOW_MNC
80 IF ( PTRACERS_timeave_mnc ) THEN
81 IF ( writeBinaryPrec .EQ. precFloat64 ) THEN
82 pf(1:1) = 'D'
83 ELSE
84 pf(1:1) = 'R'
85 ENDIF
86 CALL MNC_CW_SET_UDIM('ptr_tave', -1, myThid)
87 CALL MNC_CW_RL_W_S('D','ptr_tave',0,0,'T',myTime,myThid)
88 CALL MNC_CW_SET_UDIM('ptr_tave', 0, myThid)
89 CALL MNC_CW_I_W_S('I','ptr_tave',0,0,'iter',myIter,myThid)
90
91 CALL MNC_CW_SET_UDIM('ptr_flux_tave', -1, myThid)
92 CALL MNC_CW_RL_W_S('D','ptr_flux_tave',0,0,'T',myTime,
93 & myThid)
94 CALL MNC_CW_SET_UDIM('ptr_flux_tave', 0, myThid)
95 CALL MNC_CW_I_W_S('I','ptr_flux_tave',0,0,'iter',myIter,
96 & myThid)
97
98 DO iTr = 1,PTRACERS_numInUse
99 CALL MNC_CW_RL_W(pf,'ptr_tave',0,0,PTRACERS_names(iTr),
100 & ptracertave(1-OLx,1-OLy,1,1,1,iTr),myThid)
101 DO jj = 1,MAX_LEN_FNAM
102 suff(jj:jj) = ' '
103 ENDDO
104 ilnb = ILNBLNK(PTRACERS_names(iTr))
105 WRITE(suff,'(A,A)') 'surf_',PTRACERS_names(iTr)(1:ilnb)
106 CALL MNC_CW_RL_W(pf,'ptr_flux_tave',0,0,suff,
107 & ptracerFluxtave(1-OLx,1-OLy,1,1,iTr),myThid)
108 ENDDO
109 ENDIF
110 #endif /* ALLOW_MNC */
111
112 IF ( PTRACERS_timeave_mdsio ) THEN
113
114 C Read IO error counter
115 beginIOErrCount = IO_ERRCOUNT(myThid)
116
117 DO iTr=1,PTRACERS_numInUse
118 WRITE(suff,'(A7,I2.2,A1,I10.10)') 'PtrFluxtave',
119 & iTr, '.', myIter
120 CALL WRITE_FLD_XY_RL ( suff, ' ',
121 & ptracerFluxtave(1-Olx,1-Oly, 1,1,iTr),
122 & myIter, myThid )
123 WRITE(suff,'(A7,I2.2,A1,I10.10)') 'PTRtave',
124 & iTr, '.', myIter
125 CALL WRITE_FLD_XYZ_RL( suff, ' ',
126 & ptracertave (1-Olx,1-Oly,1,1,1,iTr),
127 & myIter, myThid )
128 ENDDO
129
130 C Reread IO error counter
131 endIOErrCount = IO_ERRCOUNT(myThid)
132
133 C Check for IO errors
134 IF ( endIOErrCount .NE. beginIOErrCount ) THEN
135 C- any thread that detects an error should report
136 WRITE(msgBuf,'(A)') 'S/R PTRACERS_WRITE_TIMEAVE'
137 CALL PRINT_ERROR( msgBuf, myThid )
138 WRITE(msgBuf,'(A)') 'Error writing out data'
139 CALL PRINT_ERROR( msgBuf, myThid )
140 WRITE(msgBuf,'(A,I10)') 'Timestep ',myIter
141 CALL PRINT_ERROR( msgBuf, myThid )
142 ELSE
143 C- normal case: 1 message is enough
144 _BEGIN_MASTER( myThid )
145 WRITE(msgBuf,'(A,I10)')
146 & '// PTRACER time-average data written, t-step', myIter
147 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
148 & SQUEEZE_RIGHT, myThid )
149 WRITE(msgBuf,'(A)') ' '
150 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
151 & SQUEEZE_RIGHT, myThid )
152 _END_MASTER( myThid )
153 ENDIF
154
155 ENDIF
156
157 DO bj = myByLo(myThid), myByHi(myThid)
158 DO bi = myBxLo(myThid), myBxHi(myThid)
159
160 C Like before the 1rst iteration,
161 C ==> call TIMEAVE_TIMEAVE with myIter=nIter0 :
162 C 1) Reset the averages to zero ;
163 C 2) Start to cumulate state-variables with Half time step.
164
165 CALL PTRACERS_TIMEAVE( myTime, nIter0, bi, bj, myThid )
166
167 ENDDO
168 ENDDO
169
170 ENDIF
171
172 #endif /* ALLOW_PTRACERS and ALLOW_TIMEAVE */
173
174 RETURN
175 END

  ViewVC Help
Powered by ViewVC 1.1.22