Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Calling Fortran Blas routine from C

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

ru__eli

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-09-2018
10:57 PM

90 Views

Calling Fortran Blas routine from C

Hello,

I am trying to call Fortran subroutine that calls zdotu from C.

I am using linking flags from Advisor https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/

These linking flags for both C and Fortran work when I compiled samples dgemm and matrix multiplication.

However, I am getting SIGSEGV, when running my simple app when both Fortran and C linking flags are used.

I am using GNU compiler, Intel OpenMP lib, intel64 platform, sizeof(int)=4, tried both dynamic and static linking.

The code I am trying to run is actually from R configure script.

Please let me know, how to link both Fortran and C at the same time.

Link Copied

3 Replies

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-10-2018
10:48 AM

90 Views

Ying_H_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-10-2018
05:10 PM

90 Views

Hi Eli,

Could you please tell how do you call the function. MKL support call fortran routine from c.

for example, you may refer to the MKL user guide : there is sample call zdotc. (almost same as zdotu). Please not the output C was the first parameter in routine.

**Example "Calling a Complex BLAS Level 1 Function from C++"**

Below is the C++ implementation:

#include <complex>

#include <iostream>

#define MKL_Complex16 std::complex<double>

#include "mkl.h"

#define N 5

int main()

{

int n, inca = 1, incb = 1, i;

std::complex<double> a

n = N;

for( i = 0; i < n; i++ ){

a* = std::complex<double>(i,i*2.0);*

b* = std::complex<double>(n-i,i*2.0);*

}

zdotc(&c, &n, a, &inca, b, &incb );

std::cout << "The complex dot product is: " << c << std::endl;

return 0;

}

Best Regards,

Ying

P.S If your program related to R and MKL.

It may be more than the problem. Just for your reference:

for example, there are mainly two ways

1. how you could use MKL from R by load dynamic library

__https://software.intel.com/en-us/articles/extending-r-with-intel-mkl__

2. integrate MKL to R to use BLAS and LAPACK.

__https://software.intel.com/en-us/articles/using-intel-mkl-with-r and __

etc.

ru__eli

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-13-2018
09:19 AM

90 Views

Thanks everybody for prompt replies

I fixed the problem. Everything is linking and works now. However, R regression test with MKL vs OpenBLAS reports at least 2 more failures.

I am not sure if number in R regression tests are right, it needs some investigation.

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

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