INTERP1D:EXAMPLE IN F90:
! Declare any routine as external to fill the place of m_slStateValue()
external Extrap1D_LapseRate_X
! Declare the vertical levels (e.g. sigma values)
real, dimension(srcNiNj, srcNk) :: levSrc !(ni*nj, srcNk) points containing data
real, dimension(dstNiNj, dstNk) :: levDst !(ni*nj, dstNk) points containing data
! Declare an array needed by the library
integer, dimension(dstNiNj, dstNk) :: posn !(ni*nj, dstNk) points containing data
! Declare the state values and their derivatives (e.g. humidity)
! (The derivatives are used only by Interp1D_CubicWithDerivs.
! However, they must be declared even if a different Interp1D_* routine is used.)
real, dimension(srcNiNj, srcNk) :: huSrc !(ni*nj, srcNk) points containing data
real, dimension(srcNiNj, srcNk) :: huDeriv !(ni*nj, srcNk) points containing data
real, dimension(dstNiNj, dstNk) :: huDst !(ni*nj, dstNk) points containing data
real, dimension(dstNiNj, dstNk) :: huDerivDst !(ni*nj, dstNk) points containing data
! Declare the variables that control extrapolation
logical :: extrapEnableUp
logical :: extrapEnableDown
real :: extrapGuideUp
real :: extrapGuideDown
! Declare the extension arrays
integer :: numExtArraysIn, numExtArraysOut
real, dimension(1, 1) :: ExtArraysIn, ExtArraysOut
! Calculate and fill the array, posn
call Interp1D_FindPos(ni*nj, srcNk, dstNk, & ! elements used
srcNiNj, dstNiNj, & ! elements dimensioned
levSrc, & ! source array
posn, levDst, & ! destination arrays
)
! Fill in the input values
levSrc=(/ ((i, i=1,srcNiNj), k=1,srcNk) /)
levDst=(/ ((i+0.2, i=1,srcNiNj), k=1,srcNk) /)
huSrc=40.4
! Perform the interpolation (any Interp1D_* routine may be
! chosen, except for Interp1D_FindPos), letting the algorithm
! extrapolate upward, but clamping downward extrapolation to
! the nearest-neighbour value
extrapEnableUp = .true.
extrapEnableDown = .false.
extrapGuideUp = 0. ! unused by this algorithm
extrapGuideDown = 0. ! unused by this algorithm
numExtArraysIn = 0 ! unused by this algorithm
numExtArraysOut = 0 ! unused by this algorithm
call Interp1D_CubicLagrange_X(ni*nj, srcNk, dstNk, & ! elements used
srcNiNj, dstNiNj, & ! elements dimensioned
levSrc, huSrc, huDeriv, & ! source arrays
posn, levDst, huDst, huDerivDst, & ! destination arrays
extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &
Extrap1D_LapseRate_X, &
numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
! Overwrite the (upward) extrapolated values, based on a lapse rate (if desired)
extrapGuideUp = -0.25 ! roll off to smaller values with higher levels
! extrapGuideDown = +0.25 ! roll off to smaller values with lower levels
! (if extrapGuideDown = .true.)
call Extrap1D_LapseRate_X (ni*nj, srcNk, dstNk, & ! elements used
srcNiNj, dstNiNj, & ! elements dimensioned
levSrc, huSrc, huDeriv, & ! source arrays
posn, levDst, huDst, huDerivDst, & ! destination arrays
extrapEnableDown, extrapEnableUp, &
extrapGuideDown, extrapGuideUp, &
Extrap1D_LapseRate_X, &
numExtArraysIn, numExtArraysOut, &
ExtArraysIn, ExtArraysOut &
)
Return to RPN Libraries home page
Return to product index
Last updated: December 5, 2003