1 |
C $Header: /u/gcmpack/MITgcm/pkg/longstep/longstep_thermodynamics.F,v 1.8 2013/12/06 01:57:51 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "LONGSTEP_OPTIONS.h" |
5 |
|
6 |
#ifdef ALLOW_AUTODIFF_TAMC |
7 |
# ifdef ALLOW_GMREDI |
8 |
# include "GMREDI_OPTIONS.h" |
9 |
# endif |
10 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
11 |
|
12 |
CBOP |
13 |
C !ROUTINE: LONGSTEP_THERMODYNAMICS |
14 |
C !INTERFACE: |
15 |
SUBROUTINE LONGSTEP_THERMODYNAMICS( myTime, myIter, myThid ) |
16 |
C !DESCRIPTION: \bv |
17 |
C *==========================================================* |
18 |
C | SUBROUTINE LONGSTEP_THERMODYNAMICS |
19 |
C | o Controlling routine for the prognostics of passive tracers |
20 |
C | with longer time step. |
21 |
C *=========================================================== |
22 |
C | This is a copy of THERMODYNAMICS, but only with the |
23 |
C | parts relevant to ptracers, and dynamics fields replaced |
24 |
C | by their longstep averages. |
25 |
C | When THERMODYNAMICS is changed, this routine probably has |
26 |
C | to be changed too :( |
27 |
C *==========================================================* |
28 |
C \ev |
29 |
|
30 |
C !USES: |
31 |
IMPLICIT NONE |
32 |
C == Global variables === |
33 |
#include "SIZE.h" |
34 |
#include "EEPARAMS.h" |
35 |
#include "PARAMS.h" |
36 |
#include "RESTART.h" |
37 |
#include "DYNVARS.h" |
38 |
#include "GRID.h" |
39 |
#include "SURFACE.h" |
40 |
#ifdef ALLOW_GENERIC_ADVDIFF |
41 |
# include "GAD.h" |
42 |
#endif |
43 |
#include "LONGSTEP_PARAMS.h" |
44 |
#include "LONGSTEP.h" |
45 |
#ifdef ALLOW_PTRACERS |
46 |
# include "PTRACERS_SIZE.h" |
47 |
# include "PTRACERS_PARAMS.h" |
48 |
# include "PTRACERS_FIELDS.h" |
49 |
#endif |
50 |
|
51 |
#ifdef ALLOW_AUTODIFF_TAMC |
52 |
# include "tamc.h" |
53 |
# include "tamc_keys.h" |
54 |
# include "FFIELDS.h" |
55 |
# include "EOS.h" |
56 |
# ifdef ALLOW_GMREDI |
57 |
# include "GMREDI.h" |
58 |
# endif |
59 |
# ifdef ALLOW_EBM |
60 |
# include "EBM.h" |
61 |
# endif |
62 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
63 |
|
64 |
C !INPUT/OUTPUT PARAMETERS: |
65 |
C == Routine arguments == |
66 |
C myTime :: Current time in simulation |
67 |
C myIter :: Current iteration number in simulation |
68 |
C myThid :: Thread number for this instance of the routine. |
69 |
_RL myTime |
70 |
INTEGER myIter |
71 |
INTEGER myThid |
72 |
|
73 |
#ifdef ALLOW_LONGSTEP |
74 |
C !LOCAL VARIABLES: |
75 |
C == Local variables |
76 |
C uFld,vFld,wFld :: Local copy of velocity field (3 components) |
77 |
C kappaRk :: Total diffusion in vertical, all levels, 1 tracer |
78 |
C useVariableK :: T when vertical diffusion is not constant |
79 |
C iMin, iMax :: Ranges and sub-block indices on which calculations |
80 |
C jMin, jMax are applied. |
81 |
C bi, bj :: Tile indices |
82 |
C i, j, k :: loop indices |
83 |
_RL uFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
84 |
_RL vFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
85 |
_RL wFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
86 |
_RL kappaRk (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
87 |
_RS recip_hFacNew(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
88 |
INTEGER iMin, iMax |
89 |
INTEGER jMin, jMax |
90 |
INTEGER bi, bj |
91 |
INTEGER i, j, k |
92 |
CEOP |
93 |
|
94 |
#ifdef ALLOW_DEBUG |
95 |
IF (debugMode) CALL DEBUG_ENTER('LONGSTEP_THERMODYNAMICS',myThid) |
96 |
#endif |
97 |
|
98 |
C time for a ptracer time step? |
99 |
IF ( LS_doTimeStep ) THEN |
100 |
|
101 |
#ifdef ALLOW_AUTODIFF_TAMC |
102 |
C-- dummy statement to end declaration part |
103 |
ikey = 1 |
104 |
itdkey = 1 |
105 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
106 |
|
107 |
DO bj=myByLo(myThid),myByHi(myThid) |
108 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
109 |
|
110 |
#ifdef ALLOW_AUTODIFF_TAMC |
111 |
act1 = bi - myBxLo(myThid) |
112 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
113 |
act2 = bj - myByLo(myThid) |
114 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
115 |
act3 = myThid - 1 |
116 |
max3 = nTx*nTy |
117 |
act4 = ikey_dynamics - 1 |
118 |
itdkey = (act1 + 1) + act2*max1 |
119 |
& + act3*max1*max2 |
120 |
& + act4*max1*max2*max3 |
121 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
122 |
|
123 |
C-- Set up work arrays with valid (i.e. not NaN) values |
124 |
C These inital values do not alter the numerical results. They |
125 |
C just ensure that all memory references are to valid floating |
126 |
C point numbers. This prevents spurious hardware signals due to |
127 |
C uninitialised but inert locations. |
128 |
|
129 |
DO k=1,Nr |
130 |
DO j=1-OLy,sNy+OLy |
131 |
DO i=1-OLx,sNx+OLx |
132 |
C This is currently also used by IVDC and Diagnostics |
133 |
kappaRk(i,j,k) = 0. _d 0 |
134 |
ENDDO |
135 |
ENDDO |
136 |
ENDDO |
137 |
|
138 |
C-- Compute new reciprocal hFac for implicit calculation |
139 |
#ifdef NONLIN_FRSURF |
140 |
IF ( nonlinFreeSurf.GT.0 ) THEN |
141 |
IF ( select_rStar.GT.0 ) THEN |
142 |
# ifndef DISABLE_RSTAR_CODE |
143 |
DO k=1,Nr |
144 |
DO j=1-OLy,sNy+OLy |
145 |
DO i=1-OLx,sNx+OLx |
146 |
recip_hFacNew(i,j,k) = recip_hFacC(i,j,k,bi,bj) |
147 |
& / rStarExpC(i,j,bi,bj) |
148 |
ENDDO |
149 |
ENDDO |
150 |
ENDDO |
151 |
# endif /* DISABLE_RSTAR_CODE */ |
152 |
ELSEIF ( selectSigmaCoord.NE.0 ) THEN |
153 |
# ifndef DISABLE_SIGMA_CODE |
154 |
DO k=1,Nr |
155 |
DO j=1-OLy,sNy+OLy |
156 |
DO i=1-OLx,sNx+OLx |
157 |
recip_hFacNew(i,j,k) = recip_hFacC(i,j,k,bi,bj) |
158 |
& /( 1. _d 0 + dEtaHdt(i,j,bi,bj)*deltaTFreeSurf |
159 |
& *dBHybSigF(k)*recip_drF(k) |
160 |
& *recip_hFacC(i,j,k,bi,bj) |
161 |
& ) |
162 |
ENDDO |
163 |
ENDDO |
164 |
ENDDO |
165 |
# endif /* DISABLE_RSTAR_CODE */ |
166 |
ELSE |
167 |
DO k=1,Nr |
168 |
DO j=1-OLy,sNy+OLy |
169 |
DO i=1-OLx,sNx+OLx |
170 |
IF ( k.EQ.kSurfC(i,j,bi,bj) ) THEN |
171 |
recip_hFacNew(i,j,k) = 1. _d 0 / hFac_surfC(i,j,bi,bj) |
172 |
ELSE |
173 |
recip_hFacNew(i,j,k) = recip_hFacC(i,j,k,bi,bj) |
174 |
ENDIF |
175 |
ENDDO |
176 |
ENDDO |
177 |
ENDDO |
178 |
ENDIF |
179 |
ELSE |
180 |
#endif /* NONLIN_FRSURF */ |
181 |
DO k=1,Nr |
182 |
DO j=1-OLy,sNy+OLy |
183 |
DO i=1-OLx,sNx+OLx |
184 |
recip_hFacNew(i,j,k) = _recip_hFacC(i,j,k,bi,bj) |
185 |
ENDDO |
186 |
ENDDO |
187 |
ENDDO |
188 |
#ifdef NONLIN_FRSURF |
189 |
ENDIF |
190 |
#endif /* NONLIN_FRSURF */ |
191 |
|
192 |
iMin = 1-OLx |
193 |
iMax = sNx+OLx |
194 |
jMin = 1-OLy |
195 |
jMax = sNy+OLy |
196 |
|
197 |
C need to recompute surfaceForcingPtr using LS_fwFlux |
198 |
CALL LONGSTEP_FORCING_SURF( |
199 |
I bi, bj, iMin, iMax, jMin, jMax, |
200 |
I myTime,myIter,myThid ) |
201 |
|
202 |
C-- Set up 3-D velocity field that we use to advect tracers: |
203 |
C- just do a local copy: |
204 |
DO k=1,Nr |
205 |
DO j=1-OLy,sNy+OLy |
206 |
DO i=1-OLx,sNx+OLx |
207 |
uFld(i,j,k) = LS_uVel(i,j,k,bi,bj) |
208 |
vFld(i,j,k) = LS_vVel(i,j,k,bi,bj) |
209 |
wFld(i,j,k) = LS_wVel(i,j,k,bi,bj) |
210 |
ENDDO |
211 |
ENDDO |
212 |
ENDDO |
213 |
#ifdef ALLOW_GMREDI |
214 |
C- add Bolus velocity to Eulerian-mean velocity: |
215 |
IF (useGMRedi) THEN |
216 |
CALL GMREDI_RESIDUAL_FLOW( |
217 |
U uFld, vFld, wFld, |
218 |
I bi, bj, myIter, myThid ) |
219 |
ENDIF |
220 |
#endif /* ALLOW_GMREDI */ |
221 |
|
222 |
#ifdef ALLOW_PTRACERS |
223 |
C-- Calculate passive tracer tendencies |
224 |
C and step forward, storing result in gPtr |
225 |
C Also apply open boundary conditions for each passive tracer |
226 |
IF ( usePTRACERS ) THEN |
227 |
#ifdef ALLOW_DEBUG |
228 |
IF (debugMode) CALL DEBUG_CALL('PTRACERS_INTEGRATE',myThid) |
229 |
#endif |
230 |
CALL PTRACERS_INTEGRATE( |
231 |
I bi, bj, recip_hFacNew, |
232 |
I uFld, vFld, wFld, |
233 |
U kappaRk, |
234 |
I myTime, myIter, myThid ) |
235 |
ENDIF |
236 |
#endif /* ALLOW_PTRACERS */ |
237 |
|
238 |
C-- end bi,bj loops. |
239 |
ENDDO |
240 |
ENDDO |
241 |
|
242 |
#ifdef ALLOW_DEBUG |
243 |
IF ( debugLevel.GE.debLevD ) THEN |
244 |
CALL DEBUG_STATS_RL(Nr,LS_uVel,'LS_Uvel (THERMODYNAMICS)',myThid) |
245 |
CALL DEBUG_STATS_RL(Nr,LS_vVel,'LS_Vvel (THERMODYNAMICS)',myThid) |
246 |
CALL DEBUG_STATS_RL(Nr,LS_wVel,'LS_Wvel (THERMODYNAMICS)',myThid) |
247 |
CALL DEBUG_STATS_RL(Nr,LS_theta,'LS_Theta (THERMODYNAMICS)', |
248 |
& myThid) |
249 |
CALL DEBUG_STATS_RL(Nr,LS_salt,'LS_Salt (THERMODYNAMICS)',myThid) |
250 |
#ifdef ALLOW_PTRACERS |
251 |
IF ( usePTRACERS ) THEN |
252 |
CALL PTRACERS_DEBUG(myThid) |
253 |
ENDIF |
254 |
#endif /* ALLOW_PTRACERS */ |
255 |
ENDIF |
256 |
#endif /* ALLOW_DEBUG */ |
257 |
|
258 |
C LS_doTimeStep |
259 |
ENDIF |
260 |
|
261 |
#ifdef ALLOW_DEBUG |
262 |
IF (debugMode) CALL DEBUG_LEAVE('LONGSTEP_THERMODYNAMICS',myThid) |
263 |
#endif |
264 |
|
265 |
#endif /* ALLOW_LONGSTEP */ |
266 |
|
267 |
RETURN |
268 |
END |