/[MITgcm]/MITgcm/model/src/calc_gs.F
ViewVC logotype

Contents of /MITgcm/model/src/calc_gs.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.43 - (show annotations) (download)
Sun Feb 26 01:57:24 2006 UTC (18 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.42: +12 -4 lines
try to fix adjoint Pb (duplicated input argument in GAD_CALC_RHS call)

1 C $Header: /u/gcmpack/MITgcm/model/src/calc_gs.F,v 1.42 2005/12/08 15:44:33 heimbach Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6
7 CBOP
8 C !ROUTINE: CALC_GS
9 C !INTERFACE:
10 SUBROUTINE CALC_GS(
11 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
12 I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
13 I KappaRS,
14 U fVerS,
15 I myTime,myIter,myThid )
16 C !DESCRIPTION: \bv
17 C *==========================================================*
18 C | SUBROUTINE CALC_GS
19 C | o Calculate the salt tendency terms.
20 C *==========================================================*
21 C | A procedure called EXTERNAL_FORCING_S is called from
22 C | here. These procedures can be used to add per problem
23 C | E-P flux source terms.
24 C | Note: Although it is slightly counter-intuitive the
25 C | EXTERNAL_FORCING routine is not the place to put
26 C | file I/O. Instead files that are required to
27 C | calculate the external source terms are generally
28 C | read during the model main loop. This makes the
29 C | logisitics of multi-processing simpler and also
30 C | makes the adjoint generation simpler. It also
31 C | allows for I/O to overlap computation where that
32 C | is supported by hardware.
33 C | Aside from the problem specific term the code here
34 C | forms the tendency terms due to advection and mixing
35 C | The baseline implementation here uses a centered
36 C | difference form for the advection term and a tensorial
37 C | divergence of a flux form for the diffusive term. The
38 C | diffusive term is formulated so that isopycnal mixing and
39 C | GM-style subgrid-scale terms can be incorporated b simply
40 C | setting the diffusion tensor terms appropriately.
41 C *==========================================================*
42 C \ev
43
44 C !USES:
45 IMPLICIT NONE
46 C == GLobal variables ==
47 #include "SIZE.h"
48 #include "DYNVARS.h"
49 #include "EEPARAMS.h"
50 #include "PARAMS.h"
51 #ifdef ALLOW_GENERIC_ADVDIFF
52 #include "GAD.h"
53 #endif
54 #ifdef ALLOW_AUTODIFF_TAMC
55 # include "tamc.h"
56 # include "tamc_keys.h"
57 #endif
58
59 C !INPUT/OUTPUT PARAMETERS:
60 C == Routine arguments ==
61 C fVerS :: Flux of salt (S) in the vertical
62 C direction at the upper(U) and lower(D) faces of a cell.
63 C maskUp :: Land mask used to denote base of the domain.
64 C xA :: Tracer cell face area normal to X
65 C yA :: Tracer cell face area normal to X
66 C uTrans :: Zonal volume transport through cell face
67 C vTrans :: Meridional volume transport through cell face
68 C rTrans :: Vertical volume transport at interface k
69 C rTransKp1 :: Vertical volume transport at inteface k+1
70 C bi, bj, iMin, iMax, jMin, jMax :: Range of points for which calculation
71 C results will be set.
72 C myThid :: Instance number for this innvocation of CALC_GT
73 _RL fVerS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
74 _RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
75 _RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
76 _RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
77 _RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
78 _RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
79 _RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
80 _RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
81 _RL KappaRS(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
82 INTEGER k,kUp,kDown,kM1
83 INTEGER bi,bj,iMin,iMax,jMin,jMax
84 _RL myTime
85 INTEGER myIter
86 INTEGER myThid
87
88 CEOP
89
90 #ifdef ALLOW_GENERIC_ADVDIFF
91 C === Local variables ===
92 LOGICAL calcAdvection
93 INTEGER iterNb
94 #ifdef ALLOW_ADAMSBASHFORTH_3
95 INTEGER m1, m2
96 #endif
97
98 #ifdef ALLOW_AUTODIFF_TAMC
99 act1 = bi - myBxLo(myThid)
100 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
101 act2 = bj - myByLo(myThid)
102 max2 = myByHi(myThid) - myByLo(myThid) + 1
103 act3 = myThid - 1
104 max3 = nTx*nTy
105 act4 = ikey_dynamics - 1
106 itdkey = (act1 + 1) + act2*max1
107 & + act3*max1*max2
108 & + act4*max1*max2*max3
109 kkey = (itdkey-1)*Nr + k
110 #endif /* ALLOW_AUTODIFF_TAMC */
111
112 #ifdef ALLOW_AUTODIFF_TAMC
113 C-- only the kUp part of fverS is set in this subroutine
114 C-- the kDown is still required
115 fVerS(1,1,kDown) = fVerS(1,1,kDown)
116 # ifdef NONLIN_FRSURF
117 CADJ STORE fVerS(:,:,:) = comlev1_bibj_k, key=kkey, byte=isbyte
118 # endif
119 #endif
120
121 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
122
123 calcAdvection = saltAdvection .AND. .NOT.saltMultiDimAdvec
124 iterNb = myIter
125 IF (staggerTimeStep) iterNb = myIter - 1
126
127 #ifdef ALLOW_ADAMSBASHFORTH_3
128 IF ( AdamsBashforth_S ) THEN
129 m1 = 1 + MOD(iterNb+1,2)
130 m2 = 1 + MOD( iterNb ,2)
131 CALL GAD_CALC_RHS(
132 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
133 I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
134 I uVel, vVel, wVel,
135 I diffKhS, diffK4S, KappaRS,
136 I gsNm(1-Olx,1-Oly,1,1,1,m2), salt,
137 I GAD_SALINITY, saltAdvScheme, saltVertAdvScheme,
138 I calcAdvection, saltImplVertAdv,
139 U fVerS, gS,
140 I myTime, myIter, myThid )
141 ELSE
142 CALL GAD_CALC_RHS(
143 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
144 I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
145 I uVel, vVel, wVel,
146 I diffKhS, diffK4S, KappaRS, salt, salt,
147 I GAD_SALINITY, saltAdvScheme, saltVertAdvScheme,
148 I calcAdvection, saltImplVertAdv,
149 U fVerS, gS,
150 I myTime, myIter, myThid )
151 ENDIF
152 #else /* ALLOW_ADAMSBASHFORTH_3 */
153 CALL GAD_CALC_RHS(
154 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
155 I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
156 I uVel, vVel, wVel,
157 I diffKhS, diffK4S, KappaRS, gsNm1, salt,
158 I GAD_SALINITY, saltAdvScheme, saltVertAdvScheme,
159 I calcAdvection, saltImplVertAdv,
160 U fVerS, gS,
161 I myTime, myIter, myThid )
162 #endif /* ALLOW_ADAMSBASHFORTH_3 */
163
164 C-- External salinity forcing term(s) inside Adams-Bashforth:
165 IF ( saltForcing .AND. forcing_In_AB )
166 & CALL EXTERNAL_FORCING_S(
167 I iMin,iMax,jMin,jMax,bi,bj,k,
168 I myTime,myThid)
169
170 IF ( AdamsBashforthGs ) THEN
171 #ifdef ALLOW_ADAMSBASHFORTH_3
172 CALL ADAMS_BASHFORTH3(
173 I bi, bj, k,
174 U gS, gsNm,
175 I saltStartAB, iterNb, myThid )
176 #else
177 CALL ADAMS_BASHFORTH2(
178 I bi, bj, k,
179 U gS, gsNm1,
180 I iterNb, myThid )
181 #endif
182 ENDIF
183
184 C-- External salinity forcing term(s) outside Adams-Bashforth:
185 IF ( saltForcing .AND. .NOT.forcing_In_AB )
186 & CALL EXTERNAL_FORCING_S(
187 I iMin,iMax,jMin,jMax,bi,bj,k,
188 I myTime,myThid)
189
190 #ifdef NONLIN_FRSURF
191 IF (nonlinFreeSurf.GT.0) THEN
192 CALL FREESURF_RESCALE_G(
193 I bi, bj, k,
194 U gS,
195 I myThid )
196 IF ( AdamsBashforthGs ) THEN
197 #ifdef ALLOW_ADAMSBASHFORTH_3
198 CALL FREESURF_RESCALE_G(
199 I bi, bj, k,
200 U gsNm(1-OLx,1-OLy,1,1,1,1),
201 I myThid )
202 CALL FREESURF_RESCALE_G(
203 I bi, bj, k,
204 U gsNm(1-OLx,1-OLy,1,1,1,2),
205 I myThid )
206 #else
207 CALL FREESURF_RESCALE_G(
208 I bi, bj, k,
209 U gsNm1,
210 I myThid )
211 #endif
212 ENDIF
213 ENDIF
214 #endif /* NONLIN_FRSURF */
215
216 #endif /* ALLOW_GENERIC_ADVDIFF */
217
218 RETURN
219 END

  ViewVC Help
Powered by ViewVC 1.1.22