/[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.10 - (show annotations) (download)
Sun Feb 4 14:38:46 2001 UTC (23 years, 3 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint36, checkpoint35
Changes since 1.9: +2 -1 lines
Made sure each .F and .h file had
the CVS keywords Header and Name at its start.
Most had header but very few currently have Name, so
lots of changes!

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/calc_phi_hyd.F,v 1.9 2001/02/02 21:04:47 adcroft 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 phiHyd. |
14 C | |
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 pressure/geopot. |
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 pressure/geop. |
23 C | at cell the interface k (w point above) |
24 C | On exit: |
25 C | phiHyd(i,j,1:k) is the hydrostatic pressure/geopot. |
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 pressure/geop. |
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)
98 c phiHyd(i,j,k)=phiHyd(i,j,k)+
99 c & 0.5*drF(K)*gravity*alphaRho(i,j)
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)
107 IF (k.LT.Nr) phiHyd(i,j,k+1)=phiHyd(i,j,k)+
108 & 0.5*dRlocKp1*gravity*alphaRho(i,j)
109 C-----------------------------------------------------------------------
110 ENDDO
111 ENDDO
112
113
114
115
116 ELSEIF ( buoyancyRelation .eq. 'ATMOSPHERIC' ) THEN
117 C This is the hydrostatic geopotential calculation for the Atmosphere
118 C The ideal gas law is used implicitly here rather than calculating
119 C the specific volume, analogous to the oceanic case.
120
121 C Integrate d Phi / d pi
122
123 C *NOTE* These constants should be in the data file and PARAMS.h
124 atm_cp=1004. _d 0
125 atm_kappa=2. _d 0/7. _d 0
126 atm_po=1. _d 5
127 IF (K.EQ.1) THEN
128 ddRp1=atm_cp*( ((rC(K)/atm_po)**atm_kappa)
129 & -((rF(K)/atm_po)**atm_kappa) )
130 DO j=jMin,jMax
131 DO i=iMin,iMax
132 ddRp=ddRp1
133 IF (hFacC(I,J, K ,bi,bj).EQ.0.) ddRp=0.
134 C------------ The integration for the first level phi(k=1) is the
135 C same for both the "finite volume" and energy conserving
136 C methods.
137 C *NOTE* The geopotential boundary condition should go
138 C here but has not been implemented yet
139 phiHyd(i,j,K)=0.
140 & -ddRp*(theta(I,J,K,bi,bj)-tRef(K))
141 C-----------------------------------------------------------------------
142 ENDDO
143 ENDDO
144 ELSE
145
146 C-------- This discretization is the "finite volume" form which
147 C integrates the hydrostatic equation of each half/sub-layer.
148 C This seems most natural and could easily allow for lopped cells
149 C by replacing rF(K) with the height of the surface (not implemented).
150 C in the lower layers (e.g. at k=1).
151 C
152 c ddRm1=atm_cp*( ((rF( K )/atm_po)**atm_kappa)
153 c & -((rC(K-1)/atm_po)**atm_kappa) )
154 c ddRp1=atm_cp*( ((rC( K )/atm_po)**atm_kappa)
155 c & -((rF( K )/atm_po)**atm_kappa) )
156 C-----------------------------------------------------------------------
157
158
159 C-------- This discretization is the energy conserving form
160 ddRp1=atm_cp*( ((rC( K )/atm_po)**atm_kappa)
161 & -((rC(K-1)/atm_po)**atm_kappa) )*0.5
162 ddRm1=ddRp1
163 C-----------------------------------------------------------------------
164
165 DO j=jMin,jMax
166 DO i=iMin,iMax
167 ddRp=ddRp1
168 ddRm=ddRm1
169 IF (hFacC(I,J, K ,bi,bj).EQ.0.) ddRp=0.
170 IF (hFacC(I,J,K-1,bi,bj).EQ.0.) ddRm=0.
171 phiHyd(i,j,K)=phiHyd(i,j,K-1)
172 & -( ddRm*(theta(I,J,K-1,bi,bj)-tRef(K-1))
173 & +ddRp*(theta(I,J, K ,bi,bj)-tRef( K )) )
174 C Old code (atmos-exact) looked like this
175 Cold phiHyd(i,j,K)=phiHyd(i,j,K-1) - ddRm1*
176 Cold & (theta(I,J,K-1,bi,bj)+theta(I,J,K,bi,bj)-2.*tRef(K))
177 ENDDO
178 ENDDO
179 ENDIF
180
181
182 ELSE
183 STOP 'CALC_PHI_HYD: We should never reach this point!'
184 ENDIF
185
186 #endif
187
188 return
189 end

  ViewVC Help
Powered by ViewVC 1.1.22