Silverfrost Forums

Welcome to our forums

Using BLAS and LAPACK

14 Oct 2014 7:28 #14830

Hi, so I am very new to Fortran and learning to do some simple matrix calculation using LAPACK. I have already downloaded the BLAS and LAPACK library from http://icl.cs.utk.edu/lapack-for-windows/lapack/. I tried to link the library to the program and it told me it does not have any error. And here is what I did to import the library ftn95 -o lapack_example.f95 /IMPORT_LIB libblas.lib ftn95 -o lapack_example.f95 /IMPORT_LIB liblapack.lib The response is NO ERRORS However, whenever I try to run the program, it gives me an error message 'Error 29, Call to missing routine: _DGEMV at 0x004010e5'.

And here is my code

program matrixlapack
implicit none real, dimension(3) :: X=(/1.D0, 2.D0, 3.D0/) REAL, dimension(3):: Y=(/2.D0, 2.D0, 2.D0/) real:: Z CALL DGEMV('N', 1, 3, 1.D0, X, 1, Y, 1, 0.D0, Z, 1) PRINT *, Z STOP

  END 

Can anyone tell me what's wrong? Thank you very much!! 😃

14 Oct 2014 9:28 #14834

Maybe a better question to ask is how do I complie LAPACK using silverfrost?

15 Oct 2014 6:32 #14836

-o is the same as /old_arrays. Is that what you intend?

/import_lib is for a library using STDCALL. If you compiled using FTN95 without using F_STDCALL then you should not use /import_lib.

I think a correction would be to use /LIBRARY instead and you could probably use the DLL name or the LIB name. If not then try /REF. Either may work.

17 Oct 2014 5:20 #14865

Please post how you succeeded

17 Oct 2014 1:31 #14869

Quoted from zwang82 Maybe a better question to ask is how do I complie LAPACK using silverfrost? The only routine that you need is ?GEMV, which is in BLAS, not Lapack.

The UTK prebuilt libraries are difficult, if not impossible, to use with FTN95. This is because they were built with and for compilers other than FTN95, and therefore depend on facilities provided in the runtime libraries of those compilers. As they state on their web page, one way to satisfy the dependencies is to install MinGW32 and Gfortran libraries.

For you, the simplest route is to (i) download the BLAS source distribution from http://www.netlib.org/blas/blas.tgz, (ii) extract the files using 7Zip or some such utility, (iii) compile all the source files using FTN95, (iv) package the resulting OBJ files into a library using 'slim *.obj /out:BLAS.lib'.

Your tiny example program has errors. In particular, you have mixed up REAL and DOUBLE PRECISION types haphazardly.

If your input arrays are of type REAL, the routine to call is SGEMV, not DGEMV. The arguments alpha and beta have to be of type REAL, not double, so the call should read

CALL SGEMV('N', 1, 3, 1.0, X, 1, Y, 1, 0.0, Z, 1)
Please login to reply.