1 |
C $Header: /u/gcmpack/MITgcm/pkg/autodiff/copy_ad_uv_outp.F,v 1.1 2012/07/28 19:56:51 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "AUTODIFF_OPTIONS.h" |
5 |
#include "AD_CONFIG.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: COPY_AD_UV_OUTP |
9 |
C !INTERFACE: |
10 |
SUBROUTINE COPY_AD_UV_OUTP( |
11 |
I uFldRS, vFldRS, uFldRL, vFldRL, |
12 |
O uFldOut, vFldOut, |
13 |
I nNz, vType, myThid ) |
14 |
|
15 |
C !DESCRIPTION: |
16 |
C Copy 2-components input AD-variable (RS or RL) into output array and then, |
17 |
C according to variable type, apply ADEXCH to output array. |
18 |
C vType (1rst digit): |
19 |
C = 1,3 : process RS input field ; = 2,4 : process RL input field |
20 |
C = 1,2 : without sign. ; = 3,4 : with sign. |
21 |
C vType (2nd digit) = 10 : A-grid location (i.e., grid-cell center) |
22 |
C = 20 : B-grid location (i.e., grid-cell corner) |
23 |
C = 30 : C-grid location ; = 40 : D-grid location |
24 |
|
25 |
C !USES: |
26 |
IMPLICIT NONE |
27 |
|
28 |
C Global variables / common blocks |
29 |
#include "EEPARAMS.h" |
30 |
#include "SIZE.h" |
31 |
|
32 |
C !INPUT/OUTPUT PARAMETERS: |
33 |
C Routine arguments |
34 |
C uFldRS ( RS ) :: input AD-vector field, 1rst component |
35 |
C vFldRS ( RS ) :: input AD-vector field, 2nd component |
36 |
C uFldRL ( RL ) :: input AD-vector field, 1rst component |
37 |
C vFldRL ( RL ) :: input AD-vector field, 2nd component |
38 |
C uFldOut ( RL ) :: copy of input field, 1rst component |
39 |
C vFldOut ( RL ) :: copy of input field, 1rst component |
40 |
C nNz (integer):: third dimension of 3-D input/output field |
41 |
C vType (integer):: type of AD-variable (select which ADEXCH to use) |
42 |
C myThid (integer):: my Thread Id number |
43 |
INTEGER nNz |
44 |
_RS uFldRS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
45 |
_RS vFldRS (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
46 |
_RL uFldRL (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
47 |
_RL vFldRL (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
48 |
_RL uFldOut(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
49 |
_RL vFldOut(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
50 |
INTEGER vType |
51 |
INTEGER myThid |
52 |
|
53 |
#ifdef ALLOW_AUTODIFF_MONITOR |
54 |
#if (defined (ALLOW_ADJOINT_RUN) || defined (ALLOW_ADMTLM)) |
55 |
C !LOCAL VARIABLES: |
56 |
C i,j,k :: loop indices |
57 |
C bi,bj :: tile indices |
58 |
C gridloc :: advar horizontal-grid location |
59 |
INTEGER i,j,k,bi,bj |
60 |
INTEGER gridloc |
61 |
LOGICAL wSign |
62 |
CEOP |
63 |
|
64 |
gridloc = vType/10 |
65 |
IF ( MOD(vType,10).LT.1 .OR. MOD(vType,10).GT.4 |
66 |
& .OR. gridloc.LT.1 .OR. gridloc.GT.4 ) THEN |
67 |
STOP 'ABNORMAL END: COPY_AD_UV_OUTP invalid vType' |
68 |
ENDIF |
69 |
wSign = MOD(vType,10).GE.3 |
70 |
|
71 |
IF ( MOD(vType,2).EQ.1 ) THEN |
72 |
DO bj = myByLo(myThid), myByHi(myThid) |
73 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
74 |
DO k=1,nNz |
75 |
DO j=1-OLy,sNy+OLy |
76 |
DO i=1-OLx,sNx+OLx |
77 |
uFldOut(i,j,k,bi,bj) = uFldRS(i,j,k,bi,bj) |
78 |
vFldOut(i,j,k,bi,bj) = vFldRS(i,j,k,bi,bj) |
79 |
ENDDO |
80 |
ENDDO |
81 |
ENDDO |
82 |
ENDDO |
83 |
ENDDO |
84 |
ELSE |
85 |
DO bj = myByLo(myThid), myByHi(myThid) |
86 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
87 |
DO k=1,nNz |
88 |
DO j=1-OLy,sNy+OLy |
89 |
DO i=1-OLx,sNx+OLx |
90 |
uFldOut(i,j,k,bi,bj) = uFldRL(i,j,k,bi,bj) |
91 |
vFldOut(i,j,k,bi,bj) = vFldRL(i,j,k,bi,bj) |
92 |
ENDDO |
93 |
ENDDO |
94 |
ENDDO |
95 |
ENDDO |
96 |
ENDDO |
97 |
ENDIF |
98 |
|
99 |
IF ( gridloc.EQ.1 ) THEN |
100 |
#ifdef AUTODIFF_TAMC_COMPATIBILITY |
101 |
c CALL ADEXCH_UV_AGRID_3D_RL( wSign,nNz,myThid, uFldOut,vFldOut ) |
102 |
#else |
103 |
c CALL ADEXCH_UV_AGRID_3D_RL( uFldOut,vFldOut, wSign,nNz,myThid ) |
104 |
#endif |
105 |
STOP 'ABNORMAL END: COPY_AD_UV_OUTP missing vType=11-14' |
106 |
ELSEIF ( gridloc.EQ.2 ) THEN |
107 |
#ifdef AUTODIFF_TAMC_COMPATIBILITY |
108 |
c CALL ADEXCH_UV_BGRID_3D_RL( wSign,nNz,myThid, uFldOut,vFldOut ) |
109 |
#else |
110 |
c CALL ADEXCH_UV_BGRID_3D_RL( uFldOut,vFldOut, wSign,nNz,myThid ) |
111 |
#endif |
112 |
STOP 'ABNORMAL END: COPY_AD_UV_OUTP missing vType=21-24' |
113 |
ELSEIF ( gridloc.EQ.3 ) THEN |
114 |
#ifdef AUTODIFF_TAMC_COMPATIBILITY |
115 |
CALL ADEXCH_UV_3D_RL( wSign,nNz,myThid, uFldOut,vFldOut ) |
116 |
#else |
117 |
CALL ADEXCH_UV_3D_RL( uFldOut,vFldOut, wSign,nNz,myThid ) |
118 |
#endif |
119 |
ELSEIF ( gridloc.EQ.4 ) THEN |
120 |
#ifdef AUTODIFF_TAMC_COMPATIBILITY |
121 |
c CALL ADEXCH_UV_DGRID_3D_RL( wSign,nNz,myThid, uFldOut,vFldOut ) |
122 |
#else |
123 |
c CALL ADEXCH_UV_DGRID_3D_RL( uFldOut,vFldOut, wSign,nNz,myThid ) |
124 |
#endif |
125 |
STOP 'ABNORMAL END: COPY_AD_UV_OUTP missing vType=41-44' |
126 |
ENDIF |
127 |
|
128 |
#endif /* ALLOW_ADJOINT_RUN or ALLOW_ADMTLM */ |
129 |
#endif /* ALLOW_AUTODIFF_MONITOR */ |
130 |
RETURN |
131 |
END |