17 implicit none ;
private 29 logical :: boundary_extrapolation
72 ppoly0_coefficients, degree)
74 real,
dimension(:),
intent(in) :: densities
75 integer,
intent(in) :: n0
76 real,
dimension(:),
intent(in) :: h0
77 real,
dimension(:,:),
intent(inout) :: ppoly0_E
78 real,
dimension(:,:),
intent(inout) :: ppoly0_S
79 real,
dimension(:,:),
intent(inout) :: ppoly0_coefficients
80 integer,
intent(inout) :: degree
82 logical :: extrapolate
87 ppoly0_coefficients(:,:) = 0.0
89 extrapolate = cs%boundary_extrapolation
92 select case (cs%interpolation_scheme)
96 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
105 call edge_values_explicit_h4( n0, h0, densities, ppoly0_e )
107 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
110 if (extrapolate)
then 119 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
122 if (extrapolate)
then 129 if (extrapolate)
then 136 call edge_values_explicit_h4( n0, h0, densities, ppoly0_e )
138 if (extrapolate)
then 143 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
145 if (extrapolate)
then 155 if (extrapolate)
then 160 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
162 if (extrapolate)
then 172 call p3m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
173 if (extrapolate)
then 178 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
180 if (extrapolate)
then 190 call p3m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
191 if (extrapolate)
then 196 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
198 if (extrapolate)
then 209 if (extrapolate)
then 214 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
216 if (extrapolate)
then 227 if (extrapolate)
then 232 call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
234 if (extrapolate)
then 246 subroutine interpolate_grid( n0, h0, x0, ppoly0_E, ppoly0_coefficients, target_values, degree, n1, h1, x1 )
248 integer,
intent(in) :: n0
249 real,
dimension(:),
intent(in) :: h0
250 real,
dimension(:),
intent(in) :: x0
251 real,
dimension(:,:),
intent(in) :: ppoly0_E
252 real,
dimension(:,:),
intent(in) :: ppoly0_coefficients
253 real,
dimension(:),
intent(in) :: target_values
254 integer,
intent(in) :: degree
255 integer,
intent(in) :: n1
256 real,
dimension(:),
intent(inout) :: h1
257 real,
dimension(:),
intent(inout) :: x1
272 h1(k-1) = x1(k) - x1(k-1)
274 h1(n1) = x1(n1+1) - x1(n1)
280 real,
dimension(:),
intent(in) :: densities, target_values
281 integer,
intent(in) :: n0, n1
282 real,
dimension(:),
intent(in) :: h0, x0
283 real,
dimension(:),
intent(inout) :: h1, x1
285 real,
dimension(n0,2) :: ppoly0_E, ppoly0_S
286 real,
dimension(n0,DEGREE_MAX+1) :: ppoly0_C
291 call interpolate_grid(n0, h0, x0, ppoly0_e, ppoly0_c, target_values, degree, &
312 target_value, degree )
result ( x_tgt )
314 integer,
intent(in) :: N
315 real,
dimension(:),
intent(in) :: h
316 real,
dimension(:),
intent(in) :: x_g
317 real,
dimension(:,:),
intent(in) :: ppoly_E
318 real,
dimension(:,:),
intent(in) :: ppoly_coefficients
319 real,
intent(in) :: target_value
320 integer,
intent(in) :: degree
329 real,
dimension(DEGREE_MAX) :: a
344 if ( target_value <= ppoly_e(1,1) )
then 352 if ( ( target_value >= ppoly_e(k-1,2) ) .AND. &
353 ( target_value <= ppoly_e(k,1) ) )
then 363 if ( target_value >= ppoly_e(n,2) )
then 374 if ( ( target_value > ppoly_e(k,1) ) .AND. &
375 ( target_value < ppoly_e(k,2) ) )
then 386 if ( k_found == -1 )
then 387 write(*,*) target_value, ppoly_e(1,1), ppoly_e(n,2)
388 write(*,*)
'Could not find target coordinate in ' //&
389 '"get_polynomial_coordinate". This is caused by an '//&
390 'inconsistent interpolant (perhaps not monotonically '//&
392 call mom_error( fatal,
'Aborting execution' )
399 a(i) = ppoly_coefficients(k_found,i)
415 numerator = a(1) + a(2)*xi0 + a(3)*xi0*xi0 + a(4)*xi0*xi0*xi0 + &
416 a(5)*xi0*xi0*xi0*xi0 - target_value
418 denominator = a(2) + 2*a(3)*xi0 + 3*a(4)*xi0*xi0 + 4*a(5)*xi0*xi0*xi0
420 delta = -numerator / denominator
429 if ( xi0 < 0.0 )
then 432 if ( grad == 0.0 ) xi0 = xi0 + eps
435 if ( xi0 > 1.0 )
then 437 grad = a(2) + 2*a(3) + 3*a(4) + 4*a(5)
438 if ( grad == 0.0 ) xi0 = xi0 - eps
444 x_tgt = x_g(k_found) + xi0 * h(k_found)
449 character(len=*),
intent(in) :: interp_scheme
451 select case (
uppercase(trim(interp_scheme)) )
462 case default ;
call mom_error(fatal,
"regrid_interp: "//&
463 "Unrecognized choice for INTERPOLATION_SCHEME ("//trim(interp_scheme)//
").")
469 character(len=*),
intent(in) :: interp_scheme
476 logical,
intent(in) :: extrapolation
478 cs%boundary_extrapolation = extrapolation
subroutine, public edge_values_implicit_h6(N, h, u, edge_values)
subroutine, public edge_values_implicit_h4(N, h, u, edge_values)
integer function interpolation_scheme(interp_scheme)
Numeric value of interpolation_scheme corresponding to scheme name.
integer, parameter interpolation_p3m_ih6ih5
O(h^4)
integer, parameter degree_3
integer, parameter interpolation_p1m_ih4
O(h^2)
integer, parameter interpolation_p1m_h4
O(h^2)
subroutine, public pqm_boundary_extrapolation_v1(N, h, u, ppoly_E, ppoly_S, ppoly_coefficients)
subroutine, public set_interp_scheme(CS, interp_scheme)
subroutine, public p1m_boundary_extrapolation(N, h, u, ppoly_E, ppoly_coefficients)
integer, parameter interpolation_plm
O(h^2)
subroutine, public pqm_reconstruction(N, h, u, ppoly_E, ppoly_S, ppoly_coefficients)
Provides functions used with the Piecewise-Parabolic-Method in the vertical ALE algorithm.
integer, parameter interpolation_p1m_h2
O(h^2)
integer, parameter degree_1
List of interpolant degrees.
subroutine, public build_and_interpolate_grid(CS, densities, n0, h0, x0, target_values, n1, h1, x1)
integer, parameter interpolation_ppm_h4
O(h^3)
integer, parameter degree_2
subroutine, public p1m_interpolation(N, h, u, ppoly_E, ppoly_coefficients)
subroutine, public regridding_set_ppolys(CS, densities, n0, h0, ppoly0_E, ppoly0_S, ppoly0_coefficients, degree)
Given the set of target values and cell densities, this routine builds an interpolated profile for th...
subroutine, public ppm_reconstruction(N, h, u, ppoly_E, ppoly_coefficients)
Builds quadratic polynomials coefficients from cell mean and edge values.
character(len=len(input_string)) function, public uppercase(input_string)
subroutine, public edge_slopes_implicit_h3(N, h, u, edge_slopes)
subroutine, public p3m_interpolation(N, h, u, ppoly_E, ppoly_S, ppoly_coefficients)
integer, parameter, public nr_iterations
Maximum number of Newton-Raphson iterations. Newton-Raphson iterations are used to build the new grid...
integer, parameter degree_4
subroutine, public edge_slopes_implicit_h5(N, h, u, edge_slopes)
subroutine, public interpolate_grid(n0, h0, x0, ppoly0_E, ppoly0_coefficients, target_values, degree, n1, h1, x1)
Given target values (e.g., density), build new grid based on polynomial.
subroutine, public edge_values_explicit_h2(N, h, u, edge_values)
subroutine, public plm_boundary_extrapolation(N, h, u, ppoly_E, ppoly_coefficients)
subroutine, public plm_reconstruction(N, h, u, ppoly_E, ppoly_coefficients)
integer, parameter interpolation_pqm_ih6ih5
O(h^5)
integer, parameter interpolation_ppm_ih4
O(h^3)
integer, parameter, public degree_max
real, parameter, public nr_tolerance
Tolerance for Newton-Raphson iterations (stop when increment falls below this)
subroutine, public ppm_boundary_extrapolation(N, h, u, ppoly_E, ppoly_coefficients)
integer, parameter interpolation_p3m_ih4ih3
O(h^4)
real function get_polynomial_coordinate(N, h, x_g, ppoly_E, ppoly_coefficients, target_value, degree)
Given a target value, find corresponding coordinate for given polynomial.
subroutine, public mom_error(level, message, all_print)
real, parameter, public nr_offset
When the N-R algorithm produces an estimate that lies outside [0,1], the estimate is set to be equal ...
subroutine, public set_interp_extrap(CS, extrapolation)
subroutine, public p3m_boundary_extrapolation(N, h, u, ppoly_E, ppoly_S, ppoly_coefficients)
subroutine, public edge_values_explicit_h4(N, h, u, edge_values)
integer, parameter interpolation_pqm_ih4ih3
O(h^4)