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