Does the nvfortran lblas libaray include the dnrm2 and similar vector operations functions?

Note: This post is concerning the lblas library and NOT the cublas library.

I am attempting to compile the following code as a test of the dnrm2 BLAS function:

program test

implicit none

external :: dnrm2

integer :: m=3
real(8) :: s
real(8), allocatable :: x(:)

allocate(x(m),source=0.0)

x = [1.0, 2.0, 3.0]

s = dnrm2(m,x,1)

print *, s

end program

However, when I compile with:

nvfortran test.cuf -lblas

I am getting the following error:

NVFORTRAN-S-0038-Symbol, dnrm2, has not been explicitly declared (test.cuf: 1)

I have tested other vector operations function for example dasum which also doesn’t work. However, I have successfully compiled, ran, and verified the output using BLAS matrix-vector functions for example dgevm. Which leads me to believe that the vector operations are not available in the nvfortran BLAS library. I also think it rules out a possible linking problem. I have searched these forums and the internet to no avail.

I have also reviewed the nvfortran docs here:

which points to OpenBLAS here:

A cursory review of OpenBLAS shows that the dnrm2 function does exist in that library.

It seems to me that for some reason the BLAS vector operations are not included in the nvfortran lblas library or they are under different names for which the documentation is lacking.

Any insight into this error and how to fix it would be greatly appreciated.

Hi milowh74,

“dnrm2” is a function, not a subroutine, so needs to be declared as a real:

!external :: dnrm2
real(8) :: dnrm2

With this change, the code compiles and runs correctly:

% nvfortran test.F90 -lblas ; a.out
    3.741657386773941

Hope this helps,
Mat

Hey MatColgrove,

That worked. Thanks!

For my edification is that in the documentation some where or something? Also is there better documentation for the lblas and llapack cpu libraries for nvfortran?

best,
milowh74

This would be in most Fortran books or online articles that cover F77 style calling conventions.

You could have used “external” but then implicit typing of the function would be used. But you have “implicit none”, so implicit typing is disabled and the return type needs to be declared.

Though even with implicit typing, the result would be incorrect since symbols starting with “d” are typed as “real”. You’d then need to add the flag “-r8” so “real” defaults to “real(8)” instead of “real(4)”.

Also is there better documentation for the lblas and llapack cpu libraries for nvfortran?

There’s nothing specific about using BLAS with nvfortran so not something we’d document.

NetLib originated BLAS and is the reference implementation so would be the best source for documentation. The version that ships with NVHPC is OpenBLAS, but the interfaces aren’t different than the reference version.