66 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
67 |
#include "GRID.h" |
#include "GRID.h" |
68 |
#include "GAD.h" |
#include "GAD.h" |
69 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
70 |
|
# include "tamc.h" |
71 |
|
# include "tamc_keys.h" |
72 |
|
#endif |
73 |
|
|
74 |
C !INPUT PARAMETERS: =================================================== |
C !INPUT PARAMETERS: =================================================== |
75 |
C bi,bj :: tile indices |
C bi,bj :: tile indices |
126 |
INTEGER nipass,ipass |
INTEGER nipass,ipass |
127 |
CEOP |
CEOP |
128 |
|
|
129 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
130 |
|
act1 = bi - myBxLo(myThid) |
131 |
|
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
132 |
|
act2 = bj - myByLo(myThid) |
133 |
|
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
134 |
|
act3 = myThid - 1 |
135 |
|
max3 = nTx*nTy |
136 |
|
act4 = ikey_dynamics - 1 |
137 |
|
ikey = (act1 + 1) + act2*max1 |
138 |
|
& + act3*max1*max2 |
139 |
|
& + act4*max1*max2*max3 |
140 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
141 |
|
|
142 |
C-- Set up work arrays with valid (i.e. not NaN) values |
C-- Set up work arrays with valid (i.e. not NaN) values |
143 |
C These inital values do not alter the numerical results. They |
C These inital values do not alter the numerical results. They |
144 |
C just ensure that all memory references are to valid floating |
C just ensure that all memory references are to valid floating |
163 |
|
|
164 |
C-- Start of k loop for horizontal fluxes |
C-- Start of k loop for horizontal fluxes |
165 |
DO k=1,Nr |
DO k=1,Nr |
166 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
167 |
|
kkey = (ikey-1)*Nr + k |
168 |
|
CADJ STORE tracer(:,:,k,bi,bj) = comlev1_bibj_k, key=kkey, byte=isbyte |
169 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
170 |
|
|
171 |
C-- Get temporary terms used by tendency routines |
C-- Get temporary terms used by tendency routines |
172 |
CALL CALC_COMMON_FACTORS ( |
CALL CALC_COMMON_FACTORS ( |
186 |
ELSE |
ELSE |
187 |
nipass=1 |
nipass=1 |
188 |
ENDIF |
ENDIF |
189 |
nipass=1 |
cph nipass=1 |
190 |
|
|
191 |
C-- Multiple passes for different directions on different tiles |
C-- Multiple passes for different directions on different tiles |
192 |
DO ipass=1,nipass |
DO ipass=1,nipass |
193 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
194 |
|
passkey = ipass + (k-1) *maxpass |
195 |
|
& + (ikey-1)*maxpass*Nr |
196 |
|
IF (nipass .GT. maxpass) THEN |
197 |
|
STOP 'GAD_ADVECTION: nipass > maxpass. check tamc.h' |
198 |
|
ENDIF |
199 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
200 |
|
|
201 |
IF (nipass.EQ.3) THEN |
IF (nipass.EQ.3) THEN |
202 |
calc_fluxes_X=.FALSE. |
calc_fluxes_X=.FALSE. |
240 |
af(i,j) = 0. |
af(i,j) = 0. |
241 |
ENDDO |
ENDDO |
242 |
ENDDO |
ENDDO |
243 |
|
|
244 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
245 |
|
#ifdef ALLOW_MULTIDIM_ADVECTION |
246 |
|
CADJ STORE localTij(:,:) = comlev1_bibj_pass, key=passkey, byte=isbyte |
247 |
|
#endif |
248 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
249 |
|
|
250 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
251 |
CALL GAD_FLUXLIMIT_ADV_X( |
CALL GAD_FLUXLIMIT_ADV_X( |
252 |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
& bi,bj,k,deltaTtracer,uTrans,uVel,localTij,af,myThid) |
259 |
ELSE |
ELSE |
260 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
261 |
ENDIF |
ENDIF |
262 |
|
|
263 |
DO j=1-Oly,sNy+Oly |
DO j=1-Oly,sNy+Oly |
264 |
DO i=1-Olx,sNx+Olx-1 |
DO i=1-Olx,sNx+Olx-1 |
265 |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
306 |
af(i,j) = 0. |
af(i,j) = 0. |
307 |
ENDDO |
ENDDO |
308 |
ENDDO |
ENDDO |
309 |
|
|
310 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
311 |
|
#ifdef ALLOW_MULTIDIM_ADVECTION |
312 |
|
CADJ STORE localTij(:,:) = comlev1_bibj_pass, key=passkey, byte=isbyte |
313 |
|
#endif |
314 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
315 |
|
|
316 |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
IF (advectionScheme.EQ.ENUM_FLUX_LIMIT) THEN |
317 |
CALL GAD_FLUXLIMIT_ADV_Y( |
CALL GAD_FLUXLIMIT_ADV_Y( |
318 |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
& bi,bj,k,deltaTtracer,vTrans,vVel,localTij,af,myThid) |
325 |
ELSE |
ELSE |
326 |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
STOP 'GAD_ADVECTION: adv. scheme incompatibale with mutli-dim' |
327 |
ENDIF |
ENDIF |
328 |
|
|
329 |
DO j=1-Oly,sNy+Oly-1 |
DO j=1-Oly,sNy+Oly-1 |
330 |
DO i=1-Olx,sNx+Olx |
DO i=1-Olx,sNx+Olx |
331 |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
localTij(i,j)=localTij(i,j)-deltaTtracer* |
365 |
|
|
366 |
C-- Start of k loop for vertical flux |
C-- Start of k loop for vertical flux |
367 |
DO k=Nr,1,-1 |
DO k=Nr,1,-1 |
368 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
369 |
|
kkey = (ikey-1)*Nr + k |
370 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
371 |
|
|
372 |
C-- kup Cycles through 1,2 to point to w-layer above |
C-- kup Cycles through 1,2 to point to w-layer above |
373 |
C-- kDown Cycles through 2,1 to point to w-layer below |
C-- kDown Cycles through 2,1 to point to w-layer below |
387 |
ENDDO |
ENDDO |
388 |
ENDDO |
ENDDO |
389 |
|
|
390 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
391 |
|
CADJ STORE localTijk(:,:,k) |
392 |
|
CADJ & = comlev1_bibj_k, key=kkey, byte=isbyte |
393 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
394 |
|
|
395 |
C Note: wVel needs to be masked |
C Note: wVel needs to be masked |
396 |
IF (K.GE.2) THEN |
IF (K.GE.2) THEN |
397 |
C- Compute vertical advective flux in the interior: |
C- Compute vertical advective flux in the interior: |