Question

I'm trying to get BLAS working with in a FORTRAN 77 program, but so far I've been unsuccesful and I can't figure out how to get going with this. For reference I'm doing this under Ubuntu 12.10.

This is the code of the program I'm trying to compile:

program blastest
  implicit none
  include 'cblas_f77.h'

end

The file cblas_f77.h resides in /usr/include, and there are both libblas.a and libblas.so (and a bunch of other BLAS related files) in /usr/lib.

How do you configure this to work properly?

So far, I've tried the following:

Note: adding -lblas to either of the options make no difference at all...

Just f77, no options (didn't really expect this to work, but what the heck...):

 $ f77 blastest.f -o blastest
    MAIN blastest:
Cannot open file cblas_f77.h
/usr/bin/f77: aborting compilation

f77 with include option to find the header file. Now, instead it fails on (despite the file name) not being coded with FORTRAN 77 in mind, so the first six columns are nonempty...

$ f77 blastest.f -o blastest -I/usr/include
       MAIN blastest:
    Error on line 1 of /usr/include/cblas_f77.h: nondigit in statement label field "/*   "
    Error on line 2 of /usr/include/cblas_f77.h: labeled continuation line (starts " * cbl")
    Error on line 3 of /usr/include/cblas_f77.h: labeled continuation line (starts " * Wri")
    ...

Full output: http://pastebin.com/eZBzh9N5

Switched to gfortran, to be more flexible with the spacing in the header file:

$ gfortran blastest.f -o blastest -I/usr/include
   Warning: cblas_f77.h:9: Illegal preprocessor directive
   Warning: cblas_f77.h:10: Illegal preprocessor directive
   Warning: cblas_f77.h:12: Illegal preprocessor directive
   ...

Full output: http://pastebin.com/P71Di9pR

OK, so I guessed I need -cpp to get the preprocessor working. That gave exactly the same output as above. Also, if you keep reading you see that the full output, the compiler is still complaining about labelled continuation lines further down...

Était-ce utile?

La solution

I believe that you are using the C library "cblas". I would recompile with this command:

gfortran blastest.f -o blastest -L/usr/lib -lblas

and this should sort it all out. I do not believe (though i am not sure) that you need to make use of the "include" statement.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top