1 |
C $Header: /u/gcmpack/MITgcm/pkg/gmredi/gmredi_ytransport.F,v 1.13 2003/06/27 01:55:08 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 |
# 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 |
|
61 |
#ifdef ALLOW_AUTODIFF_TAMC |
62 |
act0 = tracerIdentity - 1 |
63 |
max0 = maxpass |
64 |
act1 = bi - myBxLo(myThid) |
65 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
66 |
act2 = bj - myByLo(myThid) |
67 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
68 |
act3 = myThid - 1 |
69 |
max3 = nTx*nTy |
70 |
act4 = ikey_dynamics - 1 |
71 |
igadkey = (act0 + 1) |
72 |
& + act1*max0 |
73 |
& + act2*max0*max1 |
74 |
& + act3*max0*max1*max2 |
75 |
& + act4*max0*max1*max2*max3 |
76 |
kkey = (igadkey-1)*Nr + k |
77 |
if (tracerIdentity.GT.maxpass) then |
78 |
print *, 'ph-pass gmredi_ytrans ', maxpass, tracerIdentity |
79 |
STOP 'maxpass seems smaller than tracerIdentity' |
80 |
endif |
81 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
82 |
|
83 |
IF (useGMRedi) THEN |
84 |
|
85 |
#ifdef ALLOW_AUTODIFF_TAMC |
86 |
# ifdef GM_NON_UNITY_DIAGONAL |
87 |
CADJ STORE Kvy(:,:,k,bi,bj) = |
88 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
89 |
# endif |
90 |
# ifdef GM_EXTRA_DIAGONAL |
91 |
CADJ STORE Kvz(:,:,k,bi,bj) = |
92 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
93 |
# endif |
94 |
#endif |
95 |
|
96 |
C-- Area integrated meridional flux |
97 |
DO j=jMin,jMax |
98 |
DO i=iMin,iMax |
99 |
df(i,j) = df(i,j) |
100 |
& -yA(i,j) |
101 |
#ifdef GM_NON_UNITY_DIAGONAL |
102 |
& *Kvy(i,j,k,bi,bj) |
103 |
#else |
104 |
& *(GM_isopycK |
105 |
#ifdef GM_VISBECK_VARIABLE_K |
106 |
& +op5*(VisbeckK(i,j,bi,bj)+VisbeckK(i,j-1,bi,bj)) |
107 |
#endif |
108 |
& ) |
109 |
#endif /* GM_NON_UNITY_DIAGONAL */ |
110 |
& *_recip_dyC(i,j,bi,bj) |
111 |
& *(Tracer(i,j,k,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
112 |
ENDDO |
113 |
ENDDO |
114 |
|
115 |
#ifdef GM_EXTRA_DIAGONAL |
116 |
IF (GM_ExtraDiag) THEN |
117 |
km1 = MAX(k-1,1) |
118 |
kp1 = MIN(k+1,Nr) |
119 |
|
120 |
DO j=jMin,jMax |
121 |
DO i=iMin,iMax |
122 |
|
123 |
C- Vertical gradients interpolated to V points |
124 |
dTdz(i,j) = op5*( |
125 |
& +op5*recip_drC(k)* |
126 |
& ( maskC(i,j-1,k,bi,bj)* |
127 |
& (Tracer(i,j-1,km1,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
128 |
& +maskC(i, j ,k,bi,bj)* |
129 |
& (Tracer(i, j ,km1,bi,bj)-Tracer(i, j ,k,bi,bj)) |
130 |
& ) |
131 |
& +op5*recip_drC(kp1)* |
132 |
& ( maskC(i,j-1,kp1,bi,bj)* |
133 |
& (Tracer(i,j-1,k,bi,bj)-Tracer(i,j-1,kp1,bi,bj)) |
134 |
& +maskC(i, j ,kp1,bi,bj)* |
135 |
& (Tracer(i, j ,k,bi,bj)-Tracer(i, j ,kp1,bi,bj)) |
136 |
& ) ) |
137 |
ENDDO |
138 |
ENDDO |
139 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
140 |
CADJ STORE dtdz(:,:) = |
141 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
142 |
#endif |
143 |
DO j=jMin,jMax |
144 |
DO i=iMin,iMax |
145 |
C- Off-diagonal components of horizontal flux |
146 |
df(i,j) = df(i,j) - yA(i,j)*Kvz(i,j,k,bi,bj)*dTdz(i,j) |
147 |
|
148 |
ENDDO |
149 |
ENDDO |
150 |
ENDIF |
151 |
#endif /* GM_EXTRA_DIAGONAL */ |
152 |
|
153 |
#ifdef GM_BOLUS_ADVEC |
154 |
IF (GM_AdvForm .AND. GM_AdvSeparate) THEN |
155 |
kp1 = MIN(k+1,Nr) |
156 |
maskp1 = 1. |
157 |
IF (k.GE.Nr) maskp1 = 0. |
158 |
DO j=jMin,jMax |
159 |
DO i=iMin,iMax |
160 |
vTrans(i,j) = dxG(i,j,bi,bj)*( GM_PsiY(i,j,kp1,bi,bj)*maskp1 |
161 |
& -GM_PsiY(i,j,k,bi,bj) ) |
162 |
& *maskS(i,j,k,bi,bj) |
163 |
ENDDO |
164 |
ENDDO |
165 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
166 |
CADJ STORE vtrans(:,:) = |
167 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
168 |
#endif |
169 |
DO j=jMin,jMax |
170 |
DO i=iMin,iMax |
171 |
df(i,j) = df(i,j) |
172 |
& +vTrans(i,j)*op5*(Tracer(i,j,k,bi,bj)+Tracer(i,j-1,k,bi,bj)) |
173 |
ENDDO |
174 |
ENDDO |
175 |
ENDIF |
176 |
#endif /* GM_BOLUS_ADVEC */ |
177 |
|
178 |
ENDIF |
179 |
#endif /* ALLOW_GMREDI */ |
180 |
|
181 |
RETURN |
182 |
END |