/[MITgcm]/MITgcm/model/src/calc_grad_phi_hyd.F
ViewVC logotype

Contents of /MITgcm/model/src/calc_grad_phi_hyd.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.12 - (show annotations) (download)
Fri May 14 23:21:02 2010 UTC (14 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62g, checkpoint62j, checkpoint62i, checkpoint62h
Changes since 1.11: +7 -1 lines
move initialisation of dPhiHydX,dPhiHydY (= output of S/R CALC_GRAD_PHI_HYD)
 from dynamics.F to calc_grad_phi_hyd.F

1 C $Header: /u/gcmpack/MITgcm/model/src/calc_grad_phi_hyd.F,v 1.11 2010/03/16 00:08:27 jmc Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: CALC_GRAD_PHI_HYD
8 C !INTERFACE:
9 SUBROUTINE CALC_GRAD_PHI_HYD(
10 I k, bi, bj, iMin,iMax, jMin,jMax,
11 I phiHydC, alphRho, tFld, sFld,
12 O dPhiHydX, dPhiHydY,
13 I myTime, myIter, myThid)
14 C !DESCRIPTION: \bv
15 C *==========================================================*
16 C | S/R CALC_GRAD_PHI_HYD
17 C | o Calculate the gradient of Hydrostatic potential anomaly
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 #include "SURFACE.h"
29 #include "DYNVARS.h"
30
31 C !INPUT/OUTPUT PARAMETERS:
32 C == Routine Arguments ==
33 C bi,bj :: tile index
34 C iMin,iMax,jMin,jMax :: Loop counters
35 C phiHydC :: Hydrostatic Potential anomaly
36 C (atmos: =Geopotential ; ocean-z: =Pressure/rho)
37 C alphRho :: Density (z-coord) or specific volume (p-coord)
38 C tFld :: Potential temp.
39 C sFld :: Salinity
40 C dPhiHydX,Y :: Gradient (X & Y directions) of Hyd. Potential
41 C myTime :: Current time
42 C myIter :: Current iteration number
43 C myThid :: Instance number for this call of the routine.
44 INTEGER k, bi,bj, iMin,iMax, jMin,jMax
45 _RL phiHydC(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
46 _RL alphRho(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
47 _RL tFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
48 _RL sFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
49 _RL dPhiHydX(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
50 _RL dPhiHydY(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
51 _RL myTime
52 INTEGER myIter, myThid
53
54 #ifdef INCLUDE_PHIHYD_CALCULATION_CODE
55
56 C !LOCAL VARIABLES:
57 C == Local variables ==
58 C i,j :: Loop counters
59 INTEGER i,j
60 _RL varLoc(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
61 #ifdef NONLIN_FRSURF
62 _RL factorZ, factorP, conv_theta2T
63 _RL factPI
64 CHARACTER*(MAX_LEN_MBUF) msgBuf
65 #endif
66 CEOP
67
68 #ifdef NONLIN_FRSURF
69 IF (select_rStar.GE.2 .AND. nonlinFreeSurf.GE.4 ) THEN
70 # ifndef DISABLE_RSTAR_CODE
71 C- Integral of b.dr = rStarFac * Integral of b.dr* :
72 C and will add later (select_rStar=2) the contribution of
73 C the slope of the r* coordinate.
74 IF ( buoyancyRelation .EQ. 'ATMOSPHERIC' ) THEN
75 C- Consistent with Phi'= Integr[ theta'.dPi ] :
76 DO j=jMin,jMax
77 DO i=iMin,iMax
78 varLoc(i,j) = phiHydC(i,j)*rStarFacC(i,j,bi,bj)**atm_kappa
79 & + phi0surf(i,j,bi,bj)
80 ENDDO
81 ENDDO
82 ELSE
83 DO j=jMin,jMax
84 DO i=iMin,iMax
85 varLoc(i,j) = phiHydC(i,j)*rStarFacC(i,j,bi,bj)
86 & + phi0surf(i,j,bi,bj)
87 ENDDO
88 ENDDO
89 ENDIF
90 ELSEIF (select_rStar.GE.1 .AND. nonlinFreeSurf.GE.4 ) THEN
91 C- Integral of b.dr but scaled to correspond to a fixed r-level (=r*)
92 C no contribution of the slope of the r* coordinate (select_rStar=1)
93 IF ( buoyancyRelation .EQ. 'ATMOSPHERIC' ) THEN
94 C- Consistent with Phi'= Integr[ theta'.dPi ] :
95 DO j=jMin,jMax
96 DO i=iMin,iMax
97 IF (Ro_surf(i,j,bi,bj).EQ.rC(k)) THEN
98 factPI=atm_Cp*( ((etaH(i,j,bi,bj)+rC(k))/atm_Po)**atm_kappa
99 & -( rC(k) /atm_Po)**atm_kappa
100 & )
101 varLoc(i,j) = factPI*alphRho(i,j)
102 ELSEIF (Ro_surf(i,j,bi,bj).NE.0. _d 0) THEN
103 factPI = (rC(k)/Ro_surf(i,j,bi,bj))**atm_kappa
104 varLoc(i,j) = phiHydC(i,j)
105 & *(rStarFacC(i,j,bi,bj)**atm_kappa - factPI)
106 & /(1. _d 0 -factPI)
107 & + phi0surf(i,j,bi,bj)
108 ENDIF
109 ENDDO
110 ENDDO
111 ELSE
112 DO j=jMin,jMax
113 DO i=iMin,iMax
114 IF (Ro_surf(i,j,bi,bj).EQ.rC(k)) THEN
115 WRITE(msgBuf,'(3A)') 'CALC_GRAD_PHI_HYD: ',
116 & 'Problem when Ro_surf=rC',
117 & ' with select_rStar,integr_GeoPot=1,4'
118 CALL PRINT_ERROR( msgBuf , myThid)
119 STOP 'CALC_GRAD_PHI_HYD: Pb in r* options implementation'
120 ELSE
121 varLoc(i,j) = phiHydC(i,j)
122 & *(etaH(i,j,bi,bj)+Ro_surf(i,j,bi,bj)-rC(k))
123 & / (Ro_surf(i,j,bi,bj)-rC(k))
124 & + phi0surf(i,j,bi,bj)
125 ENDIF
126 ENDDO
127 ENDDO
128 ENDIF
129 # endif /* DISABLE_RSTAR_CODE */
130 ELSE
131 #else /* NONLIN_FRSURF */
132 IF (.TRUE.) THEN
133 #endif /* NONLIN_FRSURF */
134 DO j=jMin,jMax
135 DO i=iMin,iMax
136 varLoc(i,j) = phiHydC(i,j)+phi0surf(i,j,bi,bj)
137 ENDDO
138 ENDDO
139 ENDIF
140
141 C-- Zonal & Meridional gradient of potential anomaly
142 DO j=1-OLy,sNy+OLy
143 DO i=1-OLx,sNx+OLx
144 dPhiHydX(i,j) = 0. _d 0
145 dPhiHydY(i,j) = 0. _d 0
146 ENDDO
147 ENDDO
148 DO j=jMin,jMax
149 DO i=iMin+1,iMax
150 dPhiHydX(i,j) = _recip_dxC(i,j,bi,bj)*recip_deepFacC(k)
151 & *( varLoc(i,j)-varLoc(i-1,j) )*recip_rhoFacC(k)
152 ENDDO
153 ENDDO
154 DO j=jMin+1,jMax
155 DO i=iMin,iMax
156 dPhiHydY(i,j) = _recip_dyC(i,j,bi,bj)*recip_deepFacC(k)
157 & *( varLoc(i,j)-varLoc(i,j-1) )*recip_rhoFacC(k)
158 ENDDO
159 ENDDO
160
161 #ifdef NONLIN_FRSURF
162 IF (select_rStar.GE.2 .AND. nonlinFreeSurf.GE.1 ) THEN
163 IF ( buoyancyRelation .EQ. 'OCEANIC' ) THEN
164 C-- z* coordinate slope term: rho_prime/rho0 * Grad_r(g.z)
165 factorZ = gravity*recip_rhoConst*recip_rhoFacC(k)*0.5 _d 0
166 DO j=jMin,jMax
167 DO i=iMin,iMax
168 varLoc(i,j) = etaH(i,j,bi,bj)
169 & *(1. _d 0 + rC(k)*recip_Rcol(i,j,bi,bj))
170 ENDDO
171 ENDDO
172 DO j=jMin,jMax
173 DO i=iMin+1,iMax
174 dPhiHydX(i,j) = dPhiHydX(i,j)
175 & +factorZ*(alphRho(i-1,j)+alphRho(i,j))
176 & *(varLoc(i,j)-varLoc(i-1,j))
177 & *recip_dxC(i,j,bi,bj)*recip_deepFacC(k)
178 ENDDO
179 ENDDO
180 DO j=jMin+1,jMax
181 DO i=iMin,iMax
182 dPhiHydY(i,j) = dPhiHydY(i,j)
183 & +factorZ*(alphRho(i,j-1)+alphRho(i,j))
184 & *(varLoc(i,j)-varLoc(i,j-1))
185 & *recip_dyC(i,j,bi,bj)*recip_deepFacC(k)
186 ENDDO
187 ENDDO
188 ELSEIF (buoyancyRelation .EQ. 'OCEANICP' ) THEN
189 C-- p* coordinate slope term: alpha_prime * Grad_r( p )
190 factorP = 0.5 _d 0
191 DO j=jMin,jMax
192 DO i=iMin+1,iMax
193 dPhiHydX(i,j) = dPhiHydX(i,j)
194 & +factorP*(alphRho(i-1,j)+alphRho(i,j))
195 & *(rStarFacC(i,j,bi,bj)-rStarFacC(i-1,j,bi,bj))
196 & *rC(k)*recip_dxC(i,j,bi,bj)*recip_deepFacC(k)
197 ENDDO
198 ENDDO
199 DO j=jMin+1,jMax
200 DO i=iMin,iMax
201 dPhiHydY(i,j) = dPhiHydY(i,j)
202 & +factorP*(alphRho(i,j-1)+alphRho(i,j))
203 & *(rStarFacC(i,j,bi,bj)-rStarFacC(i,j-1,bi,bj))
204 & *rC(k)*recip_dyC(i,j,bi,bj)*recip_deepFacC(k)
205 ENDDO
206 ENDDO
207 ELSEIF ( buoyancyRelation .EQ. 'ATMOSPHERIC' ) THEN
208 C-- p* coordinate slope term: alpha_prime * Grad_r( p )
209 conv_theta2T = (rC(k)/atm_Po)**atm_kappa
210 factorP = (atm_Rd/rC(k))*conv_theta2T*0.5 _d 0
211 DO j=jMin,jMax
212 DO i=iMin+1,iMax
213 dPhiHydX(i,j) = dPhiHydX(i,j)
214 & +factorP*(alphRho(i-1,j)+alphRho(i,j))
215 & *(rStarFacC(i,j,bi,bj)-rStarFacC(i-1,j,bi,bj))
216 & *rC(k)*recip_dxC(i,j,bi,bj)*recip_deepFacC(k)
217 ENDDO
218 ENDDO
219 DO j=jMin+1,jMax
220 DO i=iMin,iMax
221 dPhiHydY(i,j) = dPhiHydY(i,j)
222 & +factorP*(alphRho(i,j-1)+alphRho(i,j))
223 & *(rStarFacC(i,j,bi,bj)-rStarFacC(i,j-1,bi,bj))
224 & *rC(k)*recip_dyC(i,j,bi,bj)*recip_deepFacC(k)
225 ENDDO
226 ENDDO
227 ENDIF
228 ENDIF
229 #endif /* NONLIN_FRSURF */
230
231 #endif /* INCLUDE_PHIHYD_CALCULATION_CODE */
232
233 RETURN
234 END

  ViewVC Help
Powered by ViewVC 1.1.22