/[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.57 - (show annotations) (download)
Tue Nov 19 17:05:40 2013 UTC (10 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.56: +1 -1 lines
FILE REMOVED
remove routine which are no longer used (after removing k-loop from
 thermodynamics.F) and update ad_diff list

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

  ViewVC Help
Powered by ViewVC 1.1.22