13 implicit none ;
private
16 public calculate_density_derivs_unesco
17 public calculate_density_scalar_unesco, calculate_density_array_unesco
23 module procedure calculate_density_scalar_unesco, calculate_density_array_unesco
30 module procedure calculate_spec_vol_scalar_unesco, calculate_spec_vol_array_unesco
36 real,
parameter :: r00 = 999.842594, r10 = 6.793952e-2, r20 = -9.095290e-3, &
37 r30 = 1.001685e-4, r40 = -1.120083e-6, r50 = 6.536332e-9, r01 = 0.824493, &
38 r11 = -4.0899e-3, r21 = 7.6438e-5, r31 = -8.2467e-7, r41 = 5.3875e-9, &
39 r032 = -5.72466e-3, r132 = 1.0227e-4, r232 = -1.6546e-6, r02 = 4.8314e-4
45 real,
parameter :: s00 = 1.965933e4, s10 = 1.444304e2, s20 = -1.706103, &
46 s30 = 9.648704e-3, s40 = -4.190253e-5, s01 = 52.84855, s11 = -3.101089e-1, &
47 s21 = 6.283263e-3, s31 = -5.084188e-5, s032 = 3.886640e-1, s132 = 9.085835e-3, &
48 s232 = -4.619924e-4, sp00 = 3.186519, sp10 = 2.212276e-2, sp20 = -2.984642e-4, &
49 sp30 = 1.956415e-6, sp01 = 6.704388e-3, sp11 = -1.847318e-4, sp21 = 2.059331e-7, &
50 sp032 = 1.480266e-4, sp000 = 2.102898e-4, sp010 = -1.202016e-5, sp020 = 1.394680e-7, &
51 sp001 = -2.040237e-6, sp011 = 6.128773e-8, sp021 = 6.207323e-10
59 subroutine calculate_density_scalar_unesco(T, S, pressure, rho, rho_ref)
62 real,
intent(in) :: pressure
63 real,
intent(out) :: rho
64 real,
optional,
intent(in) :: rho_ref
67 real,
dimension(1) :: t0, s0, pressure0
68 real,
dimension(1) :: rho0
72 pressure0(1) = pressure
74 call calculate_density_array_unesco(t0, s0, pressure0, rho0, 1, 1, rho_ref)
77 end subroutine calculate_density_scalar_unesco
82 subroutine calculate_density_array_unesco(T, S, pressure, rho, start, npts, rho_ref)
83 real,
dimension(:),
intent(in) :: t
84 real,
dimension(:),
intent(in) :: s
85 real,
dimension(:),
intent(in) :: pressure
86 real,
dimension(:),
intent(out) :: rho
87 integer,
intent(in) :: start
88 integer,
intent(in) :: npts
89 real,
optional,
intent(in) :: rho_ref
92 real :: t_local, t2, t3, t4, t5
93 real :: s_local, s32, s2
100 do j=start,start+npts-1
101 if (s(j) < -1.0e-10)
then
106 p1 = pressure(j)*1.0e-5; p2 = p1*p1
107 t_local = t(j); t2 = t_local*t_local; t3 = t_local*t2; t4 = t2*t2; t5 = t3*t2
108 s_local = s(j); s2 = s_local*s_local; s32 = s_local*sqrt(s_local)
112 sig0 = r10*t_local + r20*t2 + r30*t3 + r40*t4 + r50*t5 + &
113 s_local*(r01 + r11*t_local + r21*t2 + r31*t3 + r41*t4) + &
114 s32*(r032 + r132*t_local + r232*t2) + r02*s2
119 ks = s00 + s10*t_local + s20*t2 + s30*t3 + s40*t4 + s_local*(s01 + s11*t_local + s21*t2 + s31*t3) + &
120 s32*(s032 + s132*t_local + s232*t2) + &
121 p1*(sp00 + sp10*t_local + sp20*t2 + sp30*t3 + &
122 s_local*(sp01 + sp11*t_local + sp21*t2) + sp032*s32) + &
123 p2*(sp000 + sp010*t_local + sp020*t2 + s_local*(sp001 + sp011*t_local + sp021*t2))
125 if (
present(rho_ref))
then
126 rho(j) = ((r00 - rho_ref)*ks + (sig0*ks + p1*rho_ref)) / (ks - p1)
128 rho(j) = rho0*ks / (ks - p1)
131 end subroutine calculate_density_array_unesco
137 subroutine calculate_spec_vol_scalar_unesco(T, S, pressure, specvol, spv_ref)
138 real,
intent(in) :: T
140 real,
intent(in) :: S
141 real,
intent(in) :: pressure
142 real,
intent(out) :: specvol
143 real,
optional,
intent(in) :: spv_ref
146 real,
dimension(1) :: T0, S0, pressure0, spv0
148 t0(1) = t ; s0(1) = s ; pressure0(1) = pressure
150 call calculate_spec_vol_array_unesco(t0, s0, pressure0, spv0, 1, 1, spv_ref)
152 end subroutine calculate_spec_vol_scalar_unesco
158 subroutine calculate_spec_vol_array_unesco(T, S, pressure, specvol, start, npts, spv_ref)
159 real,
dimension(:),
intent(in) :: T
161 real,
dimension(:),
intent(in) :: S
162 real,
dimension(:),
intent(in) :: pressure
163 real,
dimension(:),
intent(out) :: specvol
164 integer,
intent(in) :: start
165 integer,
intent(in) :: npts
166 real,
optional,
intent(in) :: spv_ref
169 real :: t_local, t2, t3, t4, t5
170 real :: s_local, s32, s2
176 do j=start,start+npts-1
177 if (s(j) < -1.0e-10)
then
179 if (
present(spv_ref)) specvol(j) = 0.001 - spv_ref
183 p1 = pressure(j)*1.0e-5; p2 = p1*p1
184 t_local = t(j); t2 = t_local*t_local; t3 = t_local*t2; t4 = t2*t2; t5 = t3*t2
185 s_local = s(j); s2 = s_local*s_local; s32 = s_local*sqrt(s_local)
189 rho0 = r00 + r10*t_local + r20*t2 + r30*t3 + r40*t4 + r50*t5 + &
190 s_local*(r01 + r11*t_local + r21*t2 + r31*t3 + r41*t4) + &
191 s32*(r032 + r132*t_local + r232*t2) + r02*s2
195 ks = s00 + s10*t_local + s20*t2 + s30*t3 + s40*t4 + s_local*(s01 + s11*t_local + s21*t2 + s31*t3) + &
196 s32*(s032 + s132*t_local + s232*t2) + &
197 p1*(sp00 + sp10*t_local + sp20*t2 + sp30*t3 + &
198 s_local*(sp01 + sp11*t_local + sp21*t2) + sp032*s32) + &
199 p2*(sp000 + sp010*t_local + sp020*t2 + s_local*(sp001 + sp011*t_local + sp021*t2))
201 if (
present(spv_ref))
then
202 specvol(j) = (ks*(1.0 - (rho0*spv_ref)) - p1) / (rho0*ks)
204 specvol(j) = (ks - p1) / (rho0*ks)
207 end subroutine calculate_spec_vol_array_unesco
212 subroutine calculate_density_derivs_unesco(T, S, pressure, drho_dT, drho_dS, start, npts)
213 real,
intent(in),
dimension(:) :: t
215 real,
intent(in),
dimension(:) :: s
216 real,
intent(in),
dimension(:) :: pressure
217 real,
intent(out),
dimension(:) :: drho_dt
219 real,
intent(out),
dimension(:) :: drho_ds
221 integer,
intent(in) :: start
222 integer,
intent(in) :: npts
225 real :: t_local, t2, t3, t4, t5
226 real :: s12, s_local, s32, s2
237 do j=start,start+npts-1
238 if (s(j) < -1.0e-10)
then
239 drho_dt(j) = 0.0 ; drho_ds(j) = 0.0
243 p1 = pressure(j)*1.0e-5; p2 = p1*p1
244 t_local = t(j); t2 = t_local*t_local; t3 = t_local*t2; t4 = t2*t2; t5 = t3*t2
245 s_local = s(j); s2 = s_local*s_local; s12 = sqrt(s_local); s32 = s_local*s12
249 rho0 = r00 + r10*t_local + r20*t2 + r30*t3 + r40*t4 + r50*t5 + &
250 s_local*(r01 + r11*t_local + r21*t2 + r31*t3 + r41*t4) + &
251 s32*(r032 + r132*t_local + r232*t2) + r02*s2
252 drho0_dt = r10 + 2.0*r20*t_local + 3.0*r30*t2 + 4.0*r40*t3 + 5.0*r50*t4 + &
253 s_local*(r11 + 2.0*r21*t_local + 3.0*r31*t2 + 4.0*r41*t3) + &
254 s32*(r132 + 2.0*r232*t_local)
255 drho0_ds = (r01 + r11*t_local + r21*t2 + r31*t3 + r41*t4) + &
256 1.5*s12*(r032 + r132*t_local + r232*t2) + 2.0*r02*s_local
260 ks = s00 + s10*t_local + s20*t2 + s30*t3 + s40*t4 + s_local*(s01 + s11*t_local + s21*t2 + s31*t3) + &
261 s32*(s032 + s132*t_local + s232*t2) + &
262 p1*(sp00 + sp10*t_local + sp20*t2 + sp30*t3 + &
263 s_local*(sp01 + sp11*t_local + sp21*t2) + sp032*s32) + &
264 p2*(sp000 + sp010*t_local + sp020*t2 + s_local*(sp001 + sp011*t_local + sp021*t2))
265 dks_dt = s10 + 2.0*s20*t_local + 3.0*s30*t2 + 4.0*s40*t3 + &
266 s_local*(s11 + 2.0*s21*t_local + 3.0*s31*t2) + s32*(s132 + 2.0*s232*t_local) + &
267 p1*(sp10 + 2.0*sp20*t_local + 3.0*sp30*t2 + s_local*(sp11 + 2.0*sp21*t_local)) + &
268 p2*(sp010 + 2.0*sp020*t_local + s_local*(sp011 + 2.0*sp021*t_local))
269 dks_ds = (s01 + s11*t_local + s21*t2 + s31*t3) + 1.5*s12*(s032 + s132*t_local + s232*t2) + &
270 p1*(sp01 + sp11*t_local + sp21*t2 + 1.5*sp032*s12) + &
271 p2*(sp001 + sp011*t_local + sp021*t2)
273 denom = 1.0 / (ks - p1)
274 drho_dt(j) = denom*(ks*drho0_dt - rho0*p1*denom*dks_dt)
275 drho_ds(j) = denom*(ks*drho0_ds - rho0*p1*denom*dks_ds)
278 end subroutine calculate_density_derivs_unesco
283 subroutine calculate_compress_unesco(T, S, pressure, rho, drho_dp, start, npts)
284 real,
intent(in),
dimension(:) :: t
286 real,
intent(in),
dimension(:) :: s
287 real,
intent(in),
dimension(:) :: pressure
288 real,
intent(out),
dimension(:) :: rho
289 real,
intent(out),
dimension(:) :: drho_dp
292 integer,
intent(in) :: start
293 integer,
intent(in) :: npts
296 real :: t_local, t2, t3, t4, t5
297 real :: s_local, s32, s2
301 real :: ks_0, ks_1, ks_2
306 do j=start,start+npts-1
307 if (s(j) < -1.0e-10)
then
308 rho(j) = 1000.0 ; drho_dp(j) = 0.0
312 p1 = pressure(j)*1.0e-5; p2 = p1*p1
313 t_local = t(j); t2 = t_local*t_local; t3 = t_local*t2; t4 = t2*t2; t5 = t3*t2
314 s_local = s(j); s2 = s_local*s_local; s32 = s_local*sqrt(s_local)
318 rho0 = r00 + r10*t_local + r20*t2 + r30*t3 + r40*t4 + r50*t5 + &
319 s_local*(r01 + r11*t_local + r21*t2 + r31*t3 + r41*t4) + &
320 s32*(r032 + r132*t_local + r232*t2) + r02*s2
323 ks_0 = s00 + s10*t_local + s20*t2 + s30*t3 + s40*t4 + &
324 s_local*(s01 + s11*t_local + s21*t2 + s31*t3) + s32*(s032 + s132*t_local + s232*t2)
325 ks_1 = sp00 + sp10*t_local + sp20*t2 + sp30*t3 + &
326 s_local*(sp01 + sp11*t_local + sp21*t2) + sp032*s32
327 ks_2 = sp000 + sp010*t_local + sp020*t2 + s_local*(sp001 + sp011*t_local + sp021*t2)
329 ks = ks_0 + p1*ks_1 + p2*ks_2
330 dks_dp = ks_1 + 2.0*p1*ks_2
332 rho(j) = rho0*ks / (ks - p1)
334 drho_dp(j) = 1.0e-5 * (rho(j) / (ks - p1)) * (1.0 - dks_dp*p1/ks)
336 end subroutine calculate_compress_unesco