interp_3d Subroutine

private pure subroutine interp_3d(me, x, y, z, f, istat)

3D linear interpolation routine.

Type Bound

linear_interp_3d

Arguments

Type IntentOptional Attributes Name
class(linear_interp_3d), intent(inout) :: me
real(kind=wp), intent(in) :: x
real(kind=wp), intent(in) :: y
real(kind=wp), intent(in) :: z
real(kind=wp), intent(out) :: f

Interpolated

integer, intent(out), optional :: istat

0 : no problems, -1 : class has not been initialized


Calls

proc~~interp_3d~~CallsGraph proc~interp_3d linear_interpolation_module::linear_interp_3d%interp_3d proc~dintrv linear_interpolation_module::dintrv proc~interp_3d->proc~dintrv

Source Code

    pure subroutine interp_3d(me,x,y,z,f,istat)

    implicit none

    class(linear_interp_3d),intent(inout) :: me
    real(wp),intent(in)                   :: x
    real(wp),intent(in)                   :: y
    real(wp),intent(in)                   :: z
    real(wp),intent(out)                  :: f     !! Interpolated \( f(x,y,z) \)
    integer,intent(out),optional          :: istat !! `0`  : no problems,
                                                   !! `-1` : class has not been initialized

    integer,dimension(2) :: ix, iy, iz
    real(wp) :: p1, p2, p3
    real(wp) :: q1, q2, q3
    integer :: mflag
    real(wp) :: fx11, fx21, fx12, fx22, fxy1, fxy2

    if (me%initialized) then

        call dintrv(me%x,x,me%ilox,ix(1),ix(2),mflag)
        call dintrv(me%y,y,me%iloy,iy(1),iy(2),mflag)
        call dintrv(me%z,z,me%iloz,iz(1),iz(2),mflag)

        q1 = (x-me%x(ix(1)))/(me%x(ix(2))-me%x(ix(1)))
        q2 = (y-me%y(iy(1)))/(me%y(iy(2))-me%y(iy(1)))
        q3 = (z-me%z(iz(1)))/(me%z(iz(2))-me%z(iz(1)))
        p1 = one-q1
        p2 = one-q2
        p3 = one-q3

        fx11 = p1*me%f(ix(1),iy(1),iz(1)) + q1*me%f(ix(2),iy(1),iz(1))
        fx21 = p1*me%f(ix(1),iy(2),iz(1)) + q1*me%f(ix(2),iy(2),iz(1))
        fx12 = p1*me%f(ix(1),iy(1),iz(2)) + q1*me%f(ix(2),iy(1),iz(2))
        fx22 = p1*me%f(ix(1),iy(2),iz(2)) + q1*me%f(ix(2),iy(2),iz(2))
        fxy1 = p2*fx11 + q2*fx21
        fxy2 = p2*fx12 + q2*fx22

        f = p3*fxy1 + q3*fxy2
        if (present(istat)) istat = 0

    else

        if (present(istat)) istat = -1
        f = zero

    end if

    end subroutine interp_3d