Harminv installation

From AbInitio

Revision as of 00:18, 16 October 2005; Stevenj (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Harminv is designed to run on any Unix-like system (GNU/Linux is fine), and uses a configure script to make it easy to install. However, you do need a couple of prerequisites:

BLAS

The first thing you must have on your system is a BLAS implementation. "BLAS" stands for "Basic Linear Algebra Subroutines," and is a standard interface for operations like matrix multiplication. It is designed as a building-block for other linear-algebra applications, and is used both directly by our code and in LAPACK (see below). By using it, we can take advantage of many highly-optimized implementations of these operations that have been written to the BLAS interface. (Note that you will need implementations of BLAS levels 1-3.)

You can find more BLAS information, as well as a basic implementation, on the BLAS Homepage. Once you get things working with the basic BLAS implementation, it might be a good idea to try and find a more optimized BLAS code for your hardware. Vendor-optimized BLAS implementations are available as part of the Compaq CXML, IBM ESSL, SGI sgimath, and other libraries. Recently, there has also been work on self-optimizing BLAS implementations that can achieve performance competitive with vendor-tuned codes; see the ATLAS homepage (and also PhiPACK). Links to more BLAS implementations can be found on SAL. I recommend ATLAS, but it does take some time to compile.

Note that the generic BLAS does not come with a Makefile; compile it with something like:

mkdir blas && cd blas # the BLAS archive does not create its own directory
get http://www.netlib.org/blas/blas.tgz
gunzip blas.tgz
tar xf blas.tar
f77 -c -O3 *.f   # compile all of the .f files to produce .o files
ar rv libblas.a *.o    #  combine the .o files into a library
su -c "cp libblas.a /usr/local/lib"   # switch to root and install

(Replace -O3 with your favorite optimization options. On Linux, I use g77 -O3 -fomit-frame-pointer -funroll-loops, with -malign-double -mcpu=i686 on a Pentium II.) Note that Harminv looks for the standard BLAS library with -lblas, so the library file should be called libblas.a and reside in a standard directory like /usr/local/lib. (See also below for the --with-blas=lib option to Harminv's configure script, to manually specify a library location.)

LAPACK

LAPACK, the Linear Algebra PACKage, is a standard collection of routines, built on BLAS, for more-complicated (dense) linear algebra operations like matrix inversion and diagonalization. You can download LAPACK from the LAPACK Home Page. More LAPACK links can be found on SAL.

Note that Harminv looks for LAPACK by linking with -llapack. This means that the library must be called liblapack.a and be installed in a standard directory like /usr/local/lib (alternatively, you can specify another directory via the LDFLAGS environment variable as described below). (See also below for the --with-lapack=lib option to Harminv's configure script, to manually specify a library location.)

Compiling Harminv Itself

Once you have those installed, you can compile and install harminv. harminv comes with a GNU-style configure script, so on Unix-like systems compilation is ideally just a matter of:

./configure
make

and then switching to root and running:

make install

By default, this installs under /usr/local, i.e. in /usr/local/bin etcetera. You can change this by passing the standard --prefix=dir option to configure. Other configure options can be found by running ./configure --help.

In order to compile, harminv requires either:

  • An ANSI C compiler supporting complex numbers, as defined in the ANSI C99 standard (or a reasonable approximation thereof). For example, gcc-2.95 with GNU libc is fine.
  • A C++ compiler supporting the complex standard template class.

The configure script looks for a C compiler with complex numbers first, and then, if that fails, for a C++ compiler. You can force it to use C++ by passing --with-cxx to configure.

If you need to, you can have further control over the configure script's behavior by setting enviroment variables, by passing VARIABLE=VALUE arguments to configure. This can be useful especially if you have libraries installed in nonstandard locations (e.g. in your home directory, if you are not a system administrator), to tell the compiler where to look. The most common variables to set are:

  • CC: the C compiler command
  • CFLAGS: the C compiler flags
  • CXX: the C++ compiler command
  • CXXFLAGS: the C++ compiler flags
  • F77: the Fortran 77 compiler command. Important: if you have more than one Fortran compiler, use the same compiler here as you used for BLAS/LAPACK.
  • FFLAGS: the Fortran 77 compiler flags
  • CPPFLAGS: -Idir flags to tell the C compiler additional places to look for header files.
  • LDFLAGS: -Ldir flags to tell the linker additional places to look for libraries.
  • LIBS: additional libraries to link against.
Personal tools