Calling BLAS functions

半世苍凉 提交于 2019-12-24 15:42:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/36338770/calling-blas-functions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!