Tarek
Tarek

Reputation: 1090

Calling BLAS functions

Here is a simple program

PROGRAM MAIN
implicit none
integer, PARAMETER :: N=10
real*8 :: A(N)
real*8 :: x=0.1D0
integer :: i=1
Do i=1,N
A(i)=i
end do
call dscal(N,x, A, 1)

x=dasum(N,A,1)

END PROGRAM MAIN

I compile with the command

gfortran   test.f90  -o test -O1  -I /usr/include/ -L /usr/lib  -lblas

While I have no problem calling the subroutine dscal I get the following error for the function dasum

test.f90:15.2:

x=dasum(N,A,1)
1
Error: Function 'dasum' at (1) has no IMPLICIT type

Should I include a certain file to define the BLAS functions?

Upvotes: 1

Views: 1173

Answers (1)

Alexander Vogt
Alexander Vogt

Reputation: 18098

For functions, you need to manually specify the return value (and if you are feeling posh, optionally an external):

real*8,external :: dasum

Additionally, please don't use real*8. It is not Standard-conforming, not portable and quite confusing. Instead use the kind parameter to define the precision, e.g.:

real(kind=kind(1.d0))

or the like. If you can use the ISO_Fortran_env module, use its constants REAL32 and REAL64.

Upvotes: 4

Related Questions