1 |
C $Header: /u/gcmpack/MITgcm/model/src/momentum_correction_step.F,v 1.8 2010/10/25 23:02:35 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: MOMENTUM_CORRECTION_STEP |
9 |
C !INTERFACE: |
10 |
SUBROUTINE MOMENTUM_CORRECTION_STEP(myTime, myIter, myThid) |
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE MOMENTUM_CORRECTION_STEP |
14 |
C *==========================================================* |
15 |
C |1rst Part : Update U,V. |
16 |
C | |
17 |
C | The arrays used for time stepping are cycled. |
18 |
C | Momentum: |
19 |
C | V(n) = Gv(n) - dt * grad Eta |
20 |
C | |
21 |
C |part1: update U,V |
22 |
C | U*,V* (contained in gU,gV) have the surface |
23 |
C | pressure gradient term added and the result stored |
24 |
C | in U,V (contained in uVel, vVel) |
25 |
C | |
26 |
C |part2: Adjustments |
27 |
C | o Filter U,V (Shapiro Filter, Zonal_Filter) |
28 |
C | o Compute again Eta (exact volume conservation) |
29 |
C | o Compute vertical velocity |
30 |
C *==========================================================* |
31 |
C \ev |
32 |
|
33 |
C !USES: |
34 |
IMPLICIT NONE |
35 |
C == Global variables === |
36 |
#include "SIZE.h" |
37 |
#include "EEPARAMS.h" |
38 |
#include "PARAMS.h" |
39 |
#include "DYNVARS.h" |
40 |
|
41 |
#ifdef ALLOW_SHAP_FILT |
42 |
#include "SHAP_FILT.h" |
43 |
#endif |
44 |
#ifdef ALLOW_ZONAL_FILT |
45 |
#include "ZONAL_FILT.h" |
46 |
#endif |
47 |
#ifdef ALLOW_AUTODIFF_TAMC |
48 |
#include "tamc.h" |
49 |
#include "tamc_keys.h" |
50 |
# ifdef NONLIN_FRSURF |
51 |
# include "SURFACE.h" |
52 |
# endif |
53 |
#endif |
54 |
|
55 |
C !INPUT/OUTPUT PARAMETERS: |
56 |
C == Routine arguments == |
57 |
C myTime :: Current time in simulation |
58 |
C myIter :: Current iteration number in simulation |
59 |
C myThid :: Thread number for this instance of the routine. |
60 |
_RL myTime |
61 |
INTEGER myIter |
62 |
INTEGER myThid |
63 |
|
64 |
C !LOCAL VARIABLES: |
65 |
C == Local variables |
66 |
_RL phiSurfX(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
67 |
_RL phiSurfY(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
INTEGER iMin,iMax |
69 |
INTEGER jMin,jMax |
70 |
INTEGER bi,bj |
71 |
INTEGER k,i,j |
72 |
CEOP |
73 |
|
74 |
DO bj=myByLo(myThid),myByHi(myThid) |
75 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
76 |
|
77 |
C-- Set up work arrays that need valid initial values |
78 |
DO j=1-OLy,sNy+OLy |
79 |
DO i=1-OLx,sNx+OLx |
80 |
phiSurfX(i,j)=0. |
81 |
phiSurfY(i,j)=0. |
82 |
ENDDO |
83 |
ENDDO |
84 |
|
85 |
C Loop range: Gradients of Eta are evaluated so valid |
86 |
C range is all but first row and column in overlaps. |
87 |
iMin = 1-OLx+1 |
88 |
iMax = sNx+OLx |
89 |
jMin = 1-OLy+1 |
90 |
jMax = sNy+OLy |
91 |
|
92 |
C- Calculate gradient of surface Potentiel |
93 |
CALL CALC_GRAD_PHI_SURF( |
94 |
I bi,bj,iMin,iMax,jMin,jMax, |
95 |
I etaN, |
96 |
O phiSurfX,phiSurfY, |
97 |
I myThid ) |
98 |
|
99 |
IF (momStepping) THEN |
100 |
C-- Loop over all layers, top to bottom |
101 |
DO k=1,Nr |
102 |
C- Update velocity fields: V(n) = V** - dt * grad Eta |
103 |
CALL CORRECTION_STEP( |
104 |
I bi,bj,iMin,iMax,jMin,jMax,k, |
105 |
I phiSurfX,phiSurfY,myTime,myThid ) |
106 |
ENDDO |
107 |
ENDIF |
108 |
|
109 |
#ifdef ALLOW_OBCS |
110 |
IF (useOBCS) THEN |
111 |
CALL OBCS_APPLY_UV( bi, bj, 0, uVel, vVel, myThid ) |
112 |
ENDIF |
113 |
#endif /* ALLOW_OBCS */ |
114 |
|
115 |
C-- End of 1rst bi,bj loop |
116 |
ENDDO |
117 |
ENDDO |
118 |
|
119 |
C--- 2nd Part : Adjustment. |
120 |
|
121 |
C-- Filter (and exchange) |
122 |
#ifdef ALLOW_SHAP_FILT |
123 |
IF (useSHAP_FILT) THEN |
124 |
IF ( .NOT.shap_filt_uvStar ) THEN |
125 |
CALL TIMER_START('SHAP_FILT_UV [MOM_CORR_STEP]',myThid) |
126 |
CALL SHAP_FILT_APPLY_UV( uVel, vVel, myTime, myIter, myThid ) |
127 |
CALL TIMER_STOP ('SHAP_FILT_UV [MOM_CORR_STEP]',myThid) |
128 |
ENDIF |
129 |
ENDIF |
130 |
#endif |
131 |
#ifdef ALLOW_ZONAL_FILT |
132 |
IF (useZONAL_FILT) THEN |
133 |
IF ( .NOT.zonal_filt_uvStar ) THEN |
134 |
CALL TIMER_START('ZONAL_FILT_UV [MOM_CORR_STEP]',myThid) |
135 |
CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid ) |
136 |
CALL TIMER_STOP ('ZONAL_FILT_UV [MOM_CORR_STEP]',myThid) |
137 |
ENDIF |
138 |
ENDIF |
139 |
#endif |
140 |
|
141 |
#ifdef ALLOW_AUTODIFF_TAMC |
142 |
# ifdef NONLIN_FRSURF |
143 |
CADJ STORE uvel, vvel = comlev1, key = ikey_dynamics, byte = isbyte |
144 |
# endif |
145 |
#endif |
146 |
DO bj=myByLo(myThid),myByHi(myThid) |
147 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
148 |
|
149 |
#ifdef ALLOW_AUTODIFF_TAMC |
150 |
act1 = bi - myBxLo(myThid) |
151 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
152 |
act2 = bj - myByLo(myThid) |
153 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
154 |
act3 = myThid - 1 |
155 |
max3 = nTx*nTy |
156 |
act4 = ikey_dynamics - 1 |
157 |
idynkey = (act1 + 1) + act2*max1 |
158 |
& + act3*max1*max2 |
159 |
& + act4*max1*max2*max3 |
160 |
# ifdef NONLIN_FRSURF |
161 |
# ifndef DISABLE_RSTAR_CODE |
162 |
CADJ STORE detahdt(:,:,bi,bj) = comlev1_bibj, key = idynkey, byte = isbyte |
163 |
CADJ STORE etan(:,:,bi,bj) = comlev1_bibj, key = idynkey, byte = isbyte |
164 |
# endif |
165 |
# endif |
166 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
167 |
C-- Integrate continuity vertically |
168 |
C-- for vertical velocity and "etaN" (exact volume conservation) : |
169 |
CALL INTEGR_CONTINUITY( bi, bj, uVel, vVel, |
170 |
I myTime, myIter, myThid ) |
171 |
|
172 |
C-- End of 2nd bi,bj loop |
173 |
ENDDO |
174 |
ENDDO |
175 |
|
176 |
IF ( exactConserv .AND. implicDiv2Dflow .NE. 0. _d 0) |
177 |
& _EXCH_XY_RL( etaN , myThid ) |
178 |
IF ( implicitIntGravWave ) |
179 |
& _EXCH_XYZ_RL( wVel , myThid ) |
180 |
|
181 |
RETURN |
182 |
END |