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

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

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


Revision 1.11 - (show annotations) (download)
Thu Mar 8 20:21:34 2001 UTC (23 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: pre38tag1, pre38-close, checkpoint37
Branch point for: pre38
Changes since 1.10: +14 -15 lines
change units of PhiHyd (ocean) to have unified units for all potential Phi

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/calc_phi_hyd.F,v 1.10 2001/02/04 14:38:46 cnh Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
6 SUBROUTINE CALC_PHI_HYD(
7 I bi, bj, iMin, iMax, jMin, jMax, K,
8 I theta, salt,
9 U phiHyd,
10 I myThid)
11 C /==========================================================\
12 C | SUBROUTINE CALC_PHI_HYD |
13 C | o Integrate the hydrostatic relation to find the Hydros. |
14 C | Potential (ocean: Pressure/rho ; atmos = geopotential)|
15 C | On entry: |
16 C | theta,salt are the current thermodynamics quantities|
17 C | (unchanged on exit) |
18 C | phiHyd(i,j,1:k-1) is the hydrostatic Potential |
19 C | at cell centers (tracer points) |
20 C | - 1:k-1 layers are valid |
21 C | - k:Nr layers are invalid |
22 C | phiHyd(i,j,k) is the hydrostatic Potential |
23 C | at cell the interface k (w point above) |
24 C | On exit: |
25 C | phiHyd(i,j,1:k) is the hydrostatic Potential |
26 C | at cell centers (tracer points) |
27 C | - 1:k layers are valid |
28 C | - k+1:Nr layers are invalid |
29 C | phiHyd(i,j,k+1) is the hydrostatic Potential (P/rho) |
30 C | at cell the interface k+1 (w point below)|
31 C | |
32 C \==========================================================/
33 IMPLICIT NONE
34 C == Global variables ==
35 #include "SIZE.h"
36 #include "GRID.h"
37 #include "EEPARAMS.h"
38 #include "PARAMS.h"
39 C == Routine arguments ==
40 INTEGER bi,bj,iMin,iMax,jMin,jMax,K
41 _RL theta(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
42 _RL salt(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
43 _RL phiHyd(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
44 INTEGER myThid
45
46 #ifdef INCLUDE_PHIHYD_CALCULATION_CODE
47
48 C == Local variables ==
49 INTEGER i,j
50 _RL alphaRho(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
51 _RL dRloc,dRlocKp1
52 _RL ddRm1, ddRp1, ddRm, ddRp
53 _RL atm_cp, atm_kappa, atm_po
54
55 IF ( buoyancyRelation .eq. 'OCEANIC' ) THEN
56 C This is the hydrostatic pressure calculation for the Ocean
57 C which uses the FIND_RHO() routine to calculate density
58 C before integrating g*rho over the current layer/interface
59
60 dRloc=drC(k)
61 IF (k.EQ.1) dRloc=drF(1)
62 IF (k.EQ.Nr) THEN
63 dRlocKp1=0.
64 ELSE
65 dRlocKp1=drC(k+1)
66 ENDIF
67
68 C-- If this is the top layer we impose the boundary condition
69 C P(z=eta) = P(atmospheric_loading)
70 IF (k.EQ.1) THEN
71 DO j=jMin,jMax
72 DO i=iMin,iMax
73 C *NOTE* The loading should go here but has not been implemented yet
74 phiHyd(i,j,k)=0.
75 ENDDO
76 ENDDO
77 ENDIF
78
79 C Calculate density
80 CALL FIND_RHO( bi, bj, iMin, iMax, jMin, jMax, k, k, eosType,
81 & theta, salt,
82 & alphaRho, myThid)
83
84 C Hydrostatic pressure at cell centers
85 DO j=jMin,jMax
86 DO i=iMin,iMax
87 #ifdef ALLOW_AUTODIFF_TAMC
88 Is this directive correct or even necessary in this new code?
89 CADJ GENERAL
90 #endif /* ALLOW_AUTODIFF_TAMC */
91
92 C---------- This discretization is the "finite volume" form
93 C which has not been used to date since it does not
94 C conserve KE+PE exactly even though it is more natural
95 C
96 c IF (k.LT.Nr) phiHyd(i,j,k+1)=phiHyd(i,j,k)+
97 c & drF(K)*gravity*alphaRho(i,j)*recip_rhoConst
98 c phiHyd(i,j,k)=phiHyd(i,j,k)+
99 c & 0.5*drF(K)*gravity*alphaRho(i,j)*recip_rhoConst
100 C-----------------------------------------------------------------------
101
102 C---------- This discretization is the "energy conserving" form
103 C which has been used since at least Adcroft et al., MWR 1997
104 C
105 phiHyd(i,j,k)=phiHyd(i,j,k)+
106 & 0.5*dRloc*gravity*alphaRho(i,j)*recip_rhoConst
107 IF (k.LT.Nr) phiHyd(i,j,k+1)=phiHyd(i,j,k)+
108 & 0.5*dRlocKp1*gravity*alphaRho(i,j)*recip_rhoConst
109 C-----------------------------------------------------------------------
110 ENDDO
111 ENDDO
112
113
114
115 ELSEIF ( buoyancyRelation .eq. 'ATMOSPHERIC' ) THEN
116 C This is the hydrostatic geopotential calculation for the Atmosphere
117 C The ideal gas law is used implicitly here rather than calculating
118 C the specific volume, analogous to the oceanic case.
119
120 C Integrate d Phi / d pi
121
122 C *NOTE* These constants should be in the data file and PARAMS.h
123 atm_cp=1004. _d 0
124 atm_kappa=2. _d 0/7. _d 0
125 atm_po=1. _d 5
126 IF (K.EQ.1) THEN
127 ddRp1=atm_cp*( ((rC(K)/atm_po)**atm_kappa)
128 & -((rF(K)/atm_po)**atm_kappa) )
129 DO j=jMin,jMax
130 DO i=iMin,iMax
131 ddRp=ddRp1
132 IF (hFacC(I,J, K ,bi,bj).EQ.0.) ddRp=0.
133 C------------ The integration for the first level phi(k=1) is the
134 C same for both the "finite volume" and energy conserving
135 C methods.
136 C *NOTE* The geopotential boundary condition should go
137 C here but has not been implemented yet
138 phiHyd(i,j,K)=0.
139 & -ddRp*(theta(I,J,K,bi,bj)-tRef(K))
140 C-----------------------------------------------------------------------
141 ENDDO
142 ENDDO
143 ELSE
144
145 C-------- This discretization is the "finite volume" form which
146 C integrates the hydrostatic equation of each half/sub-layer.
147 C This seems most natural and could easily allow for lopped cells
148 C by replacing rF(K) with the height of the surface (not implemented).
149 C in the lower layers (e.g. at k=1).
150 C
151 c ddRm1=atm_cp*( ((rF( K )/atm_po)**atm_kappa)
152 c & -((rC(K-1)/atm_po)**atm_kappa) )
153 c ddRp1=atm_cp*( ((rC( K )/atm_po)**atm_kappa)
154 c & -((rF( K )/atm_po)**atm_kappa) )
155 C-----------------------------------------------------------------------
156
157
158 C-------- This discretization is the energy conserving form
159 ddRp1=atm_cp*( ((rC( K )/atm_po)**atm_kappa)
160 & -((rC(K-1)/atm_po)**atm_kappa) )*0.5
161 ddRm1=ddRp1
162 C-----------------------------------------------------------------------
163
164 DO j=jMin,jMax
165 DO i=iMin,iMax
166 ddRp=ddRp1
167 ddRm=ddRm1
168 IF (hFacC(I,J, K ,bi,bj).EQ.0.) ddRp=0.
169 IF (hFacC(I,J,K-1,bi,bj).EQ.0.) ddRm=0.
170 phiHyd(i,j,K)=phiHyd(i,j,K-1)
171 & -( ddRm*(theta(I,J,K-1,bi,bj)-tRef(K-1))
172 & +ddRp*(theta(I,J, K ,bi,bj)-tRef( K )) )
173 C Old code (atmos-exact) looked like this
174 Cold phiHyd(i,j,K)=phiHyd(i,j,K-1) - ddRm1*
175 Cold & (theta(I,J,K-1,bi,bj)+theta(I,J,K,bi,bj)-2.*tRef(K))
176 ENDDO
177 ENDDO
178 ENDIF
179
180
181 ELSE
182 STOP 'CALC_PHI_HYD: We should never reach this point!'
183 ENDIF
184
185 #endif
186
187 RETURN
188 END

  ViewVC Help
Powered by ViewVC 1.1.22