1

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?

Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
Tarek
  • 1,060
  • 4
  • 17
  • 38

1 Answers1

4

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.

Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
  • Should I specify manually the return values for all BLAS/LAPACK functions I use? Isn't there some file that contains these definitions? – Tarek Mar 31 '16 at 16:53
  • In principle, yes. However, some implementations provide modules you can `use` for that purpose. MKL provides [include files](https://software.intel.com/de-de/node/468384#3220B6B9-8A35-42E6-888D-8832E65C2EDB). – Alexander Vogt Mar 31 '16 at 16:54