1 |
C $Header: /u/gcmpack/MITgcm/pkg/longstep/longstep_average.F,v 1.5 2010/01/12 23:55:48 jahn Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "LONGSTEP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: LONGSTEP_AVERAGE |
8 |
C !INTERFACE: |
9 |
SUBROUTINE LONGSTEP_AVERAGE( myTime, myIter, myThid ) |
10 |
|
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE LONGSTEP_AVERAGE |
14 |
C | o Average variables needed for longstep |
15 |
C | - myIter is used for determining the averaging interval |
16 |
C | (LS_nIter timesteps, phase 0) |
17 |
C *==========================================================* |
18 |
C \ev |
19 |
|
20 |
C !USES: |
21 |
IMPLICIT NONE |
22 |
C == Global variables === |
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 "SURFACE.h" |
30 |
#include "LONGSTEP_PARAMS.h" |
31 |
#include "LONGSTEP.h" |
32 |
#ifdef ALLOW_GMREDI |
33 |
#include "GMREDI.h" |
34 |
#endif |
35 |
#ifdef ALLOW_KPP |
36 |
#include "KPP.h" |
37 |
#endif |
38 |
|
39 |
C !INPUT/OUTPUT PARAMETERS: |
40 |
C == Routine arguments == |
41 |
C myTime :: Current time in simulation |
42 |
C myIter :: Current iteration number in simulation |
43 |
C myThid :: my Thread Id number |
44 |
_RL myTime |
45 |
INTEGER myIter |
46 |
INTEGER myThid |
47 |
|
48 |
#ifdef ALLOW_LONGSTEP |
49 |
C !LOCAL VARIABLES: |
50 |
C == Local variables == |
51 |
CEOP |
52 |
|
53 |
C first iteration in a long time step? - reset averages |
54 |
IF ( MOD(myIter, LS_nIter) .EQ. 0 ) THEN |
55 |
|
56 |
CALL LONGSTEP_RESET_3D(LS_uVelCount, LS_uVel, Nr, myThid) |
57 |
CALL LONGSTEP_RESET_3D(LS_vVelCount, LS_vVel, Nr, myThid) |
58 |
CALL LONGSTEP_RESET_3D(LS_wVelCount, LS_wVel, Nr, myThid) |
59 |
CALL LONGSTEP_RESET_3D(LS_thetaCount,LS_theta,Nr, myThid) |
60 |
CALL LONGSTEP_RESET_3D(LS_saltCount, LS_salt, Nr, myThid) |
61 |
IF ( ivdc_kappa .NE. 0. _d 0 ) |
62 |
& CALL LONGSTEP_RESET_3D(LS_IVDConvCountCount, |
63 |
& LS_IVDConvCount, Nr, myThid) |
64 |
#ifdef SHORTWAVE_HEATING |
65 |
CALL LONGSTEP_RESET_3D(LS_QswCount, LS_Qsw, 1, myThid) |
66 |
#endif |
67 |
CALL LONGSTEP_RESET_3D(LS_fwFluxCount, LS_fwFlux, 1, myThid) |
68 |
#ifdef ALLOW_GMREDI |
69 |
IF ( useGMRedi ) THEN |
70 |
CALL LONGSTEP_RESET_3D(LS_KwxCount, LS_Kwx, Nr, myThid) |
71 |
CALL LONGSTEP_RESET_3D(LS_KwyCount, LS_Kwy, Nr, myThid) |
72 |
CALL LONGSTEP_RESET_3D(LS_KwzCount, LS_Kwz, Nr, myThid) |
73 |
ENDIF |
74 |
#endif |
75 |
#ifdef ALLOW_KPP |
76 |
IF ( useKPP ) THEN |
77 |
CALL LONGSTEP_RESET_3D(LS_KPPdiffKzSCount, |
78 |
& LS_KPPdiffKzS, Nr, myThid) |
79 |
CALL LONGSTEP_RESET_3D(LS_KPPghatCount, |
80 |
& LS_KPPghat, Nr, myThid) |
81 |
ENDIF |
82 |
#endif |
83 |
|
84 |
ENDIF |
85 |
|
86 |
C-- update average inside tile (no overlaps) for all bi,bj |
87 |
|
88 |
CALL LONGSTEP_FILL_3D_FAC(LS_uVelCount, LS_uVel, uVel, hFacW, |
89 |
& Nr, myThid) |
90 |
CALL LONGSTEP_FILL_3D_FAC(LS_vVelCount, LS_vVel, vVel, hFacS, |
91 |
& Nr, myThid) |
92 |
CALL LONGSTEP_FILL_3D(LS_wVelCount, LS_wVel, wVel, Nr, myThid) |
93 |
CALL LONGSTEP_FILL_3D(LS_thetaCount, LS_theta, theta, Nr, myThid) |
94 |
CALL LONGSTEP_FILL_3D(LS_saltCount, LS_salt, salt, Nr, myThid) |
95 |
IF ( ivdc_kappa .NE. 0. _d 0 ) |
96 |
& CALL LONGSTEP_FILL_3D(LS_IVDConvCountCount, |
97 |
& LS_IVDConvCount, IVDConvCount, Nr, myThid) |
98 |
#ifdef SHORTWAVE_HEATING |
99 |
CALL LONGSTEP_FILL_3D_RS(LS_QswCount, LS_Qsw, Qsw, 1, myThid) |
100 |
#endif |
101 |
IF ( LS_usePmEpR ) THEN |
102 |
CALL LONGSTEP_FILL_3D( LS_fwFluxCount,LS_fwFlux,PmEpR,1,myThid) |
103 |
ELSE |
104 |
CALL LONGSTEP_FILL_3D_RS(LS_fwFluxCount,LS_fwFlux,EmPmR,1,myThid) |
105 |
ENDIF |
106 |
#ifdef ALLOW_GMREDI |
107 |
IF ( useGMRedi ) THEN |
108 |
CALL LONGSTEP_FILL_3D(LS_KwxCount, LS_Kwx, Kwx, Nr, myThid) |
109 |
CALL LONGSTEP_FILL_3D(LS_KwyCount, LS_Kwy, Kwy, Nr, myThid) |
110 |
CALL LONGSTEP_FILL_3D(LS_KwzCount, LS_Kwz, Kwz, Nr, myThid) |
111 |
ENDIF |
112 |
#endif |
113 |
#ifdef ALLOW_KPP |
114 |
IF ( useKPP ) THEN |
115 |
CALL LONGSTEP_FILL_3D(LS_KPPdiffKzSCount, |
116 |
& LS_KPPdiffKzS, KPPdiffKzS, Nr, myThid) |
117 |
CALL LONGSTEP_FILL_3D(LS_KPPghatCount, |
118 |
& LS_KPPghat, KPPghat, Nr, myThid) |
119 |
ENDIF |
120 |
#endif |
121 |
|
122 |
C time for a ptracer time step? - finish average |
123 |
IF ( MOD(myIter, LS_nIter) .EQ. LS_nIter-1 ) THEN |
124 |
|
125 |
CALL LONGSTEP_AVERAGE_3D_FAC(LS_uVelCount, LS_uVel, hFacW, |
126 |
& Nr, myThid) |
127 |
CALL LONGSTEP_AVERAGE_3D_FAC(LS_vVelCount, LS_vVel, hFacS, |
128 |
& Nr, myThid) |
129 |
CALL LONGSTEP_AVERAGE_3D(LS_wVelCount, LS_wVel, Nr, myThid) |
130 |
CALL LONGSTEP_AVERAGE_3D(LS_thetaCount,LS_theta,Nr, myThid) |
131 |
CALL LONGSTEP_AVERAGE_3D(LS_saltCount, LS_salt, Nr, myThid) |
132 |
IF ( ivdc_kappa .NE. 0. _d 0 ) |
133 |
& CALL LONGSTEP_AVERAGE_3D(LS_IVDConvCountCount, |
134 |
& LS_IVDConvCount, Nr, myThid) |
135 |
#ifdef SHORTWAVE_HEATING |
136 |
CALL LONGSTEP_AVERAGE_3D(LS_QswCount, LS_Qsw, 1, myThid) |
137 |
#endif |
138 |
CALL LONGSTEP_AVERAGE_3D(LS_fwFluxCount, LS_fwFlux, 1, myThid) |
139 |
|
140 |
#ifdef ALLOW_GMREDI |
141 |
IF ( useGMRedi ) THEN |
142 |
CALL LONGSTEP_AVERAGE_3D(LS_KwxCount, LS_Kwx, Nr, myThid) |
143 |
CALL LONGSTEP_AVERAGE_3D(LS_KwyCount, LS_Kwy, Nr, myThid) |
144 |
CALL LONGSTEP_AVERAGE_3D(LS_KwzCount, LS_Kwz, Nr, myThid) |
145 |
ENDIF |
146 |
#endif |
147 |
#ifdef ALLOW_KPP |
148 |
IF ( useKPP ) THEN |
149 |
CALL LONGSTEP_AVERAGE_3D(LS_KPPdiffKzSCount, |
150 |
& LS_KPPdiffKzS, Nr, myThid) |
151 |
CALL LONGSTEP_AVERAGE_3D(LS_KPPghatCount, |
152 |
& LS_KPPghat, Nr, myThid) |
153 |
ENDIF |
154 |
#endif |
155 |
|
156 |
#if 0 |
157 |
C and update overlaps |
158 |
CALL EXCH_UV_3D_RL( LS_uVel, LS_vVel, .TRUE., Nr, myThid ) |
159 |
CALL EXCH_3D_RL( LS_wVel , Nr, myThid ) |
160 |
CALL EXCH_3D_RL( LS_theta, Nr, myThid ) |
161 |
CALL EXCH_3D_RL( LS_salt , Nr, myThid ) |
162 |
IF ( ivdc_kappa .NE. 0. _d 0 ) |
163 |
& CALL EXCH_3D_RL( LS_IVDConvCount, myThid ) |
164 |
#ifdef SHORTWAVE_HEATING |
165 |
CALL EXCH_XY_RL( LS_Qsw, myThid ) |
166 |
#endif |
167 |
CALL EXCH_XY_RL( LS_fwFlux, myThid ) |
168 |
#ifdef ALLOW_GMREDI |
169 |
IF ( useGMRedi ) THEN |
170 |
CALL EXCH_UV_AGRID_3D_RL( LS_Kwx, LS_Kwy, .FALSE., Nr, myThid ) |
171 |
CALL EXCH_3D_RL( LS_Kwz , Nr, myThid ) |
172 |
ENDIF |
173 |
#endif |
174 |
#ifdef ALLOW_KPP |
175 |
IF ( useKPP ) THEN |
176 |
CALL EXCH_3D_RL( LS_KPPdiffKzS, Nr, myThid ) |
177 |
CALL EXCH_3D_RL( LS_KPPghat, Nr, myThid ) |
178 |
ENDIF |
179 |
#endif |
180 |
#endif /* 0 */ |
181 |
|
182 |
#ifdef ALLOW_DIAGNOSTICS |
183 |
IF ( useDiagnostics ) THEN |
184 |
CALL DIAGNOSTICS_FILL(LS_uVel, 'LSuVel ',0,Nr,0,1,1,myThid) |
185 |
CALL DIAGNOSTICS_FILL(LS_vVel, 'LSvVel ',0,Nr,0,1,1,myThid) |
186 |
CALL DIAGNOSTICS_FILL(LS_wVel, 'LSwVel ',0,Nr,0,1,1,myThid) |
187 |
CALL DIAGNOSTICS_FILL(LS_theta,'LStheta ',0,Nr,0,1,1,myThid) |
188 |
CALL DIAGNOSTICS_FILL(LS_salt, 'LSsalt ',0,Nr,0,1,1,myThid) |
189 |
IF ( ivdc_kappa .NE. 0. _d 0 .AND. .NOT. useKPP ) |
190 |
& CALL DIAGNOSTICS_FILL(LS_IVDConvCount, |
191 |
& 'LScnvAdj',0,Nr,0,1,1,myThid) |
192 |
#ifdef SHORTWAVE_HEATING |
193 |
CALL DIAGNOSTICS_FILL(LS_Qsw , 'LSqsw ',0,1 ,0,1,1,myThid) |
194 |
#endif |
195 |
CALL DIAGNOSTICS_FILL(LS_fwFlux, 'LSfwFlux',0,1 ,0,1,1,myThid) |
196 |
#ifdef ALLOW_GMREDI |
197 |
IF ( useGMRedi ) THEN |
198 |
CALL DIAGNOSTICS_FILL(LS_Kwx , 'LSkwx ',0,Nr,0,1,1,myThid) |
199 |
CALL DIAGNOSTICS_FILL(LS_Kwy , 'LSkwy ',0,Nr,0,1,1,myThid) |
200 |
CALL DIAGNOSTICS_FILL(LS_Kwz , 'LSkwz ',0,Nr,0,1,1,myThid) |
201 |
ENDIF |
202 |
#endif |
203 |
#ifdef ALLOW_KPP |
204 |
IF ( useKPP ) THEN |
205 |
CALL DIAGNOSTICS_FILL(LS_KPPdiffKzs, |
206 |
& 'LSKPPdfS',0,Nr,0,1,1,myThid) |
207 |
CALL DIAGNOSTICS_FILL(LS_KPPghat, |
208 |
& 'LSKPPght',0,Nr,0,1,1,myThid) |
209 |
ENDIF |
210 |
#endif |
211 |
C if useDiagnostics: end |
212 |
ENDIF |
213 |
#endif /* ALLOW_DIAGNOSTICS */ |
214 |
|
215 |
_BARRIER |
216 |
_BEGIN_MASTER(myThid) |
217 |
C we decide whether to do a timestep here and everybody else just |
218 |
C checks this variable. This avoids complications with |
219 |
C staggerTimeStep |
220 |
LS_doTimeStep = .TRUE. |
221 |
_END_MASTER(myThid) |
222 |
_BARRIER |
223 |
|
224 |
ELSEIF ( MOD(myIter, LS_nIter) .EQ. 0 ) THEN |
225 |
|
226 |
C next time-step: switch back LS_doTimeStep |
227 |
_BARRIER |
228 |
_BEGIN_MASTER(myThid) |
229 |
LS_doTimeStep = .FALSE. |
230 |
_END_MASTER(myThid) |
231 |
_BARRIER |
232 |
|
233 |
C if MOD(myIter, LS_nIter): end |
234 |
ENDIF |
235 |
|
236 |
#endif /* ALLOW_LONGSTEP */ |
237 |
|
238 |
RETURN |
239 |
END |
240 |
|