- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to implement cubic spline interpolation using Intel MKL in FORTRAN. To make it clear, I coded up an equivalent Python code as follows:
###start of python code for cubic spline interpolation###
from numpy import *
from scipy.interpolate import CubicSpline
from matplotlib.pyplot import *
#Sample data, y_data=sin(x_data)
x_data = [0,1,2,3,4,5,6]
y_data = [ 0,0.84147098,0.90929743,0.14112001,-0.7568025,-0.95892427,-0.2794155]
#Defining interploation points
x = arange(0, 2*pi, 0.2)
#Building the cubic spline using CubicSpline class in scipy.interpolate
cs = CubicSpline(x_data, y_data, axis=0, bc_type='not-a-knot', extrapolate=False)
y_cubicSpline = cs(x)
#Computing the exact values at interpolation points for comparison purposes
y_exact = sin(x)
#Printing the results
print('x y_exact y_cubicSpline')
print('-----------------------------------------')
for i in range(len(x)):
print ("{:.1f} {:.15f} {:.15f}".format(x[i],y_exact[i],y_cubicSpline[i]))
#Plotting the results
plot(x_data, y_data, 'ko', label='Sample Data')
plot(x, y_cubicSpline,'b-', label="Cubic Spline Interpolation")
plot(x, y_exact,'r--', label='Exact Sine Function')
xlabel('x')
ylabel('Sin(x)')
legend(loc='best')
grid()
show()
###end of python code for cubic spline interpolation###
Results are as shown below:
The relevant files are attached as follows:
- cubic_spline_interpolation.txt
- results.txt
- Figure_1.pdf
As I understand, there are some examples regarding the implementation of cubic splines using MKL in FORTRAN in the following directory:
"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.5.274\windows\mkl\examples\examples_core_f.zip\datafittingf"
However, I was not able to find the functionality demonstrated above in Python. Could you please help me re-produce the results of the Python code using Intel MKL functionalities in FORTRAN?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mohammad,
Please use the latest version of Intel oneMKL for the best performance so that we could analyze and assist you accordingly. Further performance improvements can be made by using features such as Parallelization, etc.
If you need additional help, please provide more details regarding your use case, system hardware, etc. as performance varies by your usage, configuration, and other factors.
Thanks and Regards,
Praneeth Achanta
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mohammad,
Thanks for posting in Intel communities.
A FORTRAN example regarding cubic spline interpolation(dfdcubicspline_interp) is available in oneMKL 2023.1 under the below path.
C:\Program Files (x86)\Intel\oneAPI\mkl\2023.1.0\examples\examples_core_f.zip\f\datafitting\source
Could you please check if this matches your functionality?
Thanks and Regards,
Praneeth Achanta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply. Currently, I do not have MKL 2023. I used the following example (from Version 2018)
"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.5.274\windows\mkl\examples\examples_core_f.zip\datafittingf\source\dfdcubicspline_interp.f"
Attached is what I coded up (CubicSplineMKL.f90) using the above example. Since I am not intending to use parallel processing features yet, I removed the blocks from the code (NNBLOCKS). Also, I am only interested in the interpolated points (not the derivative values). The results look good as attached (result.txt).
Could you please let me know if this is implemented correctly? Is there a feature in MKL 2023 that can increase the performance of such computations?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mohammad,
Glad to know the results are satisfactory. For more tips on code optimization and program performance improvement please refer to the below link.
Thanks and Regards,
Praneeth Achanta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Praneeth,
Thank you for the follow up. I looked at the link you provided. However, I am not quite sure which part is applicable to my code. Could you please direct me to a particular part that I should look which is related to the cubic spline I implemented?
Best regards,
Mohammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mohammad,
We have not heard back from you. Could you please provide an update on your issue?
Thanks & Regards,
Praneeth Achanta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Praneeth,
Thank you for the follow up. I looked at the link you provided. However, I am not quite sure which part is applicable to my code. Could you please direct me to a particular part that I should look which is related to the cubic spline I implemented?
Best regards,
Mohammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mohammad,
Please use the latest version of Intel oneMKL for the best performance so that we could analyze and assist you accordingly. Further performance improvements can be made by using features such as Parallelization, etc.
If you need additional help, please provide more details regarding your use case, system hardware, etc. as performance varies by your usage, configuration, and other factors.
Thanks and Regards,
Praneeth Achanta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Praneeth,
Thank you for your support.
Best regards,
Mohammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mohammad,
Thanks for accepting as solution. Glad to know your issue was resolved. If you need any additional information please post a new question as this thread will no longer be monitored by Intel.
Thanks and Regards,
Praneeth Achanta

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page