Fortran double precision program with simple MKL BLAS procedure

When trying to mix precision in a simple program - using both real and double - and use the ddot procedure from BLAS, I come up with the wrong conclusion for the part with double precision. Here is the code:

program test

!! adding this statement narrowed the issue down to ddot being considered real(4)
implicit none

integer, parameter :: dp = kind(1.0d0)

!! The following 2 lines were added for the calls to the BLAS routines.
!! This fixed the issue.
real(dp), external :: ddot
real, external :: sdot

real, dimension(3) :: a,b
real(dp), dimension(3) :: d,e

integer :: i

do i = 1,3
    a(i) = 1.0*i
    b(i) = 3.5*i
    d(i) = 1.0d0*i
    e(i) = 3.5d0*i
end do

write (*,200) "sdot real(4) = ", sdot(3,a,1,b,1)  ! should work and return 49.0
write (*,200) "ddot real(4) = ", ddot(3,a,1,b,1)  ! should not work

write (*,200) "sdot real(8) = ", sdot(3,d,1,e,1)  ! should not work
write (*,200) "ddot real(8) = ", ddot(3,d,1,e,1)  ! should work and return 49.0

200 format(a,f5.2)

end program test

I tried to compile both gfortran and ifort using MKL BLAS libraries as follows:

ifort -lmkl_intel_lp64 -lmkl_sequential -lmkl_core

gfortran -lmkl_intel_lp64 -lmkl_sequential -lmkl_core main.f90

Conclusion:

sdot real(4) = 49.00
ddot real(4) =  0.00
sdot real(8) =  4.10
ddot real(8) =  0.00

How can I get the ddot procedure to handle double precision values ​​correctly?

Also, adding the -autodouble (ifort) or -fdefault-real-8 (gfortran) flag makes both ddot routines work, but sdot routines fail.

Edit: none ddot sdot. , , ddot .

+5
2

MKL, , , "use", ? . , , , , ddot .

. gfortran : -fimplicit-none -Wall -Wline-truncation -Wharacter-truncation -Wurprising -Waliasing -Wimplicit-interface -Wunused-parameter -fwhole-file -fcheck = all -std = f2008 -pedantic -fbacktrace

+6

- ( , , WW III), , , , , , . ( " " ) , .

, , , , ... gfortran.

+2

All Articles