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

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

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


Revision 1.52 - (show annotations) (download)
Sun Sep 23 17:13:13 2007 UTC (16 years, 9 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint59h
Changes since 1.51: +3 -1 lines
add trUseGMRedi & trUseKPP to the argument list of S/R GAD_CALC_RHS

1 C $Header: /u/gcmpack/MITgcm/model/src/calc_gt.F,v 1.51 2006/06/18 23:22:43 jmc Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6
7 CBOP
8 C !ROUTINE: CALC_GT
9 C !INTERFACE:
10 SUBROUTINE CALC_GT(
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 KappaRT,
15 U fVerT,
16 I myTime,myIter,myThid )
17 C !DESCRIPTION: \bv
18 C *==========================================================*
19 C | SUBROUTINE CALC_GT
20 C | o Calculate the temperature tendency terms.
21 C *==========================================================*
22 C | A procedure called EXTERNAL_FORCING_T is called from
23 C | here. These procedures can be used to add per problem
24 C | heat 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 #ifdef ALLOW_GENERIC_ADVDIFF
53 #include "GAD.h"
54 #endif
55 #ifdef ALLOW_AUTODIFF_TAMC
56 # include "tamc.h"
57 # include "tamc_keys.h"
58 #endif
59
60 C !INPUT/OUTPUT PARAMETERS:
61 C == Routine arguments ==
62 C bi, bj, :: tile indices
63 C iMin,iMax :: loop range for called routines
64 C jMin,jMax :: loop range for called routines
65 C k :: vertical index
66 C kM1 :: =k-1 for k>1, =1 for k=1
67 C kUp :: index into 2 1/2D array, toggles between 1|2
68 C kDown :: index into 2 1/2D array, toggles between 2|1
69 C xA :: Tracer cell face area normal to X
70 C yA :: Tracer cell face area normal to X
71 C maskUp :: Land mask used to denote base of the domain.
72 C uFld,vFld :: Local copy of horizontal velocity field
73 C wFld :: Local copy of vertical velocity field
74 C uTrans :: Zonal volume transport through cell face
75 C vTrans :: Meridional volume transport through cell face
76 C rTrans :: Vertical volume transport at interface k
77 C rTransKp1 :: Vertical volume transport at inteface k+1
78 C KappaRT :: Vertical diffusion for Tempertature
79 C fVerT :: Flux of temperature (T) in the vertical direction
80 C at the upper(U) and lower(D) faces of a cell.
81 C myTime :: current time
82 C myIter :: current iteration number
83 C myThid :: my Thread Id. number
84 INTEGER bi,bj,iMin,iMax,jMin,jMax
85 INTEGER k,kUp,kDown,kM1
86 _RS xA (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
87 _RS yA (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
88 _RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
89 _RL uFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
90 _RL vFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
91 _RL wFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
92 _RL uTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
93 _RL vTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
94 _RL rTrans (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
95 _RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
96 _RL KappaRT(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
97 _RL fVerT (1-OLx:sNx+OLx,1-OLy:sNy+OLy,2)
98 _RL myTime
99 INTEGER myIter
100 INTEGER myThid
101 CEOP
102
103 #ifdef ALLOW_GENERIC_ADVDIFF
104 C === Local variables ===
105 LOGICAL calcAdvection
106 INTEGER iterNb
107 #ifdef ALLOW_ADAMSBASHFORTH_3
108 INTEGER m1, m2
109 #endif
110
111 #ifdef ALLOW_AUTODIFF_TAMC
112 act1 = bi - myBxLo(myThid)
113 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
114 act2 = bj - myByLo(myThid)
115 max2 = myByHi(myThid) - myByLo(myThid) + 1
116 act3 = myThid - 1
117 max3 = nTx*nTy
118 act4 = ikey_dynamics - 1
119 itdkey = (act1 + 1) + act2*max1
120 & + act3*max1*max2
121 & + act4*max1*max2*max3
122 kkey = (itdkey-1)*Nr + k
123 #endif /* ALLOW_AUTODIFF_TAMC */
124
125 #ifdef ALLOW_AUTODIFF_TAMC
126 C-- only the kUp part of fverT is set in this subroutine
127 C-- the kDown is still required
128 fVerT(1,1,kDown) = fVerT(1,1,kDown)
129 # ifdef NONLIN_FRSURF
130 CADJ STORE fVerT(:,:,:) =
131 CADJ & comlev1_bibj_k, key=kkey, byte=isbyte
132 CADJ STORE gtNm1(:,:,k,bi,bj) =
133 CADJ & comlev1_bibj_k, key=kkey, byte=isbyte
134 # endif
135 #endif
136
137 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
138
139 calcAdvection = tempAdvection .AND. .NOT.tempMultiDimAdvec
140 iterNb = myIter
141 IF (staggerTimeStep) iterNb = myIter -1
142
143 #ifdef ALLOW_ADAMSBASHFORTH_3
144 m1 = 1 + MOD(iterNb+1,2)
145 m2 = 1 + MOD( iterNb ,2)
146 CALL GAD_CALC_RHS(
147 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
148 I xA, yA, maskUp, uFld, vFld, wFld,
149 I uTrans, vTrans, rTrans, rTransKp1,
150 I diffKhT, diffK4T, KappaRT,
151 I gtNm(1-Olx,1-Oly,1,1,1,m2), theta,
152 I GAD_TEMPERATURE, tempAdvScheme, tempVertAdvScheme,
153 I calcAdvection, tempImplVertAdv, AdamsBashforth_T,
154 I useGMRedi, useKPP,
155 U fVerT, gT,
156 I myTime, myIter, myThid )
157 #else /* ALLOW_ADAMSBASHFORTH_3 */
158 CALL GAD_CALC_RHS(
159 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
160 I xA, yA, maskUp, uFld, vFld, wFld,
161 I uTrans, vTrans, rTrans, rTransKp1,
162 I diffKhT, diffK4T, KappaRT, gtNm1, theta,
163 I GAD_TEMPERATURE, tempAdvScheme, tempVertAdvScheme,
164 I calcAdvection, tempImplVertAdv, AdamsBashforth_T,
165 I useGMRedi, useKPP,
166 U fVerT, gT,
167 I myTime, myIter, myThid )
168 #endif
169
170 C-- External thermal forcing term(s) inside Adams-Bashforth:
171 IF ( tempForcing .AND. tracForcingOutAB.NE.1 )
172 & CALL EXTERNAL_FORCING_T(
173 I iMin,iMax,jMin,jMax,bi,bj,k,
174 I myTime,myThid)
175
176 IF ( AdamsBashforthGt ) THEN
177 #ifdef ALLOW_ADAMSBASHFORTH_3
178 CALL ADAMS_BASHFORTH3(
179 I bi, bj, k,
180 U gT, gtNm,
181 I tempStartAB, iterNb, myThid )
182 #else
183 CALL ADAMS_BASHFORTH2(
184 I bi, bj, k,
185 U gT, gtNm1,
186 I iterNb, myThid )
187 #endif
188 ENDIF
189
190 C-- External thermal forcing term(s) outside Adams-Bashforth:
191 IF ( tempForcing .AND. tracForcingOutAB.EQ.1 )
192 & CALL EXTERNAL_FORCING_T(
193 I iMin,iMax,jMin,jMax,bi,bj,k,
194 I myTime,myThid)
195
196 #ifdef NONLIN_FRSURF
197 IF (nonlinFreeSurf.GT.0) THEN
198 CALL FREESURF_RESCALE_G(
199 I bi, bj, k,
200 U gT,
201 I myThid )
202 IF ( AdamsBashforthGt ) THEN
203 #ifdef ALLOW_ADAMSBASHFORTH_3
204 CALL FREESURF_RESCALE_G(
205 I bi, bj, k,
206 U gtNm(1-Olx,1-Oly,1,1,1,1),
207 I myThid )
208 CALL FREESURF_RESCALE_G(
209 I bi, bj, k,
210 U gtNm(1-Olx,1-Oly,1,1,1,2),
211 I myThid )
212 #else
213 CALL FREESURF_RESCALE_G(
214 I bi, bj, k,
215 U gtNm1,
216 I myThid )
217 #endif
218 ENDIF
219 ENDIF
220 #endif /* NONLIN_FRSURF */
221
222 #endif /* ALLOW_GENERIC_ADVDIFF */
223
224 RETURN
225 END

  ViewVC Help
Powered by ViewVC 1.1.22