How to use Data Fitting functions in Intel® Math Kernel Library with PGI* Fortran 95 Compiler on 32 bit Windows* OS


Data Fitting (DF) component of Intel® Math Kernel library (Intel® MKL) is SW solution for spline construction, interpolation, integration, and cell search. You can use power of Intel® MKL DF with spline computations, not supported in the library, via mechanism of user-defined call-back functions - see an additional details in Intel® MKL Manual.

This paper describes how you can build Intel® MKL DF call-back based applications by means of PGI* Fortran 95 compiler

Who is affected    : Users of PGI* Fortran 95 compiler

OS :   Windows* 32 bits

Intel MKL version : Intel® MKL 10.3.8 and later

Recommended solutions: 

There are several ways to build an application that makes call to Intel® MKL Data Fitting routines by passing user-defined callback functions. For demonstration we use the Data Fitting example dfdbesselcubicspline.f available  in MKL installation directory (as an example - <mkl_root>\examples\datafittingf\source\ ).

Below is its code snip that shows the major steps of the computational flow

INTERFACE

INTEGER FUNCTION linear_extrap(n,cell,site,r,params)

INTEGER(8) :: n

INTEGER(8) :: cell(*)

INTEGER :: params(DF_TEST_EXTRAP_PARAMS_4BYTE_SIZE)

REAL(8) :: site(*),r(*)

END FUNCTION

END INTERFACE

!***** Create Data Fitting task *****

errcode = dfdnewtask1d( task, nx, x, xhint, ny, y, yhint )

!***** Compute Bessel cubic spline coefficients using STD method *****

errcode = dfdconstruct1d( task, s_format, method )

!***** Interpolate and use call backs for the left and right

!      extrapolation *****

errcode = dfdinterpolateex1d( task, intepr_type, intepr_method,    &

& nsite, site, sitehint, ndorder, dorder, r=r, rhint=rhint,         &

& le_cb=linear_extrap, le_params=le_params, re_cb=linear_extrap,    &

& re_params=re_params)

!***** Delete Data Fitting task *****

errcode = dfDeleteTask( task )

- Use 64 bit version of PGI* Fortran compiler without any modification of the example

- Modify the declaration of the callback function by adding ATTRIBUTES C,REFERENCE as shown below, if you    use 32-bit version of the PGI* Fortran 95 compiler.

INTERFACE

INTEGER FUNCTION linear_extrap(n,cell,site,r,params)

!DEC$ ATTRIBUTES C,REFERENCE :: linear_extrap

INTEGER(8) :: n

INTEGER(8) :: cell(*)

INTEGER :: params(DF_TEST_EXTRAP_PARAMS_4BYTE_SIZE)

REAL(8) :: site(*),r(*)

END FUNCTION

END INTERFACE

The same modification should be done in the definition of the function.

Note. If you use non PGI* Fortran compiler, that code modification is unnecessary

For more complete information about compiler optimizations, see our Optimization Notice.