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

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

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


Revision 1.44 - (hide annotations) (download)
Wed Mar 1 03:08:50 2006 UTC (18 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.43: +3 -15 lines
simplify the calls to GAD_CALC_RHS by adding 1 argument.

1 jmc 1.44 C $Header: /u/gcmpack/MITgcm/model/src/calc_gs.F,v 1.43 2006/02/26 01:57:24 jmc Exp $
2 adcroft 1.31 C $Name: $
3 cnh 1.1
4 jmc 1.39 #include "PACKAGES_CONFIG.h"
5 cnh 1.17 #include "CPP_OPTIONS.h"
6 cnh 1.1
7 cnh 1.32 CBOP
8     C !ROUTINE: CALC_GS
9     C !INTERFACE:
10 cnh 1.1 SUBROUTINE CALC_GS(
11     I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
12 jmc 1.35 I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
13 adcroft 1.21 I KappaRS,
14 adcroft 1.23 U fVerS,
15 adcroft 1.31 I myTime,myIter,myThid )
16 cnh 1.32 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 cnh 1.1 IMPLICIT NONE
46     C == GLobal variables ==
47     #include "SIZE.h"
48     #include "DYNVARS.h"
49     #include "EEPARAMS.h"
50     #include "PARAMS.h"
51 jmc 1.39 #ifdef ALLOW_GENERIC_ADVDIFF
52 adcroft 1.30 #include "GAD.h"
53 jmc 1.39 #endif
54 heimbach 1.42 #ifdef ALLOW_AUTODIFF_TAMC
55     # include "tamc.h"
56     # include "tamc_keys.h"
57     #endif
58 cnh 1.1
59 cnh 1.32 C !INPUT/OUTPUT PARAMETERS:
60 cnh 1.1 C == Routine arguments ==
61 cnh 1.32 C fVerS :: Flux of salt (S) in the vertical
62 cnh 1.1 C direction at the upper(U) and lower(D) faces of a cell.
63 cnh 1.32 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 jmc 1.35 C rTrans :: Vertical volume transport at interface k
69     C rTransKp1 :: Vertical volume transport at inteface k+1
70 cnh 1.32 C bi, bj, iMin, iMax, jMin, jMax :: Range of points for which calculation
71 cnh 1.1 C results will be set.
72 cnh 1.32 C myThid :: Instance number for this innvocation of CALC_GT
73 cnh 1.1 _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 cnh 1.12 _RL rTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
79 jmc 1.35 _RL rTransKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
80 cnh 1.1 _RS maskUp(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
81 jmc 1.38 _RL KappaRS(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
82 adcroft 1.7 INTEGER k,kUp,kDown,kM1
83 cnh 1.1 INTEGER bi,bj,iMin,iMax,jMin,jMax
84 adcroft 1.31 _RL myTime
85     INTEGER myIter
86 cnh 1.1 INTEGER myThid
87    
88 cnh 1.32 CEOP
89 heimbach 1.20
90 jmc 1.39 #ifdef ALLOW_GENERIC_ADVDIFF
91 jmc 1.33 C === Local variables ===
92     LOGICAL calcAdvection
93 jmc 1.40 INTEGER iterNb
94 jmc 1.41 #ifdef ALLOW_ADAMSBASHFORTH_3
95     INTEGER m1, m2
96     #endif
97 jmc 1.33
98 heimbach 1.20 #ifdef ALLOW_AUTODIFF_TAMC
99 heimbach 1.42 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 heimbach 1.20 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 heimbach 1.42 # ifdef NONLIN_FRSURF
117     CADJ STORE fVerS(:,:,:) = comlev1_bibj_k, key=kkey, byte=isbyte
118     # endif
119 adcroft 1.27 #endif
120 cnh 1.1
121 jmc 1.41 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
122    
123 jmc 1.33 calcAdvection = saltAdvection .AND. .NOT.saltMultiDimAdvec
124 jmc 1.41 iterNb = myIter
125     IF (staggerTimeStep) iterNb = myIter - 1
126    
127     #ifdef ALLOW_ADAMSBASHFORTH_3
128     m1 = 1 + MOD(iterNb+1,2)
129     m2 = 1 + MOD( iterNb ,2)
130     CALL GAD_CALC_RHS(
131 adcroft 1.30 I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
132 jmc 1.35 I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
133     I uVel, vVel, wVel,
134 jmc 1.41 I diffKhS, diffK4S, KappaRS,
135     I gsNm(1-Olx,1-Oly,1,1,1,m2), salt,
136 jmc 1.36 I GAD_SALINITY, saltAdvScheme, saltVertAdvScheme,
137 jmc 1.44 I calcAdvection, saltImplVertAdv, AdamsBashforth_S,
138 adcroft 1.30 U fVerS, gS,
139 jmc 1.37 I myTime, myIter, myThid )
140 jmc 1.43 #else /* ALLOW_ADAMSBASHFORTH_3 */
141     CALL GAD_CALC_RHS(
142     I bi,bj,iMin,iMax,jMin,jMax,k,kM1,kUp,kDown,
143     I xA,yA,uTrans,vTrans,rTrans,rTransKp1,maskUp,
144     I uVel, vVel, wVel,
145     I diffKhS, diffK4S, KappaRS, gsNm1, salt,
146     I GAD_SALINITY, saltAdvScheme, saltVertAdvScheme,
147 jmc 1.44 I calcAdvection, saltImplVertAdv, AdamsBashforth_S,
148 jmc 1.43 U fVerS, gS,
149     I myTime, myIter, myThid )
150     #endif /* ALLOW_ADAMSBASHFORTH_3 */
151 cnh 1.1
152 jmc 1.33 C-- External salinity forcing term(s) inside Adams-Bashforth:
153     IF ( saltForcing .AND. forcing_In_AB )
154     & CALL EXTERNAL_FORCING_S(
155 cnh 1.16 I iMin,iMax,jMin,jMax,bi,bj,k,
156 adcroft 1.31 I myTime,myThid)
157    
158 jmc 1.41 IF ( AdamsBashforthGs ) THEN
159 jmc 1.40 #ifdef ALLOW_ADAMSBASHFORTH_3
160     CALL ADAMS_BASHFORTH3(
161     I bi, bj, k,
162     U gS, gsNm,
163 jmc 1.41 I saltStartAB, iterNb, myThid )
164 jmc 1.40 #else
165 adcroft 1.31 CALL ADAMS_BASHFORTH2(
166 jmc 1.40 I bi, bj, k,
167     U gS, gsNm1,
168     I iterNb, myThid )
169     #endif
170 adcroft 1.31 ENDIF
171 jmc 1.33
172     C-- External salinity forcing term(s) outside Adams-Bashforth:
173     IF ( saltForcing .AND. .NOT.forcing_In_AB )
174     & CALL EXTERNAL_FORCING_S(
175     I iMin,iMax,jMin,jMax,bi,bj,k,
176     I myTime,myThid)
177 adcroft 1.31
178     #ifdef NONLIN_FRSURF
179     IF (nonlinFreeSurf.GT.0) THEN
180     CALL FREESURF_RESCALE_G(
181 jmc 1.40 I bi, bj, k,
182 adcroft 1.31 U gS,
183 jmc 1.34 I myThid )
184 jmc 1.41 IF ( AdamsBashforthGs ) THEN
185 jmc 1.40 #ifdef ALLOW_ADAMSBASHFORTH_3
186     CALL FREESURF_RESCALE_G(
187     I bi, bj, k,
188     U gsNm(1-OLx,1-OLy,1,1,1,1),
189     I myThid )
190     CALL FREESURF_RESCALE_G(
191     I bi, bj, k,
192     U gsNm(1-OLx,1-OLy,1,1,1,2),
193 adcroft 1.31 I myThid )
194 jmc 1.40 #else
195     CALL FREESURF_RESCALE_G(
196     I bi, bj, k,
197     U gsNm1,
198     I myThid )
199     #endif
200     ENDIF
201 adcroft 1.31 ENDIF
202     #endif /* NONLIN_FRSURF */
203 cnh 1.1
204 jmc 1.39 #endif /* ALLOW_GENERIC_ADVDIFF */
205    
206 cnh 1.1 RETURN
207     END

  ViewVC Help
Powered by ViewVC 1.1.22