1 |
C $Header: /u/gcmpack/MITgcm/pkg/gmredi/gmredi_ytransport.F,v 1.16 2008/02/02 02:35:53 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "GMREDI_OPTIONS.h" |
5 |
|
6 |
subroutine GMREDI_YTRANSPORT( |
7 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
8 |
I yA,Tracer,tracerIdentity, |
9 |
U df, |
10 |
I myThid) |
11 |
C /==========================================================\ |
12 |
C | o SUBROUTINE GMREDI_YTRANSPORT | |
13 |
C | Add horizontal y transport terms from GM/Redi | |
14 |
C | parameterization. | |
15 |
C |==========================================================| |
16 |
C \==========================================================/ |
17 |
IMPLICIT NONE |
18 |
|
19 |
C == GLobal variables == |
20 |
#include "SIZE.h" |
21 |
#include "EEPARAMS.h" |
22 |
#include "PARAMS.h" |
23 |
#include "GRID.h" |
24 |
#include "GMREDI.h" |
25 |
|
26 |
#ifdef ALLOW_AUTODIFF_TAMC |
27 |
# include "tamc.h" |
28 |
# include "tamc_keys.h" |
29 |
# ifdef ALLOW_PTRACERS |
30 |
# include "PTRACERS_SIZE.h" |
31 |
# endif |
32 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
33 |
|
34 |
C == Routine arguments == |
35 |
C iMin,iMax,jMin, - Range of points for which calculation |
36 |
C jMax,bi,bj,k results will be set. |
37 |
C xA - Area of X face |
38 |
C Tracer - 3D Tracer field |
39 |
C df - Diffusive flux component work array. |
40 |
INTEGER iMin,iMax,jMin,jMax,bi,bj,k |
41 |
_RS yA(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
42 |
_RL Tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
43 |
integer tracerIdentity |
44 |
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
45 |
INTEGER myThid |
46 |
|
47 |
#ifdef ALLOW_GMREDI |
48 |
|
49 |
C == Local variables == |
50 |
C I, J - Loop counters |
51 |
INTEGER I, J |
52 |
INTEGER km1,kp1 |
53 |
_RL maskp1 |
54 |
#ifdef GM_EXTRA_DIAGONAL |
55 |
_RL dTdz(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
56 |
#endif |
57 |
#ifdef GM_BOLUS_ADVEC |
58 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
59 |
#endif |
60 |
#ifdef ALLOW_DIAGNOSTICS |
61 |
LOGICAL DIAGNOSTICS_IS_ON |
62 |
EXTERNAL DIAGNOSTICS_IS_ON |
63 |
_RL tmp1k(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
64 |
#endif |
65 |
|
66 |
#ifdef ALLOW_AUTODIFF_TAMC |
67 |
act0 = tracerIdentity - 1 |
68 |
max0 = maxpass |
69 |
act1 = bi - myBxLo(myThid) |
70 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
71 |
act2 = bj - myByLo(myThid) |
72 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
73 |
act3 = myThid - 1 |
74 |
max3 = nTx*nTy |
75 |
act4 = ikey_dynamics - 1 |
76 |
igadkey = (act0 + 1) |
77 |
& + act1*max0 |
78 |
& + act2*max0*max1 |
79 |
& + act3*max0*max1*max2 |
80 |
& + act4*max0*max1*max2*max3 |
81 |
kkey = (igadkey-1)*Nr + k |
82 |
if (tracerIdentity.GT.maxpass) then |
83 |
print *, 'ph-pass gmredi_ytrans ', maxpass, tracerIdentity |
84 |
STOP 'maxpass seems smaller than tracerIdentity' |
85 |
endif |
86 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
87 |
|
88 |
IF (useGMRedi) THEN |
89 |
|
90 |
#ifdef ALLOW_AUTODIFF_TAMC |
91 |
# ifdef GM_NON_UNITY_DIAGONAL |
92 |
CADJ STORE Kvy(:,:,k,bi,bj) = |
93 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
94 |
# endif |
95 |
# ifdef GM_EXTRA_DIAGONAL |
96 |
CADJ STORE Kvz(:,:,k,bi,bj) = |
97 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
98 |
# endif |
99 |
#endif |
100 |
|
101 |
C-- Area integrated meridional flux |
102 |
DO j=jMin,jMax |
103 |
DO i=iMin,iMax |
104 |
df(i,j) = df(i,j) |
105 |
& -yA(i,j) |
106 |
#ifdef GM_NON_UNITY_DIAGONAL |
107 |
& *Kvy(i,j,k,bi,bj) |
108 |
#else |
109 |
#ifdef ALLOW_KAPREDI_CONTROL |
110 |
& *(kapredi(i,j,k,bi,bj) |
111 |
#else |
112 |
& *(GM_isopycK |
113 |
#endif |
114 |
#ifdef GM_VISBECK_VARIABLE_K |
115 |
& +op5*(VisbeckK(i,j,bi,bj)+VisbeckK(i,j-1,bi,bj)) |
116 |
#endif |
117 |
& ) |
118 |
#endif /* GM_NON_UNITY_DIAGONAL */ |
119 |
& *_recip_dyC(i,j,bi,bj) |
120 |
& *(Tracer(i,j,k,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
121 |
ENDDO |
122 |
ENDDO |
123 |
|
124 |
#ifdef GM_EXTRA_DIAGONAL |
125 |
IF (GM_ExtraDiag) THEN |
126 |
km1 = MAX(k-1,1) |
127 |
kp1 = MIN(k+1,Nr) |
128 |
|
129 |
DO j=jMin,jMax |
130 |
DO i=iMin,iMax |
131 |
|
132 |
C- Vertical gradients interpolated to V points |
133 |
dTdz(i,j) = op5*( |
134 |
& +op5*recip_drC(k)* |
135 |
& ( maskC(i,j-1,k,bi,bj)* |
136 |
& (Tracer(i,j-1,km1,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
137 |
& +maskC(i, j ,k,bi,bj)* |
138 |
& (Tracer(i, j ,km1,bi,bj)-Tracer(i, j ,k,bi,bj)) |
139 |
& ) |
140 |
& +op5*recip_drC(kp1)* |
141 |
& ( maskC(i,j-1,kp1,bi,bj)* |
142 |
& (Tracer(i,j-1,k,bi,bj)-Tracer(i,j-1,kp1,bi,bj)) |
143 |
& +maskC(i, j ,kp1,bi,bj)* |
144 |
& (Tracer(i, j ,k,bi,bj)-Tracer(i, j ,kp1,bi,bj)) |
145 |
& ) ) |
146 |
ENDDO |
147 |
ENDDO |
148 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
149 |
CADJ STORE dtdz(:,:) = |
150 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
151 |
#endif |
152 |
DO j=jMin,jMax |
153 |
DO i=iMin,iMax |
154 |
C- Off-diagonal components of horizontal flux |
155 |
df(i,j) = df(i,j) - yA(i,j)*Kvz(i,j,k,bi,bj)*dTdz(i,j) |
156 |
|
157 |
ENDDO |
158 |
ENDDO |
159 |
ENDIF |
160 |
#endif /* GM_EXTRA_DIAGONAL */ |
161 |
|
162 |
#ifdef GM_BOLUS_ADVEC |
163 |
IF (GM_AdvForm .AND. GM_AdvSeparate |
164 |
& .AND. .NOT.GM_InMomAsStress) THEN |
165 |
kp1 = MIN(k+1,Nr) |
166 |
maskp1 = 1. |
167 |
IF (k.GE.Nr) maskp1 = 0. |
168 |
DO j=jMin,jMax |
169 |
DO i=iMin,iMax |
170 |
vTrans(i,j) = dxG(i,j,bi,bj)*( GM_PsiY(i,j,kp1,bi,bj)*maskp1 |
171 |
& -GM_PsiY(i,j,k,bi,bj) ) |
172 |
& *maskS(i,j,k,bi,bj) |
173 |
ENDDO |
174 |
ENDDO |
175 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
176 |
CADJ STORE vtrans(:,:) = |
177 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
178 |
#endif |
179 |
DO j=jMin,jMax |
180 |
DO i=iMin,iMax |
181 |
df(i,j) = df(i,j) |
182 |
& +vTrans(i,j)*op5*(Tracer(i,j,k,bi,bj)+Tracer(i,j-1,k,bi,bj)) |
183 |
ENDDO |
184 |
ENDDO |
185 |
ENDIF |
186 |
|
187 |
#ifdef ALLOW_DIAGNOSTICS |
188 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
189 |
IF ( useDiagnostics |
190 |
& .AND. DIAGNOSTICS_IS_ON('GM_vbT ', myThid ) |
191 |
& .AND. tracerIdentity .EQ. 1) THEN |
192 |
kp1 = MIN(k+1,Nr) |
193 |
maskp1 = 1. |
194 |
IF (k.GE.Nr) maskp1 = 0. |
195 |
DO j=jMin,jMax |
196 |
DO i=iMin,iMax |
197 |
tmp1k(i,j) = dxG(i,j,bi,bj)*( GM_PsiY(i,j,kp1,bi,bj)*maskp1 |
198 |
& -GM_PsiY(i,j,k,bi,bj) ) |
199 |
& *maskS(i,j,k,bi,bj) |
200 |
& *op5*(Tracer(i,j,k,bi,bj)+Tracer(i,j-1,k,bi,bj)) |
201 |
ENDDO |
202 |
ENDDO |
203 |
CALL DIAGNOSTICS_FILL(tmp1k,'GM_vbT ', k,1,2,bi,bj,myThid) |
204 |
|
205 |
ENDIF |
206 |
#endif /* ALLOW_DIAGNOSTICS */ |
207 |
|
208 |
#endif /* GM_BOLUS_ADVEC */ |
209 |
|
210 |
ENDIF |
211 |
#endif /* ALLOW_GMREDI */ |
212 |
|
213 |
RETURN |
214 |
END |