Main navigation

How to use LAPACK

LAPACK Libraries

There are 3 different libraries that include the LAPACK routines. These libraries are:

LAPACK library from the Netlib Repository
This library was compiled using the Intel Compiler or other high-performance Fortran compiler that was purchased for the cluster. This library is the simplest one to link to and use.
ATLAS library
ATLAS includes a subset of the LAPACK routines. When this library was built, it automatically optimized its performance for whatever system it was built on, in this case, these routines are optimized for the cluster compute nodes.
Intel-MKL library
The Intel-MKL library includes the LAPACK routines. The Intel-MKL library performed very well in our benchmarks.

For a comparison of these libraries see: LAPACK Benchmark. See also How to Use the ScaLAPACK Library.

Installed Locations

Installed locations:

  • The LAPACK library from the Netlib Repository is installed in /u/local/apps/lapack/current
  • The ATLAS library is installed in /u/local/apps/atlas/current
  • The Intel-MKL library is installed in /u/local/compilers/intel/current/current/mkl

How to run LAPACK from a Fortran Program

To compile and link with the LAPACK library from Netlib, enter:

ifort pgm.f -L/u/local/apps/lapack/current -llapack -L/u/local/apps/blas/current -lblas

To compile and link with the ATLAS library, enter:

ifort pgm.f -L/u/local/apps/atlas/current/lib -llapack -lf77blas -lcblas -latlas

To compile and link with the Intel-MKL library please see How to Use the Intel-MKL Libraries.

Note: Replace pgm.f with the name of the file containing your source code.

How to run LAPACK from a C program

To use LAPACK from a C program, replace ifort in the commands above with icc and append an _ to the name of the function you are calling. For example:

extern void sgesv_(int *, int *, float *, int *, int *, float *, int *, int * );

If you are using the LAPACK from the Netlib Repositiory and the icc compiler add:

-L /u/local/compilers/intel/fce/current/lib -lifcore

to the command you use to compile and link.

How to run LAPACK from a C++ program

To use LAPACK from a C++ program you must declare each LAPACK function you will call as being extern as in the following example:

extern "C" void sgesv_(int *, int *, float *, int *, int *, float *, int *, int * );

Code the function name (with _ appended) and the argument list for the function you are calling.

To compile and link, replace ifort in the command with icpc.

If you are using the LAPACK from the Netlib Repositiory and the icpc compiler add:

-L /u/local/compilers/intel/fce/current/lib -lifcore

to the command you use to compile and link.

Report Typos and Errors
UCLA OIT

© 2016 UC REGENTS TERMS OF USE & PRIVACY POLICY