1 |
C $Header: /u/gcmpack/MITgcm/model/src/the_correction_step.F,v 1.21 2003/04/17 13:40:06 jmc Exp $ |
2 |
C Tag $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: THE_CORRECTION_STEP |
8 |
C !INTERFACE: |
9 |
SUBROUTINE THE_CORRECTION_STEP(myTime, myIter, myThid) |
10 |
C !DESCRIPTION: \bv |
11 |
C *==========================================================* |
12 |
C | SUBROUTINE THE_CORRECTION_STEP |
13 |
C *==========================================================* |
14 |
C |1rst Part : Update U,V,T,S. |
15 |
C | |
16 |
C | The arrays used for time stepping are cycled. |
17 |
C | Tracers: |
18 |
C | T(n) = Gt(n) |
19 |
C | Momentum: |
20 |
C | V(n) = Gv(n) - dt * grad Eta |
21 |
C | |
22 |
C |part1: update U,V,T,S |
23 |
C | U*,V* (contained in gU,gV) have the surface |
24 |
C | pressure gradient term added and the result stored |
25 |
C | in U,V (contained in uVel, vVel) |
26 |
C | T* (contained in gT) is copied to T (theta) |
27 |
C | S* (contained in gS) is copied to S (salt) |
28 |
C | |
29 |
C |part2: Adjustments & Diagnostics |
30 |
C | o Filter U,V,T,S (Shapiro Filter, Zonal_Filter) |
31 |
C | o Convective Adjustment |
32 |
C | o Compute again Eta (exact volume conservation) |
33 |
C | o Compute vertical velocity |
34 |
C | o Diagmnostic of state variables (Time average) |
35 |
C *==========================================================* |
36 |
C \ev |
37 |
|
38 |
C !USES: |
39 |
IMPLICIT NONE |
40 |
C == Global variables === |
41 |
#include "SIZE.h" |
42 |
#include "EEPARAMS.h" |
43 |
#include "PARAMS.h" |
44 |
#include "DYNVARS.h" |
45 |
#ifdef ALLOW_PASSIVE_TRACER |
46 |
#include "TR1.h" |
47 |
#endif |
48 |
|
49 |
#ifdef ALLOW_SHAP_FILT |
50 |
#include "SHAP_FILT.h" |
51 |
#endif |
52 |
#ifdef ALLOW_ZONAL_FILT |
53 |
#include "ZONAL_FILT.h" |
54 |
#endif |
55 |
|
56 |
C !INPUT/OUTPUT PARAMETERS: |
57 |
C == Routine arguments == |
58 |
C myTime - Current time in simulation |
59 |
C myIter - Current iteration number in simulation |
60 |
C myThid - Thread number for this instance of the routine. |
61 |
_RL myTime |
62 |
INTEGER myIter |
63 |
INTEGER myThid |
64 |
|
65 |
C !LOCAL VARIABLES: |
66 |
C == Local variables |
67 |
_RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
_RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
69 |
INTEGER iMin,iMax |
70 |
INTEGER jMin,jMax |
71 |
INTEGER bi,bj |
72 |
INTEGER k,i,j |
73 |
|
74 |
CEOP |
75 |
|
76 |
DO bj=myByLo(myThid),myByHi(myThid) |
77 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
78 |
|
79 |
C-- Set up work arrays that need valid initial values |
80 |
DO j=1-OLy,sNy+OLy |
81 |
DO i=1-OLx,sNx+OLx |
82 |
phiSurfX(i,j)=0. |
83 |
phiSurfY(i,j)=0. |
84 |
ENDDO |
85 |
ENDDO |
86 |
|
87 |
C Loop range: Gradients of Eta are evaluated so valid |
88 |
C range is all but first row and column in overlaps. |
89 |
iMin = 1-OLx+1 |
90 |
iMax = sNx+OLx |
91 |
jMin = 1-OLy+1 |
92 |
jMax = sNy+OLy |
93 |
|
94 |
C- Calculate gradient of surface Potentiel |
95 |
CALL CALC_GRAD_PHI_SURF( |
96 |
I bi,bj,iMin,iMax,jMin,jMax, |
97 |
I etaN, |
98 |
O phiSurfX,phiSurfY, |
99 |
I myThid ) |
100 |
|
101 |
C-- Loop over all layers, top to bottom |
102 |
DO K=1,Nr |
103 |
|
104 |
C- Update velocity fields: V(n) = V** - dt * grad Eta |
105 |
IF (momStepping) |
106 |
& CALL CORRECTION_STEP( |
107 |
I bi,bj,iMin,iMax,jMin,jMax,K, |
108 |
I phiSurfX,phiSurfY,myTime,myThid ) |
109 |
|
110 |
C- Update tracer fields: T(n) = T**, Gt(n-1) = Gt(n) |
111 |
IF (tempStepping) |
112 |
& CALL CYCLE_TRACER( |
113 |
I bi,bj,iMin,iMax,jMin,jMax,K, |
114 |
U theta,gT,gTNm1, |
115 |
I myTime,myThid ) |
116 |
IF (saltStepping) |
117 |
& CALL CYCLE_TRACER( |
118 |
I bi,bj,iMin,iMax,jMin,jMax,K, |
119 |
U salt,gS,gSNm1, |
120 |
I myTime,myThid ) |
121 |
#ifdef ALLOW_PASSIVE_TRACER |
122 |
IF (tr1Stepping) |
123 |
& CALL CYCLE_TRACER( |
124 |
I bi,bj,iMin,iMax,jMin,jMax,K, |
125 |
U Tr1,gTr1,gTr1Nm1, |
126 |
I myTime,myThid ) |
127 |
#endif |
128 |
#ifdef ALLOW_PTRACERS |
129 |
C- Update passive tracer fields: T(n) = T**, Gt(n-1) = Gt(n) |
130 |
IF (usePTRACERS) |
131 |
& CALL PTRACERS_CYCLE(bi,bj,k,myIter,myTime,myThid) |
132 |
#endif /* ALLOW_PTRACERS */ |
133 |
|
134 |
|
135 |
#ifdef ALLOW_OBCS |
136 |
IF (useOBCS) THEN |
137 |
CALL OBCS_APPLY_UV(bi,bj,K,uVel,vVel,myThid) |
138 |
ENDIF |
139 |
#endif /* ALLOW_OBCS */ |
140 |
|
141 |
C-- End DO K=1,Nr |
142 |
ENDDO |
143 |
|
144 |
C-- End of 1rst bi,bj loop |
145 |
ENDDO |
146 |
ENDDO |
147 |
|
148 |
C--- 2nd Part : Adjustment. |
149 |
C |
150 |
C Static stability is calculated and the tracers are |
151 |
C convective adjusted where statically unstable. |
152 |
|
153 |
C-- Filter (and exchange) |
154 |
#ifdef ALLOW_SHAP_FILT |
155 |
IF (useSHAP_FILT) THEN |
156 |
IF ( .NOT.shap_filt_uvStar ) |
157 |
& CALL SHAP_FILT_APPLY_UV( uVel, vVel, myTime, myIter, myThid ) |
158 |
|
159 |
IF ( .NOT.(staggerTimeStep .AND. shap_filt_TrStagg) ) |
160 |
& CALL SHAP_FILT_APPLY_TS( theta,salt, myTime, myIter, myThid ) |
161 |
ENDIF |
162 |
#endif |
163 |
#ifdef ALLOW_ZONAL_FILT |
164 |
IF (useZONAL_FILT) THEN |
165 |
IF ( .NOT.zonal_filt_uvStar ) |
166 |
& CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid ) |
167 |
|
168 |
IF ( .NOT.(staggerTimeStep .AND. zonal_filt_TrStagg) ) |
169 |
& CALL ZONAL_FILT_APPLY_TS( theta, salt, myThid ) |
170 |
|
171 |
ENDIF |
172 |
#endif |
173 |
|
174 |
DO bj=myByLo(myThid),myByHi(myThid) |
175 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
176 |
|
177 |
C-- Convectively adjust new fields to be statically stable |
178 |
iMin = 1 |
179 |
iMax = sNx |
180 |
jMin = 1 |
181 |
jMax = sNy |
182 |
CALL CONVECTIVE_ADJUSTMENT( |
183 |
I bi, bj, iMin, iMax, jMin, jMax, |
184 |
I myTime, myIter, myThid ) |
185 |
|
186 |
C-- Integrate continuity vertically |
187 |
C-- for vertical velocity and "etaN" (exact volume conservation) : |
188 |
CALL INTEGR_CONTINUITY( bi, bj, uVel, vVel, |
189 |
I myTime, myIter, myThid ) |
190 |
|
191 |
#ifdef ALLOW_TIMEAVE |
192 |
IF (taveFreq.GT.0.) THEN |
193 |
CALL TIMEAVE_STATVARS(myTime, myIter, bi, bj, myThid) |
194 |
ENDIF |
195 |
#endif /* ALLOW_TIMEAVE */ |
196 |
|
197 |
C-- End of 2nd bi,bj loop |
198 |
ENDDO |
199 |
ENDDO |
200 |
|
201 |
RETURN |
202 |
END |