1 |
C $Header: /u/gcmpack/MITgcm/pkg/gmredi/gmredi_calc_psi_b.F,v 1.1 2001/12/16 18:54:49 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "GMREDI_OPTIONS.h" |
5 |
|
6 |
CStartOfInterface |
7 |
SUBROUTINE GMREDI_CALC_PSI_B( |
8 |
I bi, bj, iMin, iMax, jMin, jMax, |
9 |
I sigmaX, sigmaY, sigmaR, |
10 |
I myThid ) |
11 |
C /==========================================================\ |
12 |
C | SUBROUTINE GMREDI_CALC_PSI_B | |
13 |
C | o Calculate stream-functions for GM bolus velocity | |
14 |
C |==========================================================| |
15 |
C \==========================================================/ |
16 |
IMPLICIT NONE |
17 |
|
18 |
C == Global variables == |
19 |
#include "SIZE.h" |
20 |
#include "GRID.h" |
21 |
#include "DYNVARS.h" |
22 |
#include "EEPARAMS.h" |
23 |
#include "PARAMS.h" |
24 |
#include "GMREDI.h" |
25 |
#include "GMREDI_DIAGS.h" |
26 |
|
27 |
#ifdef ALLOW_AUTODIFF_TAMC |
28 |
#include "tamc.h" |
29 |
#include "tamc_keys.h" |
30 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
31 |
|
32 |
C == Routine arguments == |
33 |
C |
34 |
_RL sigmaX(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
35 |
_RL sigmaY(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
36 |
_RL sigmaR(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
37 |
INTEGER bi,bj,iMin,iMax,jMin,jMax |
38 |
INTEGER myThid |
39 |
CEndOfInterface |
40 |
|
41 |
#ifdef ALLOW_GMREDI |
42 |
#ifdef GM_BOLUS_ADVEC |
43 |
|
44 |
C == Local variables == |
45 |
INTEGER i,j,k, km1 |
46 |
_RL SlopeX(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
47 |
_RL SlopeY(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
48 |
_RL dSigmaDrW(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
49 |
_RL dSigmaDrS(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
50 |
_RL taperX(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
51 |
_RL taperY(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
52 |
|
53 |
C- Initialization : <= done in S/R gmredi_init |
54 |
|
55 |
#ifdef ALLOW_AUTODIFF_TAMC |
56 |
act1 = bi - myBxLo(myThid) |
57 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
58 |
act2 = bj - myByLo(myThid) |
59 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
60 |
act3 = myThid - 1 |
61 |
max3 = nTx*nTy |
62 |
act4 = ikey_dynamics - 1 |
63 |
ikey = (act1 + 1) + act2*max1 |
64 |
& + act3*max1*max2 |
65 |
& + act4*max1*max2*max3 |
66 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
67 |
|
68 |
IF (GM_AdvForm) THEN |
69 |
DO k=2,Nr |
70 |
km1 = k-1 |
71 |
|
72 |
#ifdef ALLOW_AUTODIFF_TAMC |
73 |
kkey = (ikey-1)*Nr + k |
74 |
DO j=1-Oly,sNy+Oly |
75 |
DO i=1-Olx,sNx+Olx |
76 |
SlopeX(i,j) = 0. _d 0 |
77 |
SlopeY(i,j) = 0. _d 0 |
78 |
dSigmaDrW(i,j) = 0. _d 0 |
79 |
dSigmaDrS(i,j) = 0. _d 0 |
80 |
ENDDO |
81 |
ENDDO |
82 |
#endif |
83 |
|
84 |
DO j=1-Oly+1,sNy+Oly-1 |
85 |
DO i=1-Olx+1,sNx+Olx-1 |
86 |
|
87 |
C Gradient of Sigma below U and V points |
88 |
SlopeX(i,j)=0.5*( sigmaX(i,j,km1)+sigmaX(i,j,k) ) |
89 |
& *maskW(i,j,k,bi,bj) |
90 |
dSigmaDrW(i,j)=0.5*( sigmaR(i-1,j,k)+sigmaR(i,j,k) ) |
91 |
& *maskW(i,j,k,bi,bj) |
92 |
SlopeY(i,j)=0.5*( sigmaY(i,j,km1)+sigmaY(i,j,k) ) |
93 |
& *maskS(i,j,k,bi,bj) |
94 |
dSigmaDrS(i,j)=0.5*( sigmaR(i,j-1,k)+sigmaR(i,j,k) ) |
95 |
& *maskS(i,j,k,bi,bj) |
96 |
|
97 |
ENDDO |
98 |
ENDDO |
99 |
|
100 |
C Calculate slopes , taper and/or clip |
101 |
CALL GMREDI_SLOPE_PSI_B( |
102 |
I dSigmaDrW, dSigmaDrS, |
103 |
I rF(K),K, |
104 |
U SlopeX, SlopeY, |
105 |
O taperX, taperY, |
106 |
I bi, bj, myThid ) |
107 |
|
108 |
#ifdef ALLOW_AUTODIFF_TAMC |
109 |
CADJ STORE SlopeX(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
110 |
CADJ STORE SlopeY(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
111 |
CADJ STORE taperX(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
112 |
CADJ STORE taperY(:,:) = comlev1_bibj_k, key=kkey, byte=isbyte |
113 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
114 |
|
115 |
DO j=1-Oly+1,sNy+Oly-1 |
116 |
DO i=1-Olx+1,sNx+Olx-1 |
117 |
|
118 |
C- Compute the 2 stream-function Components ( GM bolus vel.) |
119 |
GM_PsiX(i,j,k,bi,bj) = SlopeX(i,j)*taperX(i,j) |
120 |
& *( GM_background_K |
121 |
#ifdef GM_VISBECK_VARIABLE_K |
122 |
& +0.5*(VisbeckK(i-1,j,bi,bj)+VisbeckK(i,j,bi,bj)) |
123 |
#endif |
124 |
& )*maskW(i,j,k,bi,bj) |
125 |
GM_PsiY(i,j,k,bi,bj) = SlopeY(i,j)*taperY(i,j) |
126 |
& *( GM_background_K |
127 |
#ifdef GM_VISBECK_VARIABLE_K |
128 |
& +0.5*(VisbeckK(i,j-1,bi,bj)+VisbeckK(i,j,bi,bj)) |
129 |
#endif |
130 |
& )*maskS(i,j,k,bi,bj) |
131 |
|
132 |
#ifdef ALLOW_TIMEAVE |
133 |
C-- Time-average |
134 |
GM_PsiXtave(i,j,k,bi,bj)=GM_PsiXtave(i,j,k,bi,bj) |
135 |
& +GM_PsiX(i,j,k,bi,bj)*deltaTclock |
136 |
GM_PsiYtave(i,j,k,bi,bj)=GM_PsiYtave(i,j,k,bi,bj) |
137 |
& +GM_PsiY(i,j,k,bi,bj)*deltaTclock |
138 |
#endif /* ALLOW_TIMEAVE */ |
139 |
|
140 |
ENDDO |
141 |
ENDDO |
142 |
|
143 |
C----- |
144 |
ENDDO |
145 |
ENDIF |
146 |
#endif /* GM_BOLUS_ADVEC */ |
147 |
#endif /* ALLOW_GMREDI */ |
148 |
|
149 |
RETURN |
150 |
END |