7 |
C !ROUTINE: GRAD_SIGMA |
C !ROUTINE: GRAD_SIGMA |
8 |
C !INTERFACE: |
C !INTERFACE: |
9 |
SUBROUTINE GRAD_SIGMA( |
SUBROUTINE GRAD_SIGMA( |
10 |
I bi, bj, iMin, iMax, jMin, jMax, K, |
I bi, bj, iMin, iMax, jMin, jMax, k, |
11 |
I rhoK, sigKm1, sigKp1, |
I rhoK, sigKm1, sigKp1, |
12 |
O sigmaX, sigmaY, sigmaR, |
O sigmaX, sigmaY, sigmaR, |
13 |
I myThid ) |
I myThid ) |
14 |
C !DESCRIPTION: \bv |
C !DESCRIPTION: \bv |
15 |
C *==========================================================* |
C *==========================================================* |
16 |
C | SUBROUTINE CALC_ISOSLOPES |
C | SUBROUTINE GRAD_SIGMA |
17 |
C | o Calculate isoneutral gradients |
C | o Calculate isoneutral gradients |
18 |
C *==========================================================* |
C *==========================================================* |
19 |
C \ev |
C \ev |
20 |
|
|
22 |
IMPLICIT NONE |
IMPLICIT NONE |
23 |
C == Global variables == |
C == Global variables == |
24 |
#include "SIZE.h" |
#include "SIZE.h" |
|
#include "GRID.h" |
|
25 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
26 |
#include "PARAMS.h" |
#include "PARAMS.h" |
27 |
|
#include "GRID.h" |
28 |
|
|
29 |
C !INPUT/OUTPUT PARAMETERS: |
C !INPUT/OUTPUT PARAMETERS: |
30 |
C == Routine arguments == |
C == Routine arguments == |
31 |
|
C bi, bj :: tile indices |
32 |
|
C iMin,iMax :: not used |
33 |
|
C jMin,jMax :: not used |
34 |
|
C k :: current level index |
35 |
C rhoK :: density at level k |
C rhoK :: density at level k |
36 |
C sigKm1 :: upper level density computed at current pressure |
C sigKm1 :: upper level density computed at current pressure |
37 |
C sigKp1 :: lower level density computed at current pressure |
C sigKp1 :: lower level density computed at current pressure |
38 |
C sigmaX,Y,R :: iso-neutral gradient of density in 3 directions X,Y,R |
C sigmaX,Y,R :: iso-neutral gradient of density in 3 directions X,Y,R |
39 |
INTEGER bi,bj,iMin,iMax,jMin,jMax,K |
C myThid :: my Thread Id. number |
40 |
_RL rhoK(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
INTEGER bi,bj,iMin,iMax,jMin,jMax,k |
41 |
_RL sigKm1(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
_RL rhoK(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
42 |
_RL sigKp1(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
_RL sigKm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
43 |
_RL sigmaX(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL sigKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
44 |
_RL sigmaY(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL sigmaX(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
45 |
_RL sigmaR(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr) |
_RL sigmaY(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
46 |
|
_RL sigmaR(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
47 |
INTEGER myThid |
INTEGER myThid |
48 |
|
|
49 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
50 |
C == Local variables == |
C == Local variables == |
51 |
C rhoLoc :: local copy of rhoK |
C rhoLoc :: local copy of rhoK |
52 |
INTEGER i,j |
INTEGER i,j |
53 |
_RL rhoLoc(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
_RL rhoLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
54 |
CEOP |
CEOP |
55 |
|
|
56 |
C- safer to work on a local copy of rhoK (before a partial update) |
C- safer to work on a local copy of rhoK (before a partial update) |
57 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
58 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
59 |
rhoLoc(i,j) = rhoK(i,j) |
rhoLoc(i,j) = rhoK(i,j) |
60 |
ENDDO |
ENDDO |
61 |
ENDDO |
ENDDO |
62 |
|
|
63 |
C- Internal exchange for calculations in X |
C- Internal exchange for calculations in X |
64 |
#ifndef ALLOW_AUTODIFF_TAMC |
cph-exch2#ifndef ALLOW_AUTODIFF_TAMC |
65 |
IF ( useCubedSphereExchange ) THEN |
IF ( useCubedSphereExchange ) THEN |
66 |
CALL FILL_CS_CORNER_TR_RL( .TRUE., rhoLoc, bi,bj, myThid ) |
CALL FILL_CS_CORNER_TR_RL( 1, .FALSE., |
67 |
|
& rhoLoc, bi,bj, myThid ) |
68 |
ENDIF |
ENDIF |
69 |
#endif |
cph-exch2#endif |
70 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
71 |
DO i=1-Olx+1,sNx+Olx |
DO i=1-OLx+1,sNx+OLx |
72 |
sigmaX(i,j,k)=_maskW(i,j,k,bi,bj) |
sigmaX(i,j,k)=_maskW(i,j,k,bi,bj) |
73 |
& *_recip_dxC(i,j,bi,bj) |
& *_recip_dxC(i,j,bi,bj) |
74 |
& *(rhoLoc(i,j)-rhoLoc(i-1,j)) |
& *(rhoLoc(i,j)-rhoLoc(i-1,j)) |
76 |
ENDDO |
ENDDO |
77 |
|
|
78 |
C- Internal exchange for calculations in Y |
C- Internal exchange for calculations in Y |
79 |
#ifndef ALLOW_AUTODIFF_TAMC |
cph-exch2#ifndef ALLOW_AUTODIFF_TAMC |
80 |
IF ( useCubedSphereExchange ) THEN |
IF ( useCubedSphereExchange ) THEN |
81 |
CALL FILL_CS_CORNER_TR_RL( .FALSE., rhoLoc, bi,bj, myThid ) |
CALL FILL_CS_CORNER_TR_RL( 2, .FALSE., |
82 |
|
& rhoLoc, bi,bj, myThid ) |
83 |
ENDIF |
ENDIF |
84 |
#endif |
cph-exch2#endif |
85 |
DO j=1-Oly+1,sNy+Oly |
DO j=1-OLy+1,sNy+OLy |
86 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
87 |
sigmaY(i,j,k)=_maskS(i,j,k,bi,bj) |
sigmaY(i,j,k)=_maskS(i,j,k,bi,bj) |
88 |
& *_recip_dyC(i,j,bi,bj) |
& *_recip_dyC(i,j,bi,bj) |
89 |
& *(rhoLoc(i,j)-rhoLoc(i,j-1)) |
& *(rhoLoc(i,j)-rhoLoc(i,j-1)) |
90 |
ENDDO |
ENDDO |
91 |
ENDDO |
ENDDO |
92 |
|
|
93 |
C- jmc: Patrick, will this work for TAF ? |
IF (k.EQ.1) THEN |
94 |
IF (K.EQ.1) THEN |
DO j=1-OLy,sNy+OLy |
95 |
DO j=1-Oly,sNy+Oly |
DO i=1-OLx,sNx+OLx |
96 |
DO i=1-Olx,sNx+Olx |
sigmaR(i,j,k)= 0. _d 0 |
|
sigmaR(i,j,k)=0. |
|
97 |
ENDDO |
ENDDO |
98 |
ENDDO |
ENDDO |
99 |
ELSE |
ELSE |
100 |
DO j=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
101 |
DO i=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
102 |
sigmaR(i,j,k)= maskC(i,j,k,bi,bj) |
sigmaR(i,j,k)= maskC(i,j,k,bi,bj)*maskC(i,j,k-1,bi,bj) |
103 |
& *recip_drC(k)*rkFac |
& *recip_drC(k)*rkSign |
104 |
& *(sigKm1(i,j)-sigKp1(i,j)) |
& *(sigKp1(i,j)-sigKm1(i,j)) |
105 |
ENDDO |
ENDDO |
106 |
ENDDO |
ENDDO |
107 |
ENDIF |
ENDIF |
|
C- jmc: leave the old code commented (in case ...) |
|
|
c DO j=1-Oly,sNy+Oly |
|
|
c DO i=1-Olx,sNx+Olx |
|
|
c IF (K.NE.1 .AND. hfacC(i,j,k,bi,bj).NE.0.) THEN |
|
|
c sigmaR(i,j,k)=recip_drC(k)*rkFac*(sigKm1(i,j)-sigKp1(i,j)) |
|
|
c ELSE |
|
|
c sigmaR(i,j,k)=0. |
|
|
c ENDIF |
|
|
c ENDDO |
|
|
c ENDDO |
|
108 |
|
|
109 |
RETURN |
RETURN |
110 |
END |
END |