1 |
C $Header: /u/gcmpack/MITgcm/model/src/grad_sigma.F,v 1.9 2008/10/22 00:26:20 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: GRAD_SIGMA |
8 |
C !INTERFACE: |
9 |
SUBROUTINE GRAD_SIGMA( |
10 |
I bi, bj, iMin, iMax, jMin, jMax, k, |
11 |
I rhoK, sigKm1, sigKp1, |
12 |
O sigmaX, sigmaY, sigmaR, |
13 |
I myThid ) |
14 |
C !DESCRIPTION: \bv |
15 |
C *==========================================================* |
16 |
C | SUBROUTINE GRAD_SIGMA |
17 |
C | o Calculate isoneutral gradients |
18 |
C *==========================================================* |
19 |
C \ev |
20 |
|
21 |
C !USES: |
22 |
IMPLICIT NONE |
23 |
C == Global variables == |
24 |
#include "SIZE.h" |
25 |
#include "EEPARAMS.h" |
26 |
#include "PARAMS.h" |
27 |
#include "GRID.h" |
28 |
|
29 |
C !INPUT/OUTPUT PARAMETERS: |
30 |
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 |
36 |
C sigKm1 :: upper level density computed at current pressure |
37 |
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 |
39 |
C myThid :: my Thread Id. number |
40 |
INTEGER bi,bj,iMin,iMax,jMin,jMax,k |
41 |
_RL rhoK(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
42 |
_RL sigKm1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
43 |
_RL sigKp1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
44 |
_RL sigmaX(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr) |
45 |
_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 |
48 |
|
49 |
C !LOCAL VARIABLES: |
50 |
C == Local variables == |
51 |
C rhoLoc :: local copy of rhoK |
52 |
INTEGER i,j |
53 |
_RL rhoLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
54 |
CEOP |
55 |
|
56 |
C- safer to work on a local copy of rhoK (before a partial update) |
57 |
DO j=1-OLy,sNy+OLy |
58 |
DO i=1-OLx,sNx+OLx |
59 |
rhoLoc(i,j) = rhoK(i,j) |
60 |
ENDDO |
61 |
ENDDO |
62 |
|
63 |
C- Internal exchange for calculations in X |
64 |
cph-exch2#ifndef ALLOW_AUTODIFF_TAMC |
65 |
IF ( useCubedSphereExchange ) THEN |
66 |
CALL FILL_CS_CORNER_TR_RL( 1, .FALSE., |
67 |
& rhoLoc, bi,bj, myThid ) |
68 |
ENDIF |
69 |
cph-exch2#endif |
70 |
DO j=1-OLy,sNy+OLy |
71 |
DO i=1-OLx+1,sNx+OLx |
72 |
sigmaX(i,j,k)=_maskW(i,j,k,bi,bj) |
73 |
& *_recip_dxC(i,j,bi,bj) |
74 |
& *(rhoLoc(i,j)-rhoLoc(i-1,j)) |
75 |
ENDDO |
76 |
ENDDO |
77 |
|
78 |
C- Internal exchange for calculations in Y |
79 |
cph-exch2#ifndef ALLOW_AUTODIFF_TAMC |
80 |
IF ( useCubedSphereExchange ) THEN |
81 |
CALL FILL_CS_CORNER_TR_RL( 2, .FALSE., |
82 |
& rhoLoc, bi,bj, myThid ) |
83 |
ENDIF |
84 |
cph-exch2#endif |
85 |
DO j=1-OLy+1,sNy+OLy |
86 |
DO i=1-OLx,sNx+OLx |
87 |
sigmaY(i,j,k)=_maskS(i,j,k,bi,bj) |
88 |
& *_recip_dyC(i,j,bi,bj) |
89 |
& *(rhoLoc(i,j)-rhoLoc(i,j-1)) |
90 |
ENDDO |
91 |
ENDDO |
92 |
|
93 |
IF (k.EQ.1) THEN |
94 |
DO j=1-OLy,sNy+OLy |
95 |
DO i=1-OLx,sNx+OLx |
96 |
sigmaR(i,j,k)= 0. _d 0 |
97 |
ENDDO |
98 |
ENDDO |
99 |
ELSE |
100 |
DO j=1-OLy,sNy+OLy |
101 |
DO i=1-OLx,sNx+OLx |
102 |
sigmaR(i,j,k)= maskC(i,j,k,bi,bj)*maskC(i,j,k-1,bi,bj) |
103 |
& *recip_drC(k)*rkSign |
104 |
& *(sigKp1(i,j)-sigKm1(i,j)) |
105 |
ENDDO |
106 |
ENDDO |
107 |
ENDIF |
108 |
|
109 |
RETURN |
110 |
END |