1 |
C $Header: /u/gcmpack/MITgcm/pkg/gmredi/gmredi_ytransport.F,v 1.12 2003/01/21 19:34:13 heimbach 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 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
30 |
|
31 |
C == Routine arguments == |
32 |
C iMin,iMax,jMin, - Range of points for which calculation |
33 |
C jMax,bi,bj,k results will be set. |
34 |
C xA - Area of X face |
35 |
C Tracer - 3D Tracer field |
36 |
C df - Diffusive flux component work array. |
37 |
INTEGER iMin,iMax,jMin,jMax,bi,bj,k |
38 |
_RS yA(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
39 |
_RL Tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
40 |
integer tracerIdentity |
41 |
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
42 |
INTEGER myThid |
43 |
|
44 |
#ifdef ALLOW_GMREDI |
45 |
|
46 |
C == Local variables == |
47 |
C I, J - Loop counters |
48 |
INTEGER I, J |
49 |
INTEGER km1,kp1 |
50 |
_RL maskp1 |
51 |
#ifdef GM_EXTRA_DIAGONAL |
52 |
_RL dTdz(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
53 |
#endif |
54 |
#ifdef GM_BOLUS_ADVEC |
55 |
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
56 |
#endif |
57 |
|
58 |
#ifdef ALLOW_AUTODIFF_TAMC |
59 |
act0 = tracerIdentity - 1 |
60 |
max0 = maxpass |
61 |
act1 = bi - myBxLo(myThid) |
62 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
63 |
act2 = bj - myByLo(myThid) |
64 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
65 |
act3 = myThid - 1 |
66 |
max3 = nTx*nTy |
67 |
act4 = ikey_dynamics - 1 |
68 |
igadkey = (act0 + 1) |
69 |
& + act1*max0 |
70 |
& + act2*max0*max1 |
71 |
& + act3*max0*max1*max2 |
72 |
& + act4*max0*max1*max2*max3 |
73 |
kkey = (igadkey-1)*Nr + k |
74 |
if (tracerIdentity.GT.maxpass) then |
75 |
print *, 'ph-pass gmredi_ytrans ', maxpass, tracerIdentity |
76 |
STOP 'maxpass seems smaller than tracerIdentity' |
77 |
endif |
78 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
79 |
|
80 |
IF (useGMRedi) THEN |
81 |
|
82 |
#ifdef ALLOW_AUTODIFF_TAMC |
83 |
# ifdef GM_NON_UNITY_DIAGONAL |
84 |
CADJ STORE Kvy(:,:,k,bi,bj) = |
85 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
86 |
# endif |
87 |
# ifdef GM_EXTRA_DIAGONAL |
88 |
CADJ STORE Kvz(:,:,k,bi,bj) = |
89 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
90 |
# endif |
91 |
#endif |
92 |
|
93 |
C-- Area integrated meridional flux |
94 |
DO j=jMin,jMax |
95 |
DO i=iMin,iMax |
96 |
df(i,j) = df(i,j) |
97 |
& -yA(i,j) |
98 |
#ifdef GM_NON_UNITY_DIAGONAL |
99 |
& *Kvy(i,j,k,bi,bj) |
100 |
#else |
101 |
& *(GM_isopycK |
102 |
#ifdef GM_VISBECK_VARIABLE_K |
103 |
& +op5*(VisbeckK(i,j,bi,bj)+VisbeckK(i,j-1,bi,bj)) |
104 |
#endif |
105 |
& ) |
106 |
#endif /* GM_NON_UNITY_DIAGONAL */ |
107 |
& *_recip_dyC(i,j,bi,bj) |
108 |
& *(Tracer(i,j,k,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
109 |
ENDDO |
110 |
ENDDO |
111 |
|
112 |
#ifdef GM_EXTRA_DIAGONAL |
113 |
IF (GM_ExtraDiag) THEN |
114 |
km1 = MAX(k-1,1) |
115 |
kp1 = MIN(k+1,Nr) |
116 |
|
117 |
DO j=jMin,jMax |
118 |
DO i=iMin,iMax |
119 |
|
120 |
C- Vertical gradients interpolated to V points |
121 |
dTdz(i,j) = op5*( |
122 |
& +op5*recip_drC(k)* |
123 |
& ( maskC(i,j-1,k,bi,bj)* |
124 |
& (Tracer(i,j-1,km1,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
125 |
& +maskC(i, j ,k,bi,bj)* |
126 |
& (Tracer(i, j ,km1,bi,bj)-Tracer(i, j ,k,bi,bj)) |
127 |
& ) |
128 |
& +op5*recip_drC(kp1)* |
129 |
& ( maskC(i,j-1,kp1,bi,bj)* |
130 |
& (Tracer(i,j-1,k,bi,bj)-Tracer(i,j-1,kp1,bi,bj)) |
131 |
& +maskC(i, j ,kp1,bi,bj)* |
132 |
& (Tracer(i, j ,k,bi,bj)-Tracer(i, j ,kp1,bi,bj)) |
133 |
& ) ) |
134 |
ENDDO |
135 |
ENDDO |
136 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
137 |
CADJ STORE dtdz(:,:) = |
138 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
139 |
#endif |
140 |
DO j=jMin,jMax |
141 |
DO i=iMin,iMax |
142 |
C- Off-diagonal components of horizontal flux |
143 |
df(i,j) = df(i,j) - yA(i,j)*Kvz(i,j,k,bi,bj)*dTdz(i,j) |
144 |
|
145 |
ENDDO |
146 |
ENDDO |
147 |
ENDIF |
148 |
#endif /* GM_EXTRA_DIAGONAL */ |
149 |
|
150 |
#ifdef GM_BOLUS_ADVEC |
151 |
IF (GM_AdvForm .AND. GM_AdvSeparate) THEN |
152 |
kp1 = MIN(k+1,Nr) |
153 |
maskp1 = 1. |
154 |
IF (k.GE.Nr) maskp1 = 0. |
155 |
DO j=jMin,jMax |
156 |
DO i=iMin,iMax |
157 |
vTrans(i,j) = dxG(i,j,bi,bj)*( GM_PsiY(i,j,kp1,bi,bj)*maskp1 |
158 |
& -GM_PsiY(i,j,k,bi,bj) ) |
159 |
& *maskS(i,j,k,bi,bj) |
160 |
ENDDO |
161 |
ENDDO |
162 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
163 |
CADJ STORE vtrans(:,:) = |
164 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
165 |
#endif |
166 |
DO j=jMin,jMax |
167 |
DO i=iMin,iMax |
168 |
df(i,j) = df(i,j) |
169 |
& +vTrans(i,j)*op5*(Tracer(i,j,k,bi,bj)+Tracer(i,j-1,k,bi,bj)) |
170 |
ENDDO |
171 |
ENDDO |
172 |
ENDIF |
173 |
#endif /* GM_BOLUS_ADVEC */ |
174 |
|
175 |
ENDIF |
176 |
#endif /* ALLOW_GMREDI */ |
177 |
|
178 |
RETURN |
179 |
END |