Hey, what's going on?

Installing LAPACK/BLAS on Mandriva 2010

Posted by Syeilendra Pramuditya on January 19, 2011

Download the source file from the web. I downloaded version 3.3.0 (lapack-3.3.0.tgz). Save it to /usr/local/ (you need to use root account). Make sure (change if necessary) that the “owner” and the “group” are your linux user name.

  1. By using root account, extract the file: gunzip -c lapack-3.30.tgz | tar xvf –
  2. Type: cd lapack-3.3.0
  3. Type: chown yourusername *.* * -R
  4. Type: chgrp yourusername *.* * -R
  5. Exit the root account and just use your user account
  6. Type: cp make.inc.example make.inc (by default, gfortran compiler will be used, otherwise you need to edit this make.inc file)
  7. Type: make blaslib
  8. Type: make lapacklib
  9. Type: cp blas_LINUX.a libblas.a
  10. Type: cp lapack_LINUX.a liblapack.a
  11. Finish

Now you need to run a sample case, I took the following code from Ref. 3:

c This code is written in Fortran
      Program LinearEquations
c solving the matrix equation A*x=b using LAPACK
      Implicit none
c declarations, notice single precision
      Real*4 A(3,3), b(3)
      integer i, j, pivot(3), ok
c define matrix A
c define vector b, make b a matrix and you can solve multiple
c equations with the same A but different b
c find the solution using the LAPACK routine SGESV
      call SGESV(3, 1, A, 3, pivot, b, 3, ok)
c parameters in the order as they appear in the function call
c order of matrix A, number of right hand sides (b), matrix A,
c leading dimension of A, array that records pivoting,
c result vector b on entry, x on exit, leading dimension of b
c return value
c print the vector x
      do i=1, 3
      write(*,*) b(i)
       end do

To compile and link, type: gfortran -o main.unix main.f -L/usr/local/lapack-3.3.0 -llapack -lblas

To run type: ./main.unix

The answer should be [1.0 , 1.0 , 1.0]


  2. LLNL
  3. ORST
  4. UTAH

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: