1 | MODULE eqn_state_seawater_mod |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! First constant in array den also defined as type double |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: eqn_state_seawater.f90 336 2009-06-10 11:19:35Z heinze $ |
---|
11 | ! |
---|
12 | ! 97 2007-06-21 08:23:15Z raasch |
---|
13 | ! Initial revision |
---|
14 | ! |
---|
15 | ! |
---|
16 | ! Description: |
---|
17 | ! ------------ |
---|
18 | ! Equation of state for seawater as a function of potential temperature, |
---|
19 | ! salinity, and pressure. |
---|
20 | ! For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. |
---|
21 | ! eqn_state_seawater calculates the potential density referred at hyp(0). |
---|
22 | ! eqn_state_seawater_func calculates density. |
---|
23 | !------------------------------------------------------------------------------! |
---|
24 | |
---|
25 | IMPLICIT NONE |
---|
26 | |
---|
27 | PRIVATE |
---|
28 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
29 | |
---|
30 | REAL, DIMENSION(12), PARAMETER :: nom = & |
---|
31 | (/ 9.9984085444849347D2, 7.3471625860981584D0, & |
---|
32 | -5.3211231792841769D-2, 3.6492439109814549D-4, & |
---|
33 | 2.5880571023991390D0, -6.7168282786692354D-3, & |
---|
34 | 1.9203202055760151D-3, 1.1798263740430364D-2, & |
---|
35 | 9.8920219266399117D-8, 4.6996642771754730D-6, & |
---|
36 | -2.5862187075154352D-8, -3.2921414007960662D-12 /) |
---|
37 | |
---|
38 | REAL, DIMENSION(13), PARAMETER :: den = & |
---|
39 | (/ 1.0D0, 7.2815210113327091D-3, & |
---|
40 | -4.4787265461983921D-5, 3.3851002965802430D-7, & |
---|
41 | 1.3651202389758572D-10, 1.7632126669040377D-3, & |
---|
42 | -8.8066583251206474D-6, -1.8832689434804897D-10, & |
---|
43 | 5.7463776745432097D-6, 1.4716275472242334D-9, & |
---|
44 | 6.7103246285651894D-6, -2.4461698007024582D-17, & |
---|
45 | -9.1534417604289062D-18 /) |
---|
46 | |
---|
47 | INTERFACE eqn_state_seawater |
---|
48 | MODULE PROCEDURE eqn_state_seawater |
---|
49 | MODULE PROCEDURE eqn_state_seawater_ij |
---|
50 | END INTERFACE eqn_state_seawater |
---|
51 | |
---|
52 | INTERFACE eqn_state_seawater_func |
---|
53 | MODULE PROCEDURE eqn_state_seawater_func |
---|
54 | END INTERFACE eqn_state_seawater_func |
---|
55 | |
---|
56 | CONTAINS |
---|
57 | |
---|
58 | |
---|
59 | !------------------------------------------------------------------------------! |
---|
60 | ! Call for all grid points |
---|
61 | !------------------------------------------------------------------------------! |
---|
62 | SUBROUTINE eqn_state_seawater |
---|
63 | |
---|
64 | USE arrays_3d |
---|
65 | USE indices |
---|
66 | |
---|
67 | IMPLICIT NONE |
---|
68 | |
---|
69 | INTEGER :: i, j, k |
---|
70 | |
---|
71 | REAL :: p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, sa2 |
---|
72 | |
---|
73 | DO i = nxl, nxr |
---|
74 | DO j = nys, nyn |
---|
75 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
76 | ! |
---|
77 | !-- Pressure is needed in dbar |
---|
78 | ! p1 = hyp(0) * 1E-4 |
---|
79 | ! p1 = 0.0 |
---|
80 | p1 = hyp(k) * 1E-4 |
---|
81 | p2 = p1 * p1 |
---|
82 | p3 = p2 * p1 |
---|
83 | |
---|
84 | ! |
---|
85 | !-- Temperature needed in degree Celsius |
---|
86 | pt1 = pt_p(k,j,i) - 273.15 |
---|
87 | pt2 = pt1 * pt1 |
---|
88 | pt3 = pt1 * pt2 |
---|
89 | pt4 = pt2 * pt2 |
---|
90 | |
---|
91 | sa1 = sa_p(k,j,i) |
---|
92 | sa15 = sa1 * SQRT( sa1 ) |
---|
93 | sa2 = sa1 * sa1 |
---|
94 | |
---|
95 | rho(k,j,i) = & |
---|
96 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
97 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
98 | nom(7)*sa2 + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
99 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
100 | ) / & |
---|
101 | ( den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
102 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
103 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
104 | den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
105 | den(13)*p3*pt1 & |
---|
106 | ) |
---|
107 | |
---|
108 | ENDDO |
---|
109 | ! |
---|
110 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
111 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
112 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
113 | ENDDO |
---|
114 | ENDDO |
---|
115 | |
---|
116 | END SUBROUTINE eqn_state_seawater |
---|
117 | |
---|
118 | |
---|
119 | !------------------------------------------------------------------------------! |
---|
120 | ! Call for grid point i,j |
---|
121 | !------------------------------------------------------------------------------! |
---|
122 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
123 | |
---|
124 | USE arrays_3d |
---|
125 | USE indices |
---|
126 | |
---|
127 | IMPLICIT NONE |
---|
128 | |
---|
129 | INTEGER :: i, j, k |
---|
130 | |
---|
131 | REAL :: p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, sa2 |
---|
132 | |
---|
133 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
134 | ! |
---|
135 | !-- Pressure is needed in dbar |
---|
136 | ! p1 = hyp(0) * 1E-4 |
---|
137 | ! p1 = 0.0 |
---|
138 | p1 = hyp(k) * 1E-4 |
---|
139 | p2 = p1 * p1 |
---|
140 | p3 = p2 * p1 |
---|
141 | |
---|
142 | ! |
---|
143 | !-- Temperature needed in degree Celsius |
---|
144 | pt1 = pt_p(k,j,i) - 273.15 |
---|
145 | pt2 = pt1 * pt1 |
---|
146 | pt3 = pt1 * pt2 |
---|
147 | pt4 = pt2 * pt2 |
---|
148 | |
---|
149 | sa1 = sa_p(k,j,i) |
---|
150 | sa15 = sa1 * SQRT( sa1 ) |
---|
151 | sa2 = sa1 * sa1 |
---|
152 | |
---|
153 | rho(k,j,i) = ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
154 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
155 | nom(7)*sa2 + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
156 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
157 | ) / & |
---|
158 | ( den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
159 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
160 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
161 | den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
162 | den(13)*p3*pt1 & |
---|
163 | ) |
---|
164 | ENDDO |
---|
165 | ! |
---|
166 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
167 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
168 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
169 | |
---|
170 | END SUBROUTINE eqn_state_seawater_ij |
---|
171 | |
---|
172 | |
---|
173 | !------------------------------------------------------------------------------! |
---|
174 | ! Equation of state as a function |
---|
175 | !------------------------------------------------------------------------------! |
---|
176 | REAL FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
177 | |
---|
178 | IMPLICIT NONE |
---|
179 | |
---|
180 | REAL :: p, p1, p2, p3, pt, pt1, pt2, pt3, pt4, sa, sa15, sa2 |
---|
181 | |
---|
182 | ! |
---|
183 | !-- Pressure is needed in dbar |
---|
184 | p1 = p * 1E-4 |
---|
185 | p2 = p1 * p1 |
---|
186 | p3 = p2 * p1 |
---|
187 | |
---|
188 | ! |
---|
189 | !-- Temperature needed in degree Celsius |
---|
190 | pt1 = pt - 273.15 |
---|
191 | pt2 = pt1 * pt1 |
---|
192 | pt3 = pt1 * pt2 |
---|
193 | pt4 = pt2 * pt2 |
---|
194 | |
---|
195 | sa15 = sa * SQRT( sa ) |
---|
196 | sa2 = sa * sa |
---|
197 | |
---|
198 | |
---|
199 | eqn_state_seawater_func = & |
---|
200 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & |
---|
201 | nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & |
---|
202 | nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
203 | ) / & |
---|
204 | ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & |
---|
205 | den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & |
---|
206 | den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
207 | den(13)*p3*pt1 & |
---|
208 | ) |
---|
209 | |
---|
210 | |
---|
211 | END FUNCTION eqn_state_seawater_func |
---|
212 | |
---|
213 | END MODULE eqn_state_seawater_mod |
---|