1 |
C $Header: /u/gcmpack/MITgcm/pkg/gmredi/gmredi_rtransport.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_RTRANSPORT( |
7 |
I iMin,iMax,jMin,jMax,bi,bj,K, |
8 |
I Tracer,tracerIdentity, |
9 |
U df, |
10 |
I myThid) |
11 |
C /==========================================================\ |
12 |
C | o SUBROUTINE GMREDI_RTRANSPORT | |
13 |
C | Add vertical 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 |
_RL Tracer(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
42 |
INTEGER tracerIdentity |
43 |
_RL df (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
44 |
INTEGER myThid |
45 |
|
46 |
#ifdef ALLOW_GMREDI |
47 |
|
48 |
C == Local variables == |
49 |
C I, J - Loop counters |
50 |
INTEGER I, J |
51 |
_RL dTdx (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
52 |
_RL dTdy (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
53 |
#ifdef GM_BOLUS_ADVEC |
54 |
_RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
55 |
#endif |
56 |
|
57 |
#ifdef ALLOW_AUTODIFF_TAMC |
58 |
act0 = tracerIdentity - 1 |
59 |
max0 = maxpass |
60 |
act1 = bi - myBxLo(myThid) |
61 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
62 |
act2 = bj - myByLo(myThid) |
63 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
64 |
act3 = myThid - 1 |
65 |
max3 = nTx*nTy |
66 |
act4 = ikey_dynamics - 1 |
67 |
igadkey = (act0 + 1) |
68 |
& + act1*max0 |
69 |
& + act2*max0*max1 |
70 |
& + act3*max0*max1*max2 |
71 |
& + act4*max0*max1*max2*max3 |
72 |
kkey = (igadkey-1)*Nr + k |
73 |
if (tracerIdentity.GT.maxpass) then |
74 |
print *, 'ph-pass gmredi_rtrans ', maxpass, tracerIdentity |
75 |
STOP 'maxpass seems smaller than tracerIdentity' |
76 |
endif |
77 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
78 |
|
79 |
C Surface flux is zero |
80 |
IF (useGMRedi .AND. K.GT.1) THEN |
81 |
|
82 |
C- Horizontal gradients interpolated to W points |
83 |
DO j=jMin,jMax |
84 |
DO i=iMin,iMax |
85 |
dTdx(i,j) = op5*( |
86 |
& +op5*(_maskW(i+1,j,k,bi,bj) |
87 |
& *_recip_dxC(i+1,j,bi,bj)* |
88 |
& (Tracer(i+1,j,k,bi,bj)-Tracer(i,j,k,bi,bj)) |
89 |
& +_maskW(i,j,k,bi,bj) |
90 |
& *_recip_dxC(i,j,bi,bj)* |
91 |
& (Tracer(i,j,k,bi,bj)-Tracer(i-1,j,k,bi,bj))) |
92 |
& +op5*(_maskW(i+1,j,k-1,bi,bj) |
93 |
& *_recip_dxC(i+1,j,bi,bj)* |
94 |
& (Tracer(i+1,j,k-1,bi,bj)-Tracer(i,j,k-1,bi,bj)) |
95 |
& +_maskW(i,j,k-1,bi,bj) |
96 |
& *_recip_dxC(i,j,bi,bj)* |
97 |
& (Tracer(i,j,k-1,bi,bj)-Tracer(i-1,j,k-1,bi,bj))) |
98 |
& ) |
99 |
|
100 |
dTdy(i,j) = op5*( |
101 |
& +op5*(_maskS(i,j,k,bi,bj) |
102 |
& *_recip_dyC(i,j,bi,bj)* |
103 |
& (Tracer(i,j,k,bi,bj)-Tracer(i,j-1,k,bi,bj)) |
104 |
& +_maskS(i,j+1,k,bi,bj) |
105 |
& *_recip_dyC(i,j+1,bi,bj)* |
106 |
& (Tracer(i,j+1,k,bi,bj)-Tracer(i,j,k,bi,bj))) |
107 |
& +op5*(_maskS(i,j,k-1,bi,bj) |
108 |
& *_recip_dyC(i,j,bi,bj)* |
109 |
& (Tracer(i,j,k-1,bi,bj)-Tracer(i,j-1,k-1,bi,bj)) |
110 |
& +_maskS(i,j+1,k-1,bi,bj) |
111 |
& *_recip_dyC(i,j+1,bi,bj)* |
112 |
& (Tracer(i,j+1,k-1,bi,bj)-Tracer(i,j,k-1,bi,bj))) |
113 |
& ) |
114 |
ENDDO |
115 |
ENDDO |
116 |
|
117 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
118 |
CADJ STORE dTdx(:,:) = |
119 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
120 |
CADJ STORE dTdy(:,:) = |
121 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
122 |
#endif |
123 |
|
124 |
C- Off-diagonal components of vertical flux |
125 |
DO j=jMin,jMax |
126 |
DO i=iMin,iMax |
127 |
df(i,j) = df(i,j) |
128 |
& - _rA(i,j,bi,bj) |
129 |
& *( Kwx(i,j,k,bi,bj)*dTdx(i,j)+Kwy(i,j,k,bi,bj)*dTdy(i,j) ) |
130 |
|
131 |
ENDDO |
132 |
ENDDO |
133 |
|
134 |
#ifdef GM_BOLUS_ADVEC |
135 |
IF (GM_AdvForm .AND. GM_AdvSeparate) THEN |
136 |
DO j=jMin,jMax |
137 |
DO i=iMin,iMax |
138 |
rTrans(i,j) = |
139 |
& dyG(i+1,j,bi,bj)*GM_PsiX(i+1,j,k,bi,bj) |
140 |
& -dyG( i ,j,bi,bj)*GM_PsiX( i ,j,k,bi,bj) |
141 |
& +dxG(i,j+1,bi,bj)*GM_PsiY(i,j+1,k,bi,bj) |
142 |
& -dxG(i, j ,bi,bj)*GM_PsiY(i, j ,k,bi,bj) |
143 |
ENDDO |
144 |
ENDDO |
145 |
#ifdef GM_AUTODIFF_EXCESSIVE_STORE |
146 |
CADJ STORE rtrans(:,:) = |
147 |
CADJ & comlev1_gmredi_k_gad, key=kkey, byte=isbyte |
148 |
#endif |
149 |
DO j=jMin,jMax |
150 |
DO i=iMin,iMax |
151 |
df(i,j) = df(i,j) |
152 |
& +rTrans(i,j)*op5 |
153 |
& *(Tracer(i,j,k,bi,bj)+Tracer(i,j,k-1,bi,bj)) |
154 |
ENDDO |
155 |
ENDDO |
156 |
ENDIF |
157 |
#endif /* GM_BOLUS_ADVEC */ |
158 |
|
159 |
c IF (.NOT.implicitDiffusion) THEN |
160 |
c |
161 |
c This vertical diffusion term is currently implemented |
162 |
c by adding the VisbeckK*Kwz diffusivity to KappaRT/S |
163 |
c See calc_diffusivity.F and calc_gt.F (calc_gs.F) |
164 |
c |
165 |
c DO j=jMin,jMax |
166 |
c DO i=iMin,iMax |
167 |
c df(i,j) = df(i,j) - _rA(i,j,bi,bj) |
168 |
c & *maskUp(i,j)*VisbeckK(i,j,bi,bj)*Kwz(i,j,k,bi,bj) |
169 |
c & *recip_drC(k)*rkfac |
170 |
c & *(Tracer(i,j,k-1,bi,bj)-Tracer(i,j,k,bi,bj)) |
171 |
c ENDDO |
172 |
c ENDDO |
173 |
c ENDIF |
174 |
|
175 |
ENDIF |
176 |
#endif /* ALLOW_GMREDI */ |
177 |
|
178 |
RETURN |
179 |
END |