9 implicit none ;
private 26 logical :: integrate_downward_for_e
29 real,
allocatable,
dimension(:) :: target_density
46 subroutine init_coord_rho(CS, nk, ref_pressure, target_density, interp_CS)
48 integer,
intent(in) :: nk
49 real,
intent(in) :: ref_pressure
50 real,
dimension(:),
intent(in) :: target_density
53 if (
associated(cs))
call mom_error(fatal,
"init_coord_rho: CS already associated!")
55 allocate(cs%target_density(nk+1))
58 cs%ref_pressure = ref_pressure
59 cs%target_density(:) = target_density(:)
60 cs%interp_CS = interp_cs
67 if (.not.
associated(cs))
return 68 deallocate(cs%target_density)
72 subroutine set_rho_params(CS, min_thickness, integrate_downward_for_e, interp_CS)
74 real,
optional,
intent(in) :: min_thickness
75 logical,
optional,
intent(in) :: integrate_downward_for_e
78 if (.not.
associated(cs))
call mom_error(fatal,
"set_rho_params: CS not associated")
80 if (
present(min_thickness)) cs%min_thickness = min_thickness
81 if (
present(integrate_downward_for_e)) cs%integrate_downward_for_e = integrate_downward_for_e
82 if (
present(interp_cs)) cs%interp_CS = interp_cs
85 subroutine build_rho_column(CS, remapCS, nz, depth, h, T, S, eqn_of_state, zInterface)
99 type(
rho_cs),
intent(in) :: CS
101 integer,
intent(in) :: nz
102 real,
intent(in) :: depth
103 real,
dimension(nz),
intent(in) :: h
104 real,
dimension(nz),
intent(in) :: T, S
105 type(
eos_type),
pointer :: eqn_of_state
106 real,
dimension(nz+1),
intent(inout) :: zInterface
112 integer :: count_nonzero_layers
117 real :: max_thickness
119 real,
dimension(nz) :: p, densities, T_tmp, S_tmp, Tmp
120 integer,
dimension(nz) :: mapping
122 real,
dimension(nz) :: h0, h1, hTmp
123 real,
dimension(nz+1) :: x0, x1, xTmp
125 threshold = cs%min_thickness
126 p(:) = cs%ref_pressure
138 count_nonzero_layers = 0
140 if ( h0(k) > threshold )
then 141 count_nonzero_layers = count_nonzero_layers + 1
146 if ( count_nonzero_layers <= 1 )
then 155 if ( h0(k) > threshold )
then 156 mapping(map_index) = k
157 htmp(map_index) = h0(k)
158 map_index = map_index + 1
160 correction = correction + h0(k)
164 max_thickness = htmp(1)
166 do k = 1,count_nonzero_layers
167 if ( htmp(k) > max_thickness )
then 168 max_thickness = htmp(k)
173 htmp(k_found) = htmp(k_found) + correction
176 do k = 1,count_nonzero_layers
177 xtmp(k+1) = xtmp(k) + htmp(k)
182 1, nz, eqn_of_state )
184 do k = 1,count_nonzero_layers
185 densities(k) = densities(mapping(k))
191 htmp, xtmp, cs%target_density, nz, h1, x1)
194 x1(1) = 0.0 ;
do k = 1,nz ; x1(k+1) = x1(k) + h1(k) ;
end do 198 h1(k) = x1(k+1) - x1(k)
212 x0(k) = x0(k-1) + h0(k-1)
213 x1(k) = x1(k-1) + h1(k-1)
214 deviation = deviation + (x0(k)-x1(k))**2
216 deviation = sqrt( deviation / (nz-1) )
225 if (cs%integrate_downward_for_e)
then 228 zinterface(k+1) = zinterface(k) - h1(k)
234 zinterface(nz+1) = -depth
236 zinterface(k) = zinterface(k+1) + h1(k)
250 real,
intent(in) :: minThickness
251 integer,
intent(in) :: N
252 real,
intent(inout) :: h(:)
257 integer :: count_nonzero_layers
263 count_nonzero_layers = 0
265 if ( h(k) > minthickness )
then 266 count_nonzero_layers = count_nonzero_layers + 1
271 if ( count_nonzero_layers == n )
return 274 if ( count_nonzero_layers == 0 )
then 284 if ( h(k) <= minthickness )
then 285 delta = minthickness - h(k)
286 correction = correction + delta
295 if ( h(k) > maxthickness )
then 301 h(k_found) = h(k_found) - correction
Control structure containing required parameters for the rho coordinate.
subroutine, public old_inflate_layers_1d(minThickness, N, h)
Calculates density of sea water from T, S and P.
Provides column-wise vertical remapping functions.
subroutine, public end_coord_rho(CS)
subroutine, public set_rho_params(CS, min_thickness, integrate_downward_for_e, interp_CS)
subroutine, public build_and_interpolate_grid(CS, densities, n0, h0, x0, target_values, n1, h1, x1)
Container for remapping parameters.
subroutine, public build_rho_column(CS, remapCS, nz, depth, h, T, S, eqn_of_state, zInterface)
integer, parameter nb_regridding_iterations
Maximum number of regridding iterations.
Provides subroutines for quantities specific to the equation of state.
subroutine, public remapping_core_h(CS, n0, h0, u0, n1, h1, u1)
Remaps column of values u0 on grid h0 to grid h1 assuming the top edge is aligned.
Regrid columns for the continuous isopycnal (rho) coordinate.
integer, parameter, public degree_max
subroutine, public mom_error(level, message, all_print)
subroutine, public init_coord_rho(CS, nk, ref_pressure, target_density, interp_CS)
Initialise a rho_CS with pointers to parameters.
A control structure for the equation of state.
real, parameter deviation_tolerance
Deviation tolerance between succesive grids in regridding iterations.