Lapack compilation

From CUC3
Revision as of 17:16, 5 July 2008 by import>Jss43
Jump to navigation Jump to search

I had some problems using the atlas modules, which seem to be not applicable to all machines (e.g. 64-bit P4s). I compiled my own lapack routines (available from [1]. Their documentation is wrong in certain places, but it's kind of obvious what paths they refer to. As Catherine notes, it's not worth doing much tuning, so I just used the bog-standard f77 configuration. I installed it in ~/src/lib/lapack-3.1.1:

jss43@keiko:~/src/lib> wget -O - http://www.netlib.org/lapack/lapack.tgz | tar xvzf -  # Download and extract to lapack-3.1.1
jss43@keiko:~/src/lib> cd lapack-3.1.1
jss43@keiko:~/src/lib/lapack-3.1.1> cp make.inc.example make.inc        # Use g77 configuration.  Other examples exist in the INSTALL directory.
jss43@keiko:~/src/lib/lapack-3.1.1> make                                # A (cursory) glance at the docs implies this makes everything (including BLAS).
[reams of output]
g77: ../../blas_LINUX.a: No such file or directory                      # FIBBERS!
jss43@keiko:~/src/lib/lapack-3.1.1> cd BLAS/SRC && make && cd ../../    # Fine, we'll make BLAS ourselves...
jss43@keiko:~/src/lib/lapack-3.1.1> make                                # ...and finish the job.

The last make command takes a while to run, so it's worth having a cup of tea as you wait. (You can avoid the error in the middle by editing the Makefile.)

The makefile also runs tests which passed. The libraries are blas_LINUX.a and lapack_LINUX.a, so we can link to them to give them more standard names:

jss43@keiko:~/src/lib/lapack-3.1.1> ln -s lapack_LINUX.a liblapack.a
jss43@keiko:~/src/lib/lapack-3.1.1> ln -s blas_LINUX.a libblas.a

These can now be used in compilation by using:

 -L ~/src/lib/lapack-3.1.1 -llapack -lblas 

in the link line. This is somewhat platform dependent though, so we can make it even easier to use by using enviroment modules to reduce the link line to:

-llapack -lblas