# Interpolation Module file:Interpolation

## Subroutines Expand Arguments

• rgbi3p(md, nxd, nyd, xd, yd, zd, nip, xi, yi, zi, ier)

Code converted using TO_F90 by Alan Miller Date: 2003-06-11 Time: 10:11:03 Rectangular-grid bivariate interpolation (a master subroutine of the RGBI3P/RGSF3P subroutine package) Hiroshi Akima U.S. Department of Commerce, NTIA/ITS Version of 1995/08 This subroutine performs interpolation of a bivariate function, z(x,y), on a rectangular grid in the x-y plane. It is based on the revised Akima method. In this subroutine, the interpolating function is a piecewise function composed of a set of bicubic (bivariate third-degree) polynomials, each applicable to a rectangle of the input grid in the x-y plane. Each polynomial is determined locally. This subroutine has the accuracy of a bicubic polynomial, i.e., it interpolates accurately when all data points lie on a surface of a bicubic polynomial. The grid lines can be unevenly spaced. The input arguments are MD = mode of computation = 1 for new XD, YD, or ZD data (default) = 2 for old XD, YD, and ZD data, NXD = number of the input-grid data points in the x coordinate (must be 2 or greater), NYD = number of the input-grid data points in the y coordinate (must be 2 or greater), XD = array of dimension NXD containing the x coordinates of the input-grid data points (must be in a monotonic increasing order), YD = array of dimension NYD containing the y coordinates of the input-grid data points (must be in a monotonic increasing order), ZD = two-dimensional array of dimension NXD*NYD containing the z(x,y) values at the input-grid data points, NIP = number of the output points at which interpolation of the z value is desired (must be 1 or greater), XI = array of dimension NIP containing the x coordinates of the output points, YI = array of dimension NIP containing the y coordinates of the output points. The output arguments are ZI = array of dimension NIP where the interpolated z values at the output points are to be stored, IER = error flag = 0 for no errors = 1 for NXD = 1 or less = 2 for NYD = 1 or less = 3 for identical XD values or XD values out of sequence = 4 for identical YD values or YD values out of sequence = 5 for NIP = 0 or less. N.B. The workspace has been removed from the argument list. WK = three dimensional array of dimension 3*NXD*NYD used internally as a work area. The very fisrt call to this subroutine and the call with a new XD, YD, and ZD array must be made with MD=1. The call with MD=2 must be preceded by another call with the same XD, YD, and ZD arrays. Between the call with MD=2 and its preceding call, the WK array must not be disturbed. The constant in the PARAMETER statement below is NIPIMX = maximum number of output points to be processed at a time. The constant value has been selected empirically. This subroutine calls the RGPD3P, RGLCTN, and RGPLNL subroutines. Specification statements .. Parameters ..

• INTEGER INTENT(IN) :: md
• INTEGER INTENT(IN) :: nxd
• INTEGER INTENT(IN) :: nyd
• REAL(GI) INTENT(IN) :: xd(nxd)
• REAL(GI) INTENT(IN) :: yd(nyd)
• REAL(GI) INTENT(IN) :: zd(nxd,nyd)
• INTEGER INTENT(IN) :: nip
• REAL(GI) INTENT(IN) :: xi(nip)
• REAL(GI) INTENT(IN) :: yi(nip)
• REAL(GI) INTENT(OUT) :: zi(nip)
• INTEGER INTENT(OUT) :: ier
• rglctn(nxd, nyd, xd, yd, nip, xi, yi, inxi, inyi)

Location of the desired points in a rectangular grid (a supporting subroutine of the RGBI3P/RGSF3P subroutine package) Hiroshi Akima U.S. Department of Commerce, NTIA/ITS Version of 1995/08 This subroutine locates the desired points in a rectangular grid in the x-y plane. The grid lines can be unevenly spaced. The input arguments are NXD = number of the input-grid data points in the x coordinate (must be 2 or greater), NYD = number of the input-grid data points in the y coordinate (must be 2 or greater), XD = array of dimension NXD containing the x coordinates of the input-grid data points (must be in a monotonic increasing order), YD = array of dimension NYD containing the y coordinates of the input-grid data points (must be in a monotonic increasing order), NIP = number of the output points to be located (must be 1 or greater), XI = array of dimension NIP containing the x coordinates of the output points to be located, YI = array of dimension NIP containing the y coordinates of the output points to be located. The output arguments are INXI = integer array of dimension NIP where the interval numbers of the XI array elements are to be stored, INYI = integer array of dimension NIP where the interval numbers of the YI array elements are to be stored. The interval numbers are between 0 and NXD and between 0 and NYD, respectively. Specification statements .. Scalar Arguments ..

• INTEGER INTENT(IN) :: nxd
• INTEGER INTENT(IN) :: nyd
• REAL(GI) INTENT(IN) :: xd(nxd)
• REAL(GI) INTENT(IN) :: yd(nyd)
• INTEGER INTENT(IN) :: nip
• REAL(GI) INTENT(IN) :: xi(nip)
• REAL(GI) INTENT(IN) :: yi(nip)
• INTEGER INTENT(OUT) :: inxi(nip)
• INTEGER INTENT(OUT) :: inyi(nip)
• rgpd3p(nxd, nyd, xd, yd, zd, pdd)

Partial derivatives of a bivariate function on a rectangular grid (a supporting subroutine of the RGBI3P/RGSF3P subroutine package) Hiroshi Akima U.S. Department of Commerce, NTIA/ITS Version of 1995/08 This subroutine estimates three partial derivatives, zx, zy, and zxy, of a bivariate function, z(x,y), on a rectangular grid in the x-y plane. It is based on the revised Akima method that has the accuracy of a bicubic polynomial. The input arguments are NXD = number of the input-grid data points in the x coordinate (must be 2 or greater), NYD = number of the input-grid data points in the y coordinate (must be 2 or greater), XD = array of dimension NXD containing the x coordinates of the input-grid data points (must be in a monotonic increasing order), YD = array of dimension NYD containing the y coordinates of the input-grid data points (must be in a monotonic increasing order), ZD = two-dimensional array of dimension NXD*NYD containing the z(x,y) values at the input-grid data points. The output argument is PDD = three-dimensional array of dimension 3*NXD*NYD, where the estimated zx, zy, and zxy values at the input-grid data points are to be stored. Specification statements .. Scalar Arguments ..

• INTEGER INTENT(IN) :: nxd
• INTEGER INTENT(IN) :: nyd
• REAL(GI) INTENT(IN) :: xd(nxd)
• REAL(GI) INTENT(IN) :: yd(nyd)
• REAL(GI) INTENT(IN) :: zd(nxd,nyd)
• REAL(GI) INTENT(OUT) :: pdd(3,nxd,nyd)
• rgplnl(nxd, nyd, xd, yd, zd, pdd, nip, xi, yi, inxi, inyi, zi)

Polynomials for rectangular-grid bivariate interpolation and surface fitting (a supporting subroutine of the RGBI3P/RGSF3P subroutine package) Hiroshi Akima U.S. Department of Commerce, NTIA/ITS Version of 1995/08 This subroutine determines a polynomial in x and y for a rectangle of the input grid in the x-y plane and calculates the z value for the desired points by evaluating the polynomial for rectangular-grid bivariate interpolation and surface fitting. The input arguments are NXD = number of the input-grid data points in the x coordinate (must be 2 or greater), NYD = number of the input-grid data points in the y coordinate (must be 2 or greater), XD = array of dimension NXD containing the x coordinates of the input-grid data points (must be in a monotonic increasing order), YD = array of dimension NYD containing the y coordinates of the input-grid data points (must be in a monotonic increasing order), ZD = two-dimensional array of dimension NXD*NYD containing the z(x,y) values at the input-grid data points, PDD = three-dimensional array of dimension 3*NXD*NYD containing the estimated zx, zy, and zxy values at the input-grid data points, NIP = number of the output points at which interpolation is to be performed, XI = array of dimension NIP containing the x coordinates of the output points, YI = array of dimension NIP containing the y coordinates of the output points, INXI = integer array of dimension NIP containing the interval numbers of the input grid intervals in the x direction where the x coordinates of the output points lie, INYI = integer array of dimension NIP containing the interval numbers of the input grid intervals in the y direction where the y coordinates of the output points lie. The output argument is ZI = array of dimension NIP, where the interpolated z values at the output points are to be stored. Specification statements .. Scalar Arguments ..

• INTEGER INTENT(IN) :: nxd
• INTEGER INTENT(IN) :: nyd
• REAL(GI) INTENT(IN) :: xd(nxd)
• REAL(GI) INTENT(IN) :: yd(nyd)
• REAL(GI) INTENT(IN) :: zd(nxd,nyd)
• REAL(GI) INTENT(IN) :: pdd(3,nxd,nyd)
• INTEGER INTENT(IN) :: nip
• REAL(GI) INTENT(IN) :: xi(nip)
• REAL(GI) INTENT(IN) :: yi(nip)
• INTEGER INTENT(IN) :: inxi(nip)
• INTEGER INTENT(IN) :: inyi(nip)
• REAL(GI) INTENT(OUT) :: zi(nip)
• rgsf3p(md, nxd, nyd, xd, yd, zd, nxi, xi, nyi, yi, zi, ier, wk)

Rectangular-grid surface fitting (a master subroutine of the RGBI3P/RGSF3P subroutine package) Hiroshi Akima U.S. Department of Commerce, NTIA/ITS Version of 1995/08 This subroutine performs surface fitting by interpolating values of a bivariate function, z(x,y), on a rectangular grid in the x-y plane. It is based on the revised Akima method. In this subroutine, the interpolating function is a piecewise function composed of a set of bicubic (bivariate third-degree) polynomials, each applicable to a rectangle of the input grid in the x-y plane. Each polynomial is determined locally. This subroutine has the accuracy of a bicubic polynomial, i.e., it fits the surface accurately when all data points lie on a surface of a bicubic polynomial. The grid lines of the input and output data can be unevenly spaced. The input arguments are MD = mode of computation = 1 for new XD, YD, or ZD data (default) = 2 for old XD, YD, and ZD data, NXD = number of the input-grid data points in the x coordinate (must be 2 or greater), NYD = number of the input-grid data points in the y coordinate (must be 2 or greater), XD = array of dimension NXD containing the x coordinates of the input-grid data points (must be in a monotonic increasing order), YD = array of dimension NYD containing the y coordinates of the input-grid data points (must be in a monotonic increasing order), ZD = two-dimensional array of dimension NXD*NYD containing the z(x,y) values at the input-grid data points, NXI = number of output grid points in the x coordinate (must be 1 or greater), XI = array of dimension NXI containing the x coordinates of the output grid points, NYI = number of output grid points in the y coordinate (must be 1 or greater), YI = array of dimension NYI containing the y coordinates of the output grid points. The output arguments are ZI = two-dimensional array of dimension NXI*NYI, where the interpolated z values at the output grid points are to be stored, IER = error flag = 0 for no error = 1 for NXD = 1 or less = 2 for NYD = 1 or less = 3 for identical XD values or XD values out of sequence = 4 for identical YD values or YD values out of sequence = 5 for NXI = 0 or less = 6 for NYI = 0 or less. N.B. The workspace has been removed from the argument list. WK = three-dimensional array of dimension 3*NXD*NYD used internally as a work area. The very first call to this subroutine and the call with a new XD, YD, or ZD array must be made with MD=1. The call with MD=2 must be preceded by another call with the same XD, YD, and ZD arrays. Between the call with MD=2 and its preceding call, the WK array must not be disturbed. The constant in the PARAMETER statement below is NIPIMX = maximum number of output points to be processed at a time. The constant value has been selected empirically. This subroutine calls the RGPD3P, RGLCTN, and RGPLNL subroutines. Specification statements .. Parameters ..

• INTEGER INTENT(IN) :: md
• INTEGER INTENT(IN) :: nxd
• INTEGER INTENT(IN) :: nyd
• REAL(GI) INTENT(IN) :: xd(nxd)
• REAL(GI) INTENT(IN) :: yd(nyd)
• REAL(GI) INTENT(IN OUT) :: zd(nxd,nyd)
• INTEGER INTENT(IN) :: nxi
• REAL(GI) INTENT(IN OUT) :: xi(nxi)
• INTEGER INTENT(IN) :: nyi
• REAL(GI) INTENT(IN) :: yi(nyi)
• REAL(GI) INTENT(IN OUT) :: zi(nxi,nyi)
• INTEGER INTENT(OUT) :: ier
• REAL(GI) INTENT(INOUT) :: wk(3,nxd,nyd)
• TInterpolator_error(this, S, v1, v2)
• TInterpolator   :: this
• character(LEN=*) intent(in) :: S
• class(*) intent(in), optional :: v1
• class(*) intent(in), optional :: v2

## Functions  Expand Arguments

• REAL(GI) z2f(xx1, xx2, zz0, zz1)
• REAL(GI) INTENT(IN) :: xx1
• REAL(GI) INTENT(IN) :: xx2
• REAL(GI) INTENT(IN) :: zz0
• REAL(GI) INTENT(IN) :: zz1
• REAL(GI) z3f(xx1, xx2, xx3, zz0, zz1, zz2)
• REAL(GI) INTENT(IN) :: xx1
• REAL(GI) INTENT(IN) :: xx2
• REAL(GI) INTENT(IN) :: xx3
• REAL(GI) INTENT(IN) :: zz0
• REAL(GI) INTENT(IN) :: zz1
• REAL(GI) INTENT(IN) :: zz2