10 use regrid_interp,
only : nr_iterations, nr_tolerance, degree_max
12 implicit none ;
private
28 real :: compressibility_fraction
32 real :: rho_ml_avg_depth
35 real :: nlay_ml_offset
38 integer :: nz_fixed_surface = 2
45 logical :: fix_haloclines = .false.
49 real :: halocline_filter_length
52 real :: halocline_strat_tol
55 real,
allocatable,
dimension(:) :: target_density
58 real,
allocatable,
dimension(:) :: max_interface_depths
61 real,
allocatable,
dimension(:) :: max_layer_thickness
67 public init_coord_slight, set_slight_params, build_slight_column, end_coord_slight
72 subroutine init_coord_slight(CS, nk, ref_pressure, target_density, interp_CS, m_to_H)
74 integer,
intent(in) :: nk
75 real,
intent(in) :: ref_pressure
76 real,
dimension(:),
intent(in) :: target_density
78 real,
optional,
intent(in) :: m_to_h
80 real :: m_to_h_rescale
82 if (
associated(cs))
call mom_error(fatal,
"init_coord_slight: CS already associated!")
84 allocate(cs%target_density(nk+1))
86 m_to_h_rescale = 1.0 ;
if (
present(m_to_h)) m_to_h_rescale = m_to_h
89 cs%ref_pressure = ref_pressure
90 cs%target_density(:) = target_density(:)
91 cs%interp_CS = interp_cs
94 cs%compressibility_fraction = 0.
95 cs%Rho_ML_avg_depth = 1.0 * m_to_h_rescale
96 cs%nlay_ml_offset = 2.0
97 cs%dz_ml_min = 1.0 * m_to_h_rescale
98 cs%halocline_filter_length = 2.0 * m_to_h_rescale
99 cs%halocline_strat_tol = 0.25
101 end subroutine init_coord_slight
104 subroutine end_coord_slight(CS)
108 if (.not.
associated(cs))
return
109 deallocate(cs%target_density)
111 end subroutine end_coord_slight
114 subroutine set_slight_params(CS, max_interface_depths, max_layer_thickness, &
115 min_thickness, compressibility_fraction, dz_ml_min, &
116 nz_fixed_surface, Rho_ML_avg_depth, nlay_ML_offset, fix_haloclines, &
117 halocline_filter_length, halocline_strat_tol, interp_CS)
119 real,
dimension(:), &
120 optional,
intent(in) :: max_interface_depths
121 real,
dimension(:), &
122 optional,
intent(in) :: max_layer_thickness
123 real,
optional,
intent(in) :: min_thickness
125 real,
optional,
intent(in) :: compressibility_fraction
128 real,
optional,
intent(in) :: dz_ml_min
130 integer,
optional,
intent(in) :: nz_fixed_surface
132 real,
optional,
intent(in) :: rho_ml_avg_depth
134 real,
optional,
intent(in) :: nlay_ml_offset
136 logical,
optional,
intent(in) :: fix_haloclines
138 real,
optional,
intent(in) :: halocline_filter_length
140 real,
optional,
intent(in) :: halocline_strat_tol
143 optional,
intent(in) :: interp_cs
145 if (.not.
associated(cs))
call mom_error(fatal,
"set_slight_params: CS not associated")
147 if (
present(max_interface_depths))
then
148 if (
size(max_interface_depths) /= cs%nk+1) &
149 call mom_error(fatal,
"set_slight_params: max_interface_depths inconsistent size")
150 allocate(cs%max_interface_depths(cs%nk+1))
151 cs%max_interface_depths(:) = max_interface_depths(:)
154 if (
present(max_layer_thickness))
then
155 if (
size(max_layer_thickness) /= cs%nk) &
156 call mom_error(fatal,
"set_slight_params: max_layer_thickness inconsistent size")
157 allocate(cs%max_layer_thickness(cs%nk))
158 cs%max_layer_thickness(:) = max_layer_thickness(:)
161 if (
present(min_thickness)) cs%min_thickness = min_thickness
162 if (
present(compressibility_fraction)) cs%compressibility_fraction = compressibility_fraction
164 if (
present(dz_ml_min)) cs%dz_ml_min = dz_ml_min
165 if (
present(nz_fixed_surface)) cs%nz_fixed_surface = nz_fixed_surface
166 if (
present(rho_ml_avg_depth)) cs%Rho_ML_avg_depth = rho_ml_avg_depth
167 if (
present(nlay_ml_offset)) cs%nlay_ML_offset = nlay_ml_offset
168 if (
present(fix_haloclines)) cs%fix_haloclines = fix_haloclines
169 if (
present(halocline_filter_length)) cs%halocline_filter_length = halocline_filter_length
170 if (
present(halocline_strat_tol))
then
171 if (halocline_strat_tol > 1.0)
call mom_error(fatal,
"set_slight_params: "//&
172 "HALOCLINE_STRAT_TOL must not exceed 1.0.")
173 cs%halocline_strat_tol = halocline_strat_tol
176 if (
present(interp_cs)) cs%interp_CS = interp_cs
177 end subroutine set_slight_params
180 subroutine build_slight_column(CS, eqn_of_state, H_to_pres, H_subroundoff, &
181 nz, depth, h_col, T_col, S_col, p_col, z_col, z_col_new, &
182 h_neglect, h_neglect_edge)
184 type(
eos_type),
pointer :: eqn_of_state
185 real,
intent(in) :: h_to_pres
187 real,
intent(in) :: h_subroundoff
188 integer,
intent(in) :: nz
189 real,
intent(in) :: depth
190 real,
dimension(nz),
intent(in) :: t_col
191 real,
dimension(nz),
intent(in) :: s_col
192 real,
dimension(nz),
intent(in) :: h_col
193 real,
dimension(nz),
intent(in) :: p_col
194 real,
dimension(nz+1),
intent(in) :: z_col
195 real,
dimension(nz+1),
intent(inout) :: z_col_new
196 real,
optional,
intent(in) :: h_neglect
198 real,
optional,
intent(in) :: h_neglect_edge
201 real,
dimension(nz) :: rho_col
202 real,
dimension(nz) :: t_f, s_f
203 logical,
dimension(nz+1) :: reliable
204 real,
dimension(nz+1) :: t_int, s_int
205 real,
dimension(nz+1) :: rho_tmp
206 real,
dimension(nz+1) :: drho_dp
207 real,
dimension(nz+1) :: p_is, p_r
208 real,
dimension(nz+1) :: drhois_dt
210 real,
dimension(nz+1) :: drhois_ds
212 real,
dimension(nz+1) :: drhor_dt
214 real,
dimension(nz+1) :: drhor_ds
216 real,
dimension(nz+1) :: strat_rat
220 real :: fn_now, i_hstol, fn_zero_val
236 logical :: maximum_depths_set
237 logical :: maximum_h_set
238 real :: k2_used, k2here, dz_sum, z_max
240 real :: h_tr, b_denom_1, b1, d1
241 real,
dimension(nz) :: c1
242 integer :: kur1, kur2
244 integer :: i, j, k, nkml
246 maximum_depths_set =
allocated(cs%max_interface_depths)
247 maximum_h_set =
allocated(cs%max_layer_thickness)
249 if (z_col(nz+1) - z_col(1) < nz*cs%min_thickness)
then
251 dz = (z_col(nz+1) - z_col(1)) / real(nz)
252 do k=2,nz ; z_col_new(k) = z_col(1) + dz*real(k-1) ;
enddo
258 call rho_interfaces_col(rho_col, h_col, z_col, cs%target_density, nz, &
259 z_col_new, cs, reliable, debug=.true., &
260 h_neglect=h_neglect, h_neglect_edge=h_neglect_edge)
263 if (cs%min_thickness > 0.0)
then
265 do k=2,nz ;
if (z_col_new(k) < z_col_new(k-1) + cs%min_thickness)
then
266 z_col_new(k) = z_col_new(k-1) + cs%min_thickness
269 do k=nz,2,-1 ;
if (z_col_new(k) > z_col_new(k+1) - cs%min_thickness)
then
270 z_col_new(k) = z_col_new(k+1) - cs%min_thickness
281 do k=kur_ss,nz ;
if (.not.reliable(k))
then
287 do k=kur1+1,nz+1 ;
if (reliable(k))
then
288 kur2 = k-1 ; kur_ss = k ;
exit
290 if (kur2 < kur1)
call mom_error(fatal,
"Bad unreliable range.")
292 dz_ur = z_col_new(kur2+1) - z_col_new(kur1-1)
296 wgt = 1.0 ; cowgt = 0.0
298 z_col_new(k) = cowgt*z_col_new(k) + &
299 wgt * (z_col_new(kur1-1) + dz_ur*(k - (kur1-1)) / ((kur2 - kur1) + 2))
305 z_wt = 0.0 ; rho_x_z = 0.0
306 h_ml_av = cs%Rho_ml_avg_depth
308 if (z_wt + h_col(k) >= h_ml_av)
then
309 rho_x_z = rho_x_z + rho_col(k) * (h_ml_av - z_wt)
313 rho_x_z = rho_x_z + rho_col(k) * h_col(k)
314 z_wt = z_wt + h_col(k)
317 if (z_wt > 0.0) rho_ml_av = rho_x_z / z_wt
319 nkml = cs%nz_fixed_surface
321 if (rho_ml_av <= cs%target_density(nkml))
then
322 k_interior = cs%nlay_ml_offset + real(nkml)
323 elseif (rho_ml_av > cs%target_density(nz+1))
then
324 k_interior = real(nz+1)
326 if ((rho_ml_av >= cs%target_density(k)) .and. &
327 (rho_ml_av < cs%target_density(k+1)))
then
328 k_interior = (cs%nlay_ml_offset + k) + &
329 (rho_ml_av - cs%target_density(k)) / &
330 (cs%target_density(k+1) - cs%target_density(k))
334 if (k_interior > real(nz+1)) k_interior = real(nz+1)
337 k = int(ceiling(k_interior))
338 z_interior = (k-k_interior)*z_col_new(k-1) + (1.0+(k_interior-k))*z_col_new(k)
340 if (cs%fix_haloclines)
then
346 if (cs%halocline_filter_length > 0.0)
then
347 lfilt = cs%halocline_filter_length
350 h_tr = h_col(1) + h_subroundoff
351 b1 = 1.0 / (h_tr + lfilt) ; d1 = h_tr * b1
352 t_f(1) = (b1*h_tr)*t_col(1) ; s_f(1) = (b1*h_tr)*s_col(1)
355 h_tr = h_col(k) + h_subroundoff ; b_denom_1 = h_tr + d1*lfilt
356 b1 = 1.0 / (b_denom_1 + lfilt) ; d1 = b_denom_1 * b1
357 t_f(k) = b1 * (h_tr*t_col(k) + lfilt*t_f(k-1))
358 s_f(k) = b1 * (h_tr*s_col(k) + lfilt*s_f(k-1))
361 t_f(k) = t_f(k) + c1(k+1)*t_f(k+1) ; s_f(k) = s_f(k) + c1(k+1)*s_f(k+1)
364 do k=1,nz ; t_f(k) = t_col(k) ; s_f(k) = s_col(k) ;
enddo
367 t_int(1) = t_f(1) ; s_int(1) = s_f(1)
369 t_int(k) = 0.5*(t_f(k-1) + t_f(k)) ; s_int(k) = 0.5*(s_f(k-1) + s_f(k))
370 p_is(k) = z_col(k) * h_to_pres
371 p_r(k) = cs%ref_pressure + cs%compressibility_fraction * ( p_is(k) - cs%ref_pressure )
373 t_int(nz+1) = t_f(nz) ; s_int(nz+1) = s_f(nz)
374 p_is(nz+1) = z_col(nz+1) * h_to_pres
376 eqn_of_state, (/2,nz/) )
378 eqn_of_state, (/2,nz/) )
379 if (cs%compressibility_fraction > 0.0)
then
380 call calculate_compress(t_int, s_int, p_r(:), rho_tmp, drho_dp, 2, nz-1, eqn_of_state)
382 do k=2,nz ; drho_dp(k) = 0.0 ;
enddo
385 h_to_cpa = cs%compressibility_fraction * h_to_pres
388 dris = drhois_dt(k) * (t_f(k) - t_f(k-1)) + &
389 drhois_ds(k) * (s_f(k) - s_f(k-1))
390 drr = (drhor_dt(k) * (t_f(k) - t_f(k-1)) + &
391 drhor_ds(k) * (s_f(k) - s_f(k-1))) + &
392 drho_dp(k) * (h_to_cpa*0.5*(h_col(k) + h_col(k-1)))
394 if (dris <= 0.0)
then
397 strat_rat(k) = 2.0*max(drr,0.0) / (dris + abs(drr))
400 strat_rat(nz+1) = 1.0
402 z_int_unst = 0.0 ; fn_now = 0.0
403 fn_zero_val = min(2.0*cs%halocline_strat_tol, &
404 0.5*(1.0 + cs%halocline_strat_tol))
405 if (cs%halocline_strat_tol > 0.0)
then
407 i_hstol = 0.0 ;
if (fn_zero_val - cs%halocline_strat_tol > 0.0) &
408 i_hstol = 1.0 / (fn_zero_val - cs%halocline_strat_tol)
409 do k=nz,1,-1 ;
if (cs%ref_pressure > p_is(k+1))
then
410 z_int_unst = z_int_unst + fn_now * h_col(k)
411 if (strat_rat(k) <= fn_zero_val)
then
412 if (strat_rat(k) <= cs%halocline_strat_tol)
then ; fn_now = 1.0
414 fn_now = max(fn_now, (fn_zero_val - strat_rat(k)) * i_hstol)
419 do k=nz,1,-1 ;
if (cs%ref_pressure > p_is(k+1))
then
420 z_int_unst = z_int_unst + fn_now * h_col(k)
421 if (strat_rat(k) <= cs%halocline_strat_tol) fn_now = 1.0
425 if (z_interior < z_int_unst)
then
427 kur1 = max(int(ceiling(k_interior)),2)
428 if (z_col_new(kur1-1) < z_interior)
then
430 do k = kur1,nz+1 ;
if (z_col_new(k) >= z_int_unst)
then
432 if (z_col_new(k-1) >= z_int_unst) &
433 call mom_error(fatal,
"build_grid_SLight, bad halocline structure.")
434 k_int2 = real(k-1) + (z_int_unst - z_col_new(k-1)) / &
435 (z_col_new(k) - z_col_new(k-1))
438 if (z_col_new(nz+1) < z_int_unst)
then
440 z_int_unst = z_col_new(nz+1) ; k_int2 = real(nz+1)
444 if (k_int2 > k_interior)
then
445 k_interior = k_int2 ; z_interior = z_int_unst
453 z_col_new(k) = min((k-1)*cs%dz_ml_min, &
454 z_col_new(nz+1) - cs%min_thickness*(nz+1-k))
456 z_ml_fix = z_col_new(nkml+1)
457 if (z_interior > z_ml_fix)
then
458 dz_dk = (z_interior - z_ml_fix) / (k_interior - (nkml+1))
459 do k=nkml+2,int(floor(k_interior))
460 z_col_new(k) = z_ml_fix + dz_dk * (k - (nkml+1))
464 if (z_col_new(k) <= z_col_new(cs%nz_fixed_surface+1))
then
465 z_col_new(k) = z_col_new(cs%nz_fixed_surface+1)
470 if (maximum_depths_set .and. maximum_h_set)
then ;
do k=2,nz
473 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k), &
474 z_col_new(k-1) + cs%max_layer_thickness(k-1))
475 enddo ;
elseif (maximum_depths_set)
then ;
do k=2,nz
476 z_col_new(k) = min(z_col_new(k), cs%max_interface_depths(k))
477 enddo ;
elseif (maximum_h_set)
then ;
do k=2,nz
478 z_col_new(k) = min(z_col_new(k), z_col_new(k-1) + cs%max_layer_thickness(k-1))
483 end subroutine build_slight_column
487 subroutine rho_interfaces_col(rho_col, h_col, z_col, rho_tgt, nz, z_col_new, &
488 CS, reliable, debug, h_neglect, h_neglect_edge)
489 integer,
intent(in) :: nz
490 real,
dimension(nz),
intent(in) :: rho_col
491 real,
dimension(nz),
intent(in) :: h_col
492 real,
dimension(nz+1),
intent(in) :: z_col
493 real,
dimension(nz+1),
intent(in) :: rho_tgt
494 real,
dimension(nz+1),
intent(inout) :: z_col_new
496 logical,
dimension(nz+1),
intent(inout) :: reliable
498 logical,
optional,
intent(in) :: debug
499 real,
optional,
intent(in) :: h_neglect
501 real,
optional,
intent(in) :: h_neglect_edge
504 real,
dimension(nz+1) :: ru_max_int
505 real,
dimension(nz+1) :: ru_min_int
506 real,
dimension(nz) :: ru_max_lay
507 real,
dimension(nz) :: ru_min_lay
508 real,
dimension(nz,2) :: ppoly_i_E
509 real,
dimension(nz,2) :: ppoly_i_S
510 real,
dimension(nz,DEGREE_MAX+1) :: ppoly_i_coefficients
511 logical,
dimension(nz) :: unstable_lay
512 logical,
dimension(nz+1) :: unstable_int
520 real :: sgn, delta_zf, zf_prev
524 integer :: ppoly_degree
525 integer :: k, k1, k1_min, itt, max_itt, m
530 debugging = .false. ;
if (
present(debug)) debugging = debug
531 max_itt = nr_iterations
534 z_sgn = 1.0 ;
if ( z_col(1) > z_col(nz+1) ) z_sgn = -1.0
537 if (abs((z_col(k+1) - z_col(k)) - z_sgn*h_col(k)) > &
538 1.0e-14*(abs(z_col(k+1)) + abs(z_col(k)) + abs(h_col(k))) ) &
539 call mom_error(fatal,
"rho_interfaces_col: Inconsistent z_col and h_col")
543 if ( z_col(1) == z_col(nz+1) )
then
545 do k=1,nz+1 ; z_col_new(k) = z_col(1) ; reliable(k) = .true. ;
enddo
550 call regridding_set_ppolys(cs%interp_CS, rho_col, nz, h_col, ppoly_i_e, ppoly_i_s, &
551 ppoly_i_coefficients, ppoly_degree, h_neglect, h_neglect_edge)
557 unstable_int(1) = .false.
558 ru_max_int(1) = ppoly_i_e(1,1)
560 unstable_lay(1) = (ppoly_i_e(1,1) > ppoly_i_e(1,2))
561 ru_max_lay(1) = max(ppoly_i_e(1,1), ppoly_i_e(1,2))
564 unstable_int(k) = (ppoly_i_e(k-1,2) > ppoly_i_e(k,1))
565 ru_max_int(k) = max(ppoly_i_e(k-1,2), ppoly_i_e(k,1))
566 ru_min_int(k) = min(ppoly_i_e(k-1,2), ppoly_i_e(k,1))
567 if (unstable_int(k) .and. unstable_lay(k-1)) &
568 ru_max_int(k) = max(ru_max_lay(k-1), ru_max_int(k))
570 unstable_lay(k) = (ppoly_i_e(k,1) > ppoly_i_e(k,2))
571 ru_max_lay(k) = max(ppoly_i_e(k,1), ppoly_i_e(k,2))
572 ru_min_lay(k) = min(ppoly_i_e(k,1), ppoly_i_e(k,2))
573 if (unstable_lay(k) .and. unstable_int(k)) &
574 ru_max_lay(k) = max(ru_max_int(k), ru_max_lay(k))
576 unstable_int(nz+1) = .false.
577 ru_min_int(nz+1) = ppoly_i_e(nz,2)
580 if (unstable_lay(k) .and. unstable_int(k+1)) &
581 ru_min_lay(k) = min(ru_min_int(k+1), ru_min_lay(k))
583 if (unstable_int(k) .and. unstable_lay(k)) &
584 ru_min_int(k) = min(ru_min_lay(k), ru_min_int(k))
587 z_col_new(1) = z_col(1) ; reliable(1) = .true.
595 if (rt <= ppoly_i_e(k1_min,1))
then
596 z_col_new(k) = z_col(k1_min)
599 elseif (k1_min == nz+1)
then
600 z_col_new(k) = z_col(nz+1)
603 if (unstable_int(k) .and. (rt >= ru_min_int(k)) .and. (rt <= ru_max_int(k)))
then
605 z_col_new(k) = z_col(k) ; reliable(k) = .false.
606 k1_min = k ; k_found = .true.
607 elseif ((rt >= ppoly_i_e(k-1,2)) .and. (rt <= ppoly_i_e(k,1)))
then
609 z_col_new(k) = z_col(k) ; reliable(k) = .true.
610 k1_min = k ; k_found = .true.
611 elseif (rt < ppoly_i_e(k-1,2))
then
614 if ((rt < ppoly_i_e(k1,2)) .and. (rt > ppoly_i_e(k1,1)))
then
617 k1_min = k1 ; k_found = .true. ;
exit
618 elseif (unstable_lay(k1) .and. (rt >= ru_min_lay(k1)) .and. (rt <= ru_max_lay(k1)))
then
621 z_col_new(k) = z_col(k1+1) ; reliable(k) = .false.
622 k1_min = k1 ; k_found = .true. ;
exit
625 if (k1 > 1)
then ;
if ((rt <= ppoly_i_e(k1,1)) .and. (rt >= ppoly_i_e(k1-1,2)))
then
627 z_col_new(k) = z_col(k1) ; reliable(k) = .true.
628 k1_min = k1 ; k_found = .true. ;
exit
629 elseif (unstable_int(k1) .and. (rt >= ru_min_int(k1)) .and. (rt <= ru_max_int(k1)))
then
632 z_col_new(k) = z_col(k1) ; reliable(k) = .false.
633 k1_min = k1 ; k_found = .true. ;
exit
637 if (.not.k_found)
then
640 z_col_new(k) = z_col(k1_min)
642 z_col_new(k) = z_col(k1_min)
648 if ((rt < ppoly_i_e(k1,2)) .and. (rt > ppoly_i_e(k1,1)))
then
651 k1_min = k1 ; k_found = .true. ;
exit
652 elseif (unstable_lay(k1) .and. (rt >= ru_min_lay(k1)) .and. (rt <= ru_max_lay(k1)))
then
655 z_col_new(k) = z_col(k1)
656 reliable(k) = .false.
657 k1_min = k1 ; k_found = .true. ;
exit
659 if (k1 < nz)
then ;
if ((rt <= ppoly_i_e(k1+1,1)) .and. (rt >= ppoly_i_e(k1,2)))
then
662 z_col_new(k) = z_col(k1+1) ; reliable(k) = .true.
663 k1_min = k1+1 ; k_found = .true. ;
exit
664 elseif (unstable_int(k1+1) .and. (rt >= ru_min_int(k1+1)) .and. (rt <= ru_max_int(k1+1)))
then
667 z_col_new(k) = z_col(k1+1)
668 reliable(k) = .false.
669 k1_min = k1+1 ; k_found = .true. ;
exit
672 if (.not.k_found)
then
673 z_col_new(k) = z_col(nz+1)
674 if (rt >= ppoly_i_e(nz,2))
then
677 reliable(k) = .false.
682 if (k_layer > 0)
then
684 if (.not.(ppoly_i_e(k1,2) > ppoly_i_e(k1,1)))
call mom_error(fatal, &
685 "build_grid_SLight: Erroneously searching for an interface in an unstratified layer.")
688 zf = (rt - ppoly_i_e(k1,1)) / (ppoly_i_e(k1,2) - ppoly_i_e(k1,1))
690 if (ppoly_degree > 1)
then
691 a(:) = 0.0 ; a(1) = ppoly_i_coefficients(k_layer,1) - rt
692 do m=2,ppoly_degree+1 ; a(m) = ppoly_i_coefficients(k_layer,m) ;
enddo
694 zf1 = 0.0 ; rfn1 = a(1)
695 zf2 = 1.0 ; rfn2 = a(1) + (a(2) + (a(3) + (a(4) + a(5))))
696 if (rfn1 * rfn2 > 0.0)
call mom_error(fatal,
"build_grid_SLight: Bad bracketing.")
699 rfn = a(1) + zf*(a(2) + zf*(a(3) + zf*(a(4) + zf*a(5))))
701 if (rfn * rfn1 > 0.0)
then
702 zf1 = zf ; rfn1 = rfn
704 zf2 = zf ; rfn2 = rfn
706 if (rfn1 == rfn2)
exit
708 drfn_dzf = (a(2) + zf*(2.0*a(3) + zf*(3.0*a(4) + zf*4.0*a(5))))
709 sgn = 1.0 ;
if (drfn_dzf < 0.0) sgn = -1.0
711 if ((sgn*(zf - rfn) >= zf1 * abs(drfn_dzf)) .and. &
712 (sgn*(zf - rfn) <= zf2 * abs(drfn_dzf)))
then
713 delta_zf = -rfn / drfn_dzf
717 zf = ( rfn2 * zf1 - rfn1 * zf2 ) / (rfn2 - rfn1)
718 delta_zf = zf - zf_prev
721 if (abs(delta_zf) < tol)
exit
724 z_col_new(k) = z_col(k_layer) + zf * z_sgn * h_col(k_layer)
731 z_col_new(nz+1) = z_col(nz+1) ; reliable(nz+1) = .true.
733 end subroutine rho_interfaces_col