@@ -80,7 +80,8 @@ subroutine int_density_dz(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, EOS, US, dpa,
80
80
real , optional , intent (in ) :: dz_neglect ! < A minuscule thickness change [Z ~> m]
81
81
integer , optional , intent (in ) :: MassWghtInterp ! < A flag indicating whether and how to use
82
82
! ! mass weighting to interpolate T/S in integrals
83
- real , optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
83
+ real , dimension (HI% isd:HI% ied,HI% jsd:HI% jed), &
84
+ optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
84
85
85
86
if (EOS_quadrature(EOS)) then
86
87
call int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, EOS, US, dpa, &
@@ -139,7 +140,8 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
139
140
! ! mass weighting to interpolate T/S in integrals
140
141
logical , optional , intent (in ) :: use_inaccurate_form ! < If true, uses an inaccurate form of
141
142
! ! density anomalies, as was used prior to March 2018.
142
- real , optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
143
+ real , dimension (HI% isd:HI% ied,HI% jsd:HI% jed), &
144
+ optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
143
145
144
146
! Local variables
145
147
real :: T5((5 * HI% iscB+1 ):(5 * (HI% iecB+2 ))) ! Temperatures along a line of subgrid locations [C ~> degC]
@@ -157,7 +159,7 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
157
159
real :: dz ! The layer thickness [Z ~> m]
158
160
real :: dz_x(5 ,HI% iscB:HI% iecB) ! Layer thicknesses along an x-line of subgrid locations [Z ~> m]
159
161
real :: dz_y(5 ,HI% isc:HI% iec) ! Layer thicknesses along a y-line of subgrid locations [Z ~> m]
160
- real :: z0pres ! The height at which the pressure is zero [Z ~> m]
162
+ real :: z0pres(HI % isd:HI % ied,HI % jsd:HI % jed) ! The height at which the pressure is zero [Z ~> m]
161
163
real :: hWght ! A pressure-thickness below topography [Z ~> m]
162
164
real :: hL, hR ! Pressure-thicknesses of the columns to the left and right [Z ~> m]
163
165
real :: iDenom ! The inverse of the denominator in the weights [Z-2 ~> m-2]
@@ -184,7 +186,13 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
184
186
185
187
GxRho = G_e * rho_0
186
188
I_Rho = 1.0 / rho_0
187
- z0pres = 0.0 ; if (present (Z_0p)) z0pres = Z_0p
189
+ if (present (Z_0p)) then
190
+ do j= Jsq,Jeq+1 ; do i= Isq,Ieq+1
191
+ z0pres(i,j) = Z_0p(i,j)
192
+ enddo ; enddo
193
+ else
194
+ z0pres(:,:) = 0.0
195
+ endif
188
196
use_rho_ref = .true.
189
197
if (present (use_inaccurate_form)) then
190
198
if (use_inaccurate_form) use_rho_ref = .not. use_inaccurate_form
@@ -209,7 +217,7 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
209
217
dz = z_t(i,j) - z_b(i,j)
210
218
do n= 1 ,5
211
219
T5(i* 5 + n) = T(i,j) ; S5(i* 5 + n) = S(i,j)
212
- p5(i* 5 + n) = - GxRho* ((z_t(i,j) - z0pres) - 0.25 * real (n-1 )* dz)
220
+ p5(i* 5 + n) = - GxRho* ((z_t(i,j) - z0pres(i,j) ) - 0.25 * real (n-1 )* dz)
213
221
enddo
214
222
enddo
215
223
@@ -260,7 +268,7 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
260
268
pos = i* 15 + (m-2 )* 5
261
269
T15(pos+1 ) = wtT_L* T(i,j) + wtT_R* T(i+1 ,j)
262
270
S15(pos+1 ) = wtT_L* S(i,j) + wtT_R* S(i+1 ,j)
263
- p15(pos+1 ) = - GxRho* ((wt_L* z_t(i,j) + wt_R* z_t(i+1 ,j)) - z0pres)
271
+ p15(pos+1 ) = - GxRho* ((wt_L* z_t(i,j) + wt_R* z_t(i+1 ,j)) - z0pres(i,j) )
264
272
do n= 2 ,5
265
273
T15(pos+ n) = T15(pos+1 ) ; S15(pos+ n) = S15(pos+1 )
266
274
p15(pos+ n) = p15(pos+ n-1 ) + GxRho* 0.25 * dz_x(m,i)
@@ -326,7 +334,7 @@ subroutine int_density_dz_generic_pcm(T, S, z_t, z_b, rho_ref, rho_0, G_e, HI, &
326
334
pos = i* 15 + (m-2 )* 5
327
335
T15(pos+1 ) = wtT_L* T(i,j) + wtT_R* T(i,j+1 )
328
336
S15(pos+1 ) = wtT_L* S(i,j) + wtT_R* S(i,j+1 )
329
- p15(pos+1 ) = - GxRho* ((wt_L* z_t(i,j) + wt_R* z_t(i,j+1 )) - z0pres)
337
+ p15(pos+1 ) = - GxRho* ((wt_L* z_t(i,j) + wt_R* z_t(i,j+1 )) - z0pres(i,j) )
330
338
do n= 2 ,5
331
339
T15(pos+ n) = T15(pos+1 ) ; S15(pos+ n) = S15(pos+1 )
332
340
p15(pos+ n) = p15(pos+ n-1 ) + GxRho* 0.25 * dz_y(m,i)
@@ -414,7 +422,8 @@ subroutine int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, rho_ref, &
414
422
! ! mass weighting to interpolate T/S in integrals
415
423
logical , optional , intent (in ) :: use_inaccurate_form ! < If true, uses an inaccurate form of
416
424
! ! density anomalies, as was used prior to March 2018.
417
- real , optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
425
+ real , dimension (HI% isd:HI% ied,HI% jsd:HI% jed), &
426
+ optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
418
427
419
428
! This subroutine calculates (by numerical quadrature) integrals of
420
429
! pressure anomalies across layers, which are required for calculating the
@@ -464,7 +473,7 @@ subroutine int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, rho_ref, &
464
473
real :: massWeightToggle ! A non-dimensional toggle factor (0 or 1) [nondim]
465
474
real :: Ttl, Tbl, Ttr, Tbr ! Temperatures at the velocity cell corners [C ~> degC]
466
475
real :: Stl, Sbl, Str, Sbr ! Salinities at the velocity cell corners [S ~> ppt]
467
- real :: z0pres ! The height at which the pressure is zero [Z ~> m]
476
+ real :: z0pres(HI % isd:HI % ied,HI % jsd:HI % jed) ! The height at which the pressure is zero [Z ~> m]
468
477
real :: hWght ! A topographically limited thickness weight [Z ~> m]
469
478
real :: hL, hR ! Thicknesses to the left and right [Z ~> m]
470
479
real :: iDenom ! The denominator of the thickness weight expressions [Z-2 ~> m-2]
@@ -480,7 +489,13 @@ subroutine int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, rho_ref, &
480
489
481
490
GxRho = G_e * rho_0
482
491
I_Rho = 1.0 / rho_0
483
- z0pres = 0.0 ; if (present (Z_0p)) z0pres = Z_0p
492
+ if (present (Z_0p)) then
493
+ do j= Jsq,Jeq+1 ; do i= Isq,Ieq+1
494
+ z0pres(i,j) = Z_0p(i,j)
495
+ enddo ; enddo
496
+ else
497
+ z0pres(:,:) = 0.0
498
+ endif
484
499
massWeightToggle = 0 .
485
500
if (present (MassWghtInterp)) then ; if (BTEST (MassWghtInterp, 0 )) massWeightToggle = 1 . ; endif
486
501
use_rho_ref = .true.
@@ -517,7 +532,7 @@ subroutine int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, rho_ref, &
517
532
do i = Isq,Ieq+1
518
533
dz(i) = e(i,j,K) - e(i,j,K+1 )
519
534
do n= 1 ,5
520
- p5(i* 5 + n) = - GxRho* ((e(i,j,K) - z0pres) - 0.25 * real (n-1 )* dz(i))
535
+ p5(i* 5 + n) = - GxRho* ((e(i,j,K) - z0pres(i,j) ) - 0.25 * real (n-1 )* dz(i))
521
536
! Salinity and temperature points are linearly interpolated
522
537
S5(i* 5 + n) = wt_t(n) * S_t(i,j,k) + wt_b(n) * S_b(i,j,k)
523
538
T5(i* 5 + n) = wt_t(n) * T_t(i,j,k) + wt_b(n) * T_b(i,j,k)
@@ -610,7 +625,7 @@ subroutine int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, rho_ref, &
610
625
S15(pos+1 ) = w_left* Stl + w_right* Str
611
626
S15(pos+5 ) = w_left* Sbl + w_right* Sbr
612
627
613
- p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i+1 ,j,K)) - z0pres)
628
+ p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i+1 ,j,K)) - z0pres(i,j) )
614
629
615
630
! Pressure
616
631
do n= 2 ,5
@@ -706,7 +721,7 @@ subroutine int_density_dz_generic_plm(k, tv, T_t, T_b, S_t, S_b, e, rho_ref, &
706
721
S15(pos+1 ) = w_left* Stl + w_right* Str
707
722
S15(pos+5 ) = w_left* Sbl + w_right* Sbr
708
723
709
- p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i,j+1 ,K)) - z0pres)
724
+ p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i,j+1 ,K)) - z0pres(i,j) )
710
725
711
726
! Pressure
712
727
do n= 2 ,5
@@ -812,7 +827,8 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
812
827
! ! divided by the y grid spacing [R L2 T-2 ~> Pa]
813
828
integer , optional , intent (in ) :: MassWghtInterp ! < A flag indicating whether and how to use
814
829
! ! mass weighting to interpolate T/S in integrals
815
- real , optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
830
+ real , dimension (HI% isd:HI% ied,HI% jsd:HI% jed), &
831
+ optional , intent (in ) :: Z_0p ! < The height at which the pressure is 0 [Z ~> m]
816
832
817
833
! This subroutine calculates (by numerical quadrature) integrals of
818
834
! pressure anomalies across layers, which are required for calculating the
@@ -864,7 +880,7 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
864
880
real :: t6 ! PPM curvature coefficient for T [C ~> degC]
865
881
real :: T_top, T_mn, T_bot ! Left edge, cell mean and right edge values used in PPM reconstructions of T [C ~> degC]
866
882
real :: S_top, S_mn, S_bot ! Left edge, cell mean and right edge values used in PPM reconstructions of S [S ~> ppt]
867
- real :: z0pres ! The height at which the pressure is zero [Z ~> m]
883
+ real :: z0pres(HI % isd:HI % ied,HI % jsd:HI % jed) ! The height at which the pressure is zero [Z ~> m]
868
884
real :: hWght ! A topographically limited thickness weight [Z ~> m]
869
885
real :: hL, hR ! Thicknesses to the left and right [Z ~> m]
870
886
real :: iDenom ! The denominator of the thickness weight expressions [Z-2 ~> m-2]
@@ -879,7 +895,13 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
879
895
880
896
GxRho = G_e * rho_0
881
897
I_Rho = 1.0 / rho_0
882
- z0pres = 0.0 ; if (present (Z_0p)) z0pres = Z_0p
898
+ if (present (Z_0p)) then
899
+ do j= Jsq,Jeq+1 ; do i= Isq,Ieq+1
900
+ z0pres(i,j) = Z_0p(i,j)
901
+ enddo ; enddo
902
+ else
903
+ z0pres(:,:) = 0.0
904
+ endif
883
905
massWeightToggle = 0 .
884
906
if (present (MassWghtInterp)) then ; if (BTEST (MassWghtInterp, 0 )) massWeightToggle = 1 . ; endif
885
907
@@ -924,7 +946,7 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
924
946
endif
925
947
dz = e(i,j,K) - e(i,j,K+1 )
926
948
do n= 1 ,5
927
- p5(I* 5 + n) = - GxRho* ((e(i,j,K) - z0pres) - 0.25 * real (n-1 )* dz)
949
+ p5(I* 5 + n) = - GxRho* ((e(i,j,K) - z0pres(i,j) ) - 0.25 * real (n-1 )* dz)
928
950
! Salinity and temperature points are reconstructed with PPM
929
951
S5(I* 5 + n) = wt_t(n) * S_t(i,j,k) + wt_b(n) * ( S_b(i,j,k) + s6 * wt_t(n) )
930
952
T5(I* 5 + n) = wt_t(n) * T_t(i,j,k) + wt_b(n) * ( T_b(i,j,k) + t6 * wt_t(n) )
@@ -1011,7 +1033,7 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
1011
1033
dz_x(m,i) = w_left* (e(i,j,K) - e(i,j,K+1 )) + w_right* (e(i+1 ,j,K) - e(i+1 ,j,K+1 ))
1012
1034
1013
1035
pos = i* 15 + (m-2 )* 5
1014
- p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i+1 ,j,K)) - z0pres)
1036
+ p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i+1 ,j,K)) - z0pres(i,j) )
1015
1037
do n= 2 ,5
1016
1038
p15(pos+ n) = p15(pos+ n-1 ) + GxRho* 0.25 * dz_x(m,i)
1017
1039
enddo
@@ -1116,7 +1138,7 @@ subroutine int_density_dz_generic_ppm(k, tv, T_t, T_b, S_t, S_b, e, &
1116
1138
dz_y(m,i) = w_left* (e(i,j,K) - e(i,j,K+1 )) + w_right* (e(i,j+1 ,K) - e(i,j+1 ,K+1 ))
1117
1139
1118
1140
pos = i* 15 + (m-2 )* 5
1119
- p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i,j+1 ,K)) - z0pres)
1141
+ p15(pos+1 ) = - GxRho* ((w_left* e(i,j,K) + w_right* e(i,j+1 ,K)) - z0pres(i,j) )
1120
1142
do n= 2 ,5
1121
1143
p15(pos+ n) = p15(pos+ n-1 ) + GxRho* 0.25 * dz_y(m,i)
1122
1144
enddo
0 commit comments