MOM6
regrid_interp Module Reference

Data Types

type  interp_cs_type
 

Functions/Subroutines

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 the densities within each grid cell. It may happen that, given a high-order interpolator, the number of available layers is insufficient (e.g., there are two available layers for a third-order PPM ih4 scheme). In these cases, we resort to the simplest continuous linear scheme (P1M h2). More...
 
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. More...
 
subroutine, public build_and_interpolate_grid (CS, densities, n0, h0, x0, target_values, n1, h1, x1)
 
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. More...
 
integer function interpolation_scheme (interp_scheme)
 Numeric value of interpolation_scheme corresponding to scheme name. More...
 
subroutine, public set_interp_scheme (CS, interp_scheme)
 
subroutine, public set_interp_extrap (CS, extrapolation)
 

Variables

integer, parameter interpolation_p1m_h2 = 0
 O(h^2) More...
 
integer, parameter interpolation_p1m_h4 = 1
 O(h^2) More...
 
integer, parameter interpolation_p1m_ih4 = 2
 O(h^2) More...
 
integer, parameter interpolation_plm = 3
 O(h^2) More...
 
integer, parameter interpolation_ppm_h4 = 4
 O(h^3) More...
 
integer, parameter interpolation_ppm_ih4 = 5
 O(h^3) More...
 
integer, parameter interpolation_p3m_ih4ih3 = 6
 O(h^4) More...
 
integer, parameter interpolation_p3m_ih6ih5 = 7
 O(h^4) More...
 
integer, parameter interpolation_pqm_ih4ih3 = 8
 O(h^4) More...
 
integer, parameter interpolation_pqm_ih6ih5 = 9
 O(h^5) More...
 
integer, parameter degree_1 = 1
 List of interpolant degrees. More...
 
integer, parameter degree_2 = 2
 
integer, parameter degree_3 = 3
 
integer, parameter degree_4 = 4
 
integer, parameter, public degree_max = 5
 
real, parameter, public nr_offset = 1e-6
 When the N-R algorithm produces an estimate that lies outside [0,1], the estimate is set to be equal to the boundary location, 0 or 1, plus or minus an offset, respectively, when the derivative is zero at the boundary. More...
 
integer, parameter, public nr_iterations = 8
 Maximum number of Newton-Raphson iterations. Newton-Raphson iterations are used to build the new grid by finding the coordinates associated with target densities and interpolations of degree larger than 1. More...
 
real, parameter, public nr_tolerance = 1e-12
 Tolerance for Newton-Raphson iterations (stop when increment falls below this) More...
 

Function/Subroutine Documentation

◆ build_and_interpolate_grid()

subroutine, public regrid_interp::build_and_interpolate_grid ( type(interp_cs_type), intent(in)  CS,
real, dimension(:), intent(in)  densities,
integer, intent(in)  n0,
real, dimension(:), intent(in)  h0,
real, dimension(:), intent(in)  x0,
real, dimension(:), intent(in)  target_values,
integer, intent(in)  n1,
real, dimension(:), intent(inout)  h1,
real, dimension(:), intent(inout)  x1 
)

Definition at line 279 of file regrid_interp.F90.

References interpolate_grid(), and regridding_set_ppolys().

Referenced by coord_hycom::build_hycom1_column(), and coord_rho::build_rho_column().

279  type(interp_cs_type), intent(in) :: cs
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
284 
285  real, dimension(n0,2) :: ppoly0_e, ppoly0_s
286  real, dimension(n0,DEGREE_MAX+1) :: ppoly0_c
287  integer :: degree
288 
289  call regridding_set_ppolys(cs, densities, n0, h0, ppoly0_e, ppoly0_s, ppoly0_c, &
290  degree)
291  call interpolate_grid(n0, h0, x0, ppoly0_e, ppoly0_c, target_values, degree, &
292  n1, h1, x1)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_polynomial_coordinate()

real function regrid_interp::get_polynomial_coordinate ( integer, intent(in)  N,
real, dimension(:), intent(in)  h,
real, dimension(:), intent(in)  x_g,
real, dimension(:,:), intent(in)  ppoly_E,
real, dimension(:,:), intent(in)  ppoly_coefficients,
real, intent(in)  target_value,
integer, intent(in)  degree 
)
private

Given a target value, find corresponding coordinate for given polynomial.

Here, 'ppoly' is assumed to be a piecewise discontinuous polynomial of degree 'degree' throughout the domain defined by 'grid'. A target value is given and we need to determine the corresponding grid coordinate to define the new grid.

If the target value is out of range, the grid coordinate is simply set to be equal to one of the boundary coordinates, which results in vanished layers near the boundaries.

IT IS ASSUMED THAT THE PIECEWISE POLYNOMIAL IS MONOTONICALLY INCREASING. IF THIS IS NOT THE CASE, THE NEW GRID MAY BE ILL-DEFINED.

It is assumed that the number of cells defining 'grid' and 'ppoly' are the same.

Parameters
[in]nNumber of grid cells
[in]hGrid cell thicknesses
[in]x_gGrid interface locations
[in]ppoly_eEdge values of interpolating polynomials
[in]ppoly_coefficientsCoefficients of interpolating polynomials
[in]target_valueTarget value to find position for
[in]degreeDegree of the interpolating polynomials
Returns
The position of x_g at which target_value is found.

Definition at line 313 of file regrid_interp.F90.

References mom_error_handler::mom_error(), nr_iterations, nr_offset, and nr_tolerance.

Referenced by interpolate_grid().

313  ! Arguments
314  integer, intent(in) :: n !< Number of grid cells
315  real, dimension(:), intent(in) :: h !< Grid cell thicknesses
316  real, dimension(:), intent(in) :: x_g !< Grid interface locations
317  real, dimension(:,:), intent(in) :: ppoly_e !< Edge values of interpolating polynomials
318  real, dimension(:,:), intent(in) :: ppoly_coefficients !< Coefficients of interpolating polynomials
319  real, intent(in) :: target_value !< Target value to find position for
320  integer, intent(in) :: degree !< Degree of the interpolating polynomials
321 
322  real :: x_tgt !< The position of x_g at which target_value is found.
323 
324  ! Local variables
325  integer :: i, k ! loop indices
326  integer :: k_found ! index of target cell
327  integer :: iter
328  real :: xi0 ! normalized target coordinate
329  real, dimension(DEGREE_MAX) :: a ! polynomial coefficients
330  real :: numerator
331  real :: denominator
332  real :: delta ! Newton-Raphson increment
333  real :: x ! global target coordinate
334  real :: eps ! offset used to get away from
335  ! boundaries
336  real :: grad ! gradient during N-R iterations
337 
338  eps = nr_offset
339  k_found = -1
340 
341  ! If the target value is outside the range of all values, we
342  ! force the target coordinate to be equal to the lowest or
343  ! largest value, depending on which bound is overtaken
344  if ( target_value <= ppoly_e(1,1) ) then
345  x_tgt = x_g(1)
346  return ! return because there is no need to look further
347  end if
348 
349  ! Since discontinuous edge values are allowed, we check whether the target
350  ! value lies between two discontinuous edge values at interior interfaces
351  do k = 2,n
352  if ( ( target_value >= ppoly_e(k-1,2) ) .AND. &
353  ( target_value <= ppoly_e(k,1) ) ) then
354  x_tgt = x_g(k)
355  return ! return because there is no need to look further
356  exit
357  end if
358  end do
359 
360  ! If the target value is outside the range of all values, we
361  ! force the target coordinate to be equal to the lowest or
362  ! largest value, depending on which bound is overtaken
363  if ( target_value >= ppoly_e(n,2) ) then
364  x_tgt = x_g(n+1)
365  return ! return because there is no need to look further
366  end if
367 
368  ! At this point, we know that the target value is bounded and does not
369  ! lie between discontinuous, monotonic edge values. Therefore,
370  ! there is a unique solution. We loop on all cells and find which one
371  ! contains the target value. The variable k_found holds the index value
372  ! of the cell where the taregt value lies.
373  do k = 1,n
374  if ( ( target_value > ppoly_e(k,1) ) .AND. &
375  ( target_value < ppoly_e(k,2) ) ) then
376  k_found = k
377  exit
378  end if
379  end do
380 
381  ! At this point, 'k_found' should be strictly positive. If not, this is
382  ! a major failure because it means we could not find any target cell
383  ! despite the fact that the target value lies between the extremes. It
384  ! means there is a major problem with the interpolant. This needs to be
385  ! reported.
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 '//&
391  'increasing)'
392  call mom_error( fatal, 'Aborting execution' )
393  end if
394 
395  ! Reset all polynomial coefficients to 0 and copy those pertaining to
396  ! the found cell
397  a(:) = 0.0
398  do i = 1,degree+1
399  a(i) = ppoly_coefficients(k_found,i)
400  end do
401 
402  ! Guess value to start Newton-Raphson iterations (middle of cell)
403  xi0 = 0.5
404  iter = 1
405  delta = 1e10
406 
407  ! Newton-Raphson iterations
408  do
409  ! break if converged or too many iterations taken
410  if ( ( iter > nr_iterations ) .OR. &
411  ( abs(delta) < nr_tolerance ) ) then
412  exit
413  end if
414 
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
417 
418  denominator = a(2) + 2*a(3)*xi0 + 3*a(4)*xi0*xi0 + 4*a(5)*xi0*xi0*xi0
419 
420  delta = -numerator / denominator
421 
422  xi0 = xi0 + delta
423 
424  ! Check whether new estimate is out of bounds. If the new estimate is
425  ! indeed out of bounds, we manually set it to be equal to the overtaken
426  ! bound with a small offset towards the interior when the gradient of
427  ! the function at the boundary is zero (in which case, the Newton-Raphson
428  ! algorithm does not converge).
429  if ( xi0 < 0.0 ) then
430  xi0 = 0.0
431  grad = a(2)
432  if ( grad == 0.0 ) xi0 = xi0 + eps
433  end if
434 
435  if ( xi0 > 1.0 ) then
436  xi0 = 1.0
437  grad = a(2) + 2*a(3) + 3*a(4) + 4*a(5)
438  if ( grad == 0.0 ) xi0 = xi0 - eps
439  end if
440 
441  iter = iter + 1
442  end do ! end Newton-Raphson iterations
443 
444  x_tgt = x_g(k_found) + xi0 * h(k_found)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpolate_grid()

subroutine, public regrid_interp::interpolate_grid ( integer, intent(in)  n0,
real, dimension(:), intent(in)  h0,
real, dimension(:), intent(in)  x0,
real, dimension(:,:), intent(in)  ppoly0_E,
real, dimension(:,:), intent(in)  ppoly0_coefficients,
real, dimension(:), intent(in)  target_values,
integer, intent(in)  degree,
integer, intent(in)  n1,
real, dimension(:), intent(inout)  h1,
real, dimension(:), intent(inout)  x1 
)

Given target values (e.g., density), build new grid based on polynomial.

Given the grid 'grid0' and the piecewise polynomial interpolant 'ppoly0' (possibly discontinuous), the coordinates of the new grid 'grid1' are determined by finding the corresponding target interface densities.

Parameters
[in]n0Number of points on source grid
[in]h0Thicknesses of source grid cells
[in]x0Source interface positions
[in]ppoly0_eEdge values of interpolating polynomials
[in]ppoly0_coefficientsCoefficients of interpolating polynomials
[in]target_valuesTarget values of interfaces
[in]degreeDegree of interpolating polynomials
[in]n1Number of points on target grid
[in,out]h1Thicknesses of target grid cells
[in,out]x1Target interface positions

Definition at line 247 of file regrid_interp.F90.

References get_polynomial_coordinate().

Referenced by build_and_interpolate_grid().

247  ! Arguments
248  integer, intent(in) :: n0 !< Number of points on source grid
249  real, dimension(:), intent(in) :: h0 !< Thicknesses of source grid cells
250  real, dimension(:), intent(in) :: x0 !< Source interface positions
251  real, dimension(:,:), intent(in) :: ppoly0_e !< Edge values of interpolating polynomials
252  real, dimension(:,:), intent(in) :: ppoly0_coefficients !< Coefficients of interpolating polynomials
253  real, dimension(:), intent(in) :: target_values !< Target values of interfaces
254  integer, intent(in) :: degree !< Degree of interpolating polynomials
255  integer, intent(in) :: n1 !< Number of points on target grid
256  real, dimension(:), intent(inout) :: h1 !< Thicknesses of target grid cells
257  real, dimension(:), intent(inout) :: x1 !< Target interface positions
258 
259  ! Local variables
260  integer :: k ! loop index
261  real :: t ! current interface target density
262 
263  ! Make sure boundary coordinates of new grid coincide with boundary
264  ! coordinates of previous grid
265  x1(1) = x0(1)
266  x1(n1+1) = x0(n0+1)
267 
268  ! Find coordinates for interior target values
269  do k = 2,n1
270  t = target_values(k)
271  x1(k) = get_polynomial_coordinate( n0, h0, x0, ppoly0_e, ppoly0_coefficients, t, degree )
272  h1(k-1) = x1(k) - x1(k-1)
273  end do
274  h1(n1) = x1(n1+1) - x1(n1)
275 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpolation_scheme()

integer function regrid_interp::interpolation_scheme ( character(len=*), intent(in)  interp_scheme)
private

Numeric value of interpolation_scheme corresponding to scheme name.

Parameters
[in]interp_schemeName of interpolation scheme

Definition at line 449 of file regrid_interp.F90.

References interpolation_p1m_h2, interpolation_p1m_h4, interpolation_p1m_ih4, interpolation_p3m_ih4ih3, interpolation_p3m_ih6ih5, interpolation_plm, interpolation_ppm_h4, interpolation_ppm_ih4, interpolation_pqm_ih4ih3, interpolation_pqm_ih6ih5, mom_error_handler::mom_error(), and mom_string_functions::uppercase().

Referenced by set_interp_scheme().

449  character(len=*), intent(in) :: interp_scheme !< Name of interpolation scheme
450 
451  select case ( uppercase(trim(interp_scheme)) )
452  case ("P1M_H2"); interpolation_scheme = interpolation_p1m_h2
453  case ("P1M_H4"); interpolation_scheme = interpolation_p1m_h4
454  case ("P1M_IH2"); interpolation_scheme = interpolation_p1m_ih4
455  case ("PLM"); interpolation_scheme = interpolation_plm
456  case ("PPM_H4"); interpolation_scheme = interpolation_ppm_h4
457  case ("PPM_IH4"); interpolation_scheme = interpolation_ppm_ih4
458  case ("P3M_IH4IH3"); interpolation_scheme = interpolation_p3m_ih4ih3
459  case ("P3M_IH6IH5"); interpolation_scheme = interpolation_p3m_ih6ih5
460  case ("PQM_IH4IH3"); interpolation_scheme = interpolation_pqm_ih4ih3
461  case ("PQM_IH6IH5"); interpolation_scheme = interpolation_pqm_ih6ih5
462  case default ; call mom_error(fatal, "regrid_interp: "//&
463  "Unrecognized choice for INTERPOLATION_SCHEME ("//trim(interp_scheme)//").")
464  end select
Here is the call graph for this function:
Here is the caller graph for this function:

◆ regridding_set_ppolys()

subroutine, public regrid_interp::regridding_set_ppolys ( type(interp_cs_type), intent(in)  CS,
real, dimension(:), intent(in)  densities,
integer, intent(in)  n0,
real, dimension(:), intent(in)  h0,
real, dimension(:,:), intent(inout)  ppoly0_E,
real, dimension(:,:), intent(inout)  ppoly0_S,
real, dimension(:,:), intent(inout)  ppoly0_coefficients,
integer, intent(inout)  degree 
)

Given the set of target values and cell densities, this routine builds an interpolated profile for the densities within each grid cell. It may happen that, given a high-order interpolator, the number of available layers is insufficient (e.g., there are two available layers for a third-order PPM ih4 scheme). In these cases, we resort to the simplest continuous linear scheme (P1M h2).

Parameters
[in]csInterpolation control structure
[in]densitiesActual cell densities
[in]n0Number of cells on source grid
[in]h0cell widths on source grid
[in,out]ppoly0_eEdge value of polynomial
[in,out]ppoly0_sEdge slope of polynomial
[in,out]ppoly0_coefficientsCoefficients of polynomial
[in,out]degreeThe degree of the polynomials

Definition at line 73 of file regrid_interp.F90.

References degree_1, degree_2, degree_3, degree_4, regrid_edge_slopes::edge_slopes_implicit_h3(), regrid_edge_slopes::edge_slopes_implicit_h5(), regrid_edge_values::edge_values_implicit_h4(), regrid_edge_values::edge_values_implicit_h6(), interpolation_p1m_h2, interpolation_p1m_h4, interpolation_p1m_ih4, interpolation_p3m_ih4ih3, interpolation_p3m_ih6ih5, interpolation_plm, interpolation_ppm_h4, interpolation_ppm_ih4, interpolation_pqm_ih4ih3, interpolation_pqm_ih6ih5, p1m_functions::p1m_boundary_extrapolation(), p1m_functions::p1m_interpolation(), p3m_functions::p3m_boundary_extrapolation(), p3m_functions::p3m_interpolation(), plm_functions::plm_boundary_extrapolation(), plm_functions::plm_reconstruction(), ppm_functions::ppm_boundary_extrapolation(), ppm_functions::ppm_reconstruction(), pqm_functions::pqm_boundary_extrapolation_v1(), and pqm_functions::pqm_reconstruction().

Referenced by build_and_interpolate_grid().

73  type(interp_cs_type),intent(in) :: cs !< Interpolation control structure
74  real, dimension(:), intent(in) :: densities !< Actual cell densities
75  integer, intent(in) :: n0 !< Number of cells on source grid
76  real, dimension(:), intent(in) :: h0 !< cell widths on source grid
77  real, dimension(:,:),intent(inout) :: ppoly0_e !< Edge value of polynomial
78  real, dimension(:,:),intent(inout) :: ppoly0_s !< Edge slope of polynomial
79  real, dimension(:,:),intent(inout) :: ppoly0_coefficients !< Coefficients of polynomial
80  integer, intent(inout) :: degree !< The degree of the polynomials
81 
82  logical :: extrapolate
83 
84  ! Reset piecewise polynomials
85  ppoly0_e(:,:) = 0.0
86  ppoly0_s(:,:) = 0.0
87  ppoly0_coefficients(:,:) = 0.0
88 
89  extrapolate = cs%boundary_extrapolation
90 
91  ! Compute the interpolated profile of the density field and build grid
92  select case (cs%interpolation_scheme)
93 
94  case ( interpolation_p1m_h2 )
95  degree = degree_1
96  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
97  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
98  if (extrapolate) then
99  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
100  end if
101 
102  case ( interpolation_p1m_h4 )
103  degree = degree_1
104  if ( n0 >= 4 ) then
105  call edge_values_explicit_h4( n0, h0, densities, ppoly0_e )
106  else
107  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
108  end if
109  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
110  if (extrapolate) then
111  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
112  end if
113 
114  case ( interpolation_p1m_ih4 )
115  degree = degree_1
116  if ( n0 >= 4 ) then
117  call edge_values_implicit_h4( n0, h0, densities, ppoly0_e )
118  else
119  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
120  end if
121  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
122  if (extrapolate) then
123  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
124  end if
125 
126  case ( interpolation_plm )
127  degree = degree_1
128  call plm_reconstruction( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
129  if (extrapolate) then
130  call plm_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
131  end if
132 
133  case ( interpolation_ppm_h4 )
134  if ( n0 >= 4 ) then
135  degree = degree_2
136  call edge_values_explicit_h4( n0, h0, densities, ppoly0_e )
137  call ppm_reconstruction( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
138  if (extrapolate) then
139  call ppm_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
140  end if
141  else
142  degree = degree_1
143  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
144  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
145  if (extrapolate) then
146  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
147  end if
148  end if
149 
150  case ( interpolation_ppm_ih4 )
151  if ( n0 >= 4 ) then
152  degree = degree_2
153  call edge_values_implicit_h4( n0, h0, densities, ppoly0_e )
154  call ppm_reconstruction( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
155  if (extrapolate) then
156  call ppm_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
157  end if
158  else
159  degree = degree_1
160  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
161  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
162  if (extrapolate) then
163  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
164  end if
165  end if
166 
167  case ( interpolation_p3m_ih4ih3 )
168  if ( n0 >= 4 ) then
169  degree = degree_3
170  call edge_values_implicit_h4( n0, h0, densities, ppoly0_e )
171  call edge_slopes_implicit_h3( n0, h0, densities, ppoly0_s )
172  call p3m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
173  if (extrapolate) then
174  call p3m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
175  end if
176  else
177  degree = degree_1
178  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
179  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
180  if (extrapolate) then
181  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
182  end if
183  end if
184 
185  case ( interpolation_p3m_ih6ih5 )
186  if ( n0 >= 6 ) then
187  degree = degree_3
188  call edge_values_implicit_h6( n0, h0, densities, ppoly0_e )
189  call edge_slopes_implicit_h5( n0, h0, densities, ppoly0_s )
190  call p3m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
191  if (extrapolate) then
192  call p3m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
193  end if
194  else
195  degree = degree_1
196  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
197  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
198  if (extrapolate) then
199  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
200  end if
201  end if
202 
203  case ( interpolation_pqm_ih4ih3 )
204  if ( n0 >= 4 ) then
205  degree = degree_4
206  call edge_values_implicit_h4( n0, h0, densities, ppoly0_e )
207  call edge_slopes_implicit_h3( n0, h0, densities, ppoly0_s )
208  call pqm_reconstruction( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
209  if (extrapolate) then
210  call pqm_boundary_extrapolation_v1( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
211  end if
212  else
213  degree = degree_1
214  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
215  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
216  if (extrapolate) then
217  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
218  end if
219  end if
220 
221  case ( interpolation_pqm_ih6ih5 )
222  if ( n0 >= 6 ) then
223  degree = degree_4
224  call edge_values_implicit_h6( n0, h0, densities, ppoly0_e )
225  call edge_slopes_implicit_h5( n0, h0, densities, ppoly0_s )
226  call pqm_reconstruction( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
227  if (extrapolate) then
228  call pqm_boundary_extrapolation_v1( n0, h0, densities, ppoly0_e, ppoly0_s, ppoly0_coefficients )
229  end if
230  else
231  degree = degree_1
232  call edge_values_explicit_h2( n0, h0, densities, ppoly0_e )
233  call p1m_interpolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
234  if (extrapolate) then
235  call p1m_boundary_extrapolation( n0, h0, densities, ppoly0_e, ppoly0_coefficients )
236  end if
237  end if
238  end select
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_interp_extrap()

subroutine, public regrid_interp::set_interp_extrap ( type(interp_cs_type), intent(inout)  CS,
logical, intent(in)  extrapolation 
)

Definition at line 475 of file regrid_interp.F90.

475  type(interp_cs_type), intent(inout) :: cs
476  logical, intent(in) :: extrapolation
477 
478  cs%boundary_extrapolation = extrapolation

◆ set_interp_scheme()

subroutine, public regrid_interp::set_interp_scheme ( type(interp_cs_type), intent(inout)  CS,
character(len=*), intent(in)  interp_scheme 
)

Definition at line 468 of file regrid_interp.F90.

References interpolation_scheme().

468  type(interp_cs_type), intent(inout) :: cs
469  character(len=*), intent(in) :: interp_scheme
470 
471  cs%interpolation_scheme = interpolation_scheme(interp_scheme)
Here is the call graph for this function:

Variable Documentation

◆ degree_1

integer, parameter regrid_interp::degree_1 = 1
private

List of interpolant degrees.

Definition at line 49 of file regrid_interp.F90.

Referenced by regridding_set_ppolys().

49 integer, parameter :: degree_1 = 1, degree_2 = 2, degree_3 = 3, degree_4 = 4

◆ degree_2

integer, parameter regrid_interp::degree_2 = 2
private

Definition at line 49 of file regrid_interp.F90.

Referenced by regridding_set_ppolys().

◆ degree_3

integer, parameter regrid_interp::degree_3 = 3
private

Definition at line 49 of file regrid_interp.F90.

Referenced by regridding_set_ppolys().

◆ degree_4

integer, parameter regrid_interp::degree_4 = 4
private

Definition at line 49 of file regrid_interp.F90.

Referenced by regridding_set_ppolys().

◆ degree_max

integer, parameter, public regrid_interp::degree_max = 5

Definition at line 50 of file regrid_interp.F90.

50 integer, public, parameter :: degree_max = 5

◆ interpolation_p1m_h2

integer, parameter regrid_interp::interpolation_p1m_h2 = 0

O(h^2)

Definition at line 37 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

37 integer, parameter :: interpolation_p1m_h2 = 0 !< O(h^2)

◆ interpolation_p1m_h4

integer, parameter regrid_interp::interpolation_p1m_h4 = 1
private

O(h^2)

Definition at line 38 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

38 integer, parameter :: interpolation_p1m_h4 = 1 !< O(h^2)

◆ interpolation_p1m_ih4

integer, parameter regrid_interp::interpolation_p1m_ih4 = 2
private

O(h^2)

Definition at line 39 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

39 integer, parameter :: interpolation_p1m_ih4 = 2 !< O(h^2)

◆ interpolation_p3m_ih4ih3

integer, parameter regrid_interp::interpolation_p3m_ih4ih3 = 6
private

O(h^4)

Definition at line 43 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

43 integer, parameter :: interpolation_p3m_ih4ih3 = 6 !< O(h^4)

◆ interpolation_p3m_ih6ih5

integer, parameter regrid_interp::interpolation_p3m_ih6ih5 = 7
private

O(h^4)

Definition at line 44 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

44 integer, parameter :: interpolation_p3m_ih6ih5 = 7 !< O(h^4)

◆ interpolation_plm

integer, parameter regrid_interp::interpolation_plm = 3
private

O(h^2)

Definition at line 40 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

40 integer, parameter :: interpolation_plm = 3 !< O(h^2)

◆ interpolation_ppm_h4

integer, parameter regrid_interp::interpolation_ppm_h4 = 4
private

O(h^3)

Definition at line 41 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

41 integer, parameter :: interpolation_ppm_h4 = 4 !< O(h^3)

◆ interpolation_ppm_ih4

integer, parameter regrid_interp::interpolation_ppm_ih4 = 5
private

O(h^3)

Definition at line 42 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

42 integer, parameter :: interpolation_ppm_ih4 = 5 !< O(h^3)

◆ interpolation_pqm_ih4ih3

integer, parameter regrid_interp::interpolation_pqm_ih4ih3 = 8
private

O(h^4)

Definition at line 45 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

45 integer, parameter :: interpolation_pqm_ih4ih3 = 8 !< O(h^4)

◆ interpolation_pqm_ih6ih5

integer, parameter regrid_interp::interpolation_pqm_ih6ih5 = 9
private

O(h^5)

Definition at line 46 of file regrid_interp.F90.

Referenced by interpolation_scheme(), and regridding_set_ppolys().

46 integer, parameter :: interpolation_pqm_ih6ih5 = 9 !< O(h^5)

◆ nr_iterations

integer, parameter, public regrid_interp::nr_iterations = 8

Maximum number of Newton-Raphson iterations. Newton-Raphson iterations are used to build the new grid by finding the coordinates associated with target densities and interpolations of degree larger than 1.

Definition at line 59 of file regrid_interp.F90.

Referenced by get_polynomial_coordinate(), and coord_slight::rho_interfaces_col().

59 integer, public, parameter :: nr_iterations = 8

◆ nr_offset

real, parameter, public regrid_interp::nr_offset = 1e-6

When the N-R algorithm produces an estimate that lies outside [0,1], the estimate is set to be equal to the boundary location, 0 or 1, plus or minus an offset, respectively, when the derivative is zero at the boundary.

Definition at line 55 of file regrid_interp.F90.

Referenced by get_polynomial_coordinate().

55 real, public, parameter :: nr_offset = 1e-6

◆ nr_tolerance

real, parameter, public regrid_interp::nr_tolerance = 1e-12

Tolerance for Newton-Raphson iterations (stop when increment falls below this)

Definition at line 61 of file regrid_interp.F90.

Referenced by get_polynomial_coordinate(), and coord_slight::rho_interfaces_col().

61 real, public, parameter :: nr_tolerance = 1e-12