Harminv installation

From AbInitio

(Difference between revisions)
Jump to: navigation, search
Revision as of 00:18, 16 October 2005 (edit)
Stevenj (Talk | contribs)

← Previous diff
Current revision (01:51, 23 October 2005) (edit)
Stevenj (Talk | contribs)

 
Line 1: Line 1:
[[Harminv]] is designed to run on any Unix-like system (GNU/Linux is fine), and uses a <code>configure</code> script to make it easy to install. However, you do need a couple of prerequisites: [[Harminv]] is designed to run on any Unix-like system (GNU/Linux is fine), and uses a <code>configure</code> script to make it easy to install. However, you do need a couple of prerequisites:
-== BLAS ==+{{Installing BLAS and LAPACK}}
- +
-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 [http://www.netlib.org/blas/ 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 [http://math-atlas.sourceforge.net/ ATLAS] homepage (and also [http://www.icsi.berkeley.edu/~bilmes/phipac/ PhiPACK]). Links to more BLAS implementations can be found on [http://SAL.KachinaTech.COM/B/0/BLAS.html SAL]. I recommend ATLAS, but it does take some time to compile.+
- +
-Note that the generic BLAS does not come with a <code>Makefile</code><nowiki>; compile it with something like: </nowiki>+
- +
- mkdir blas &amp;&amp; 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 <code>-O3</code> with your favorite optimization options. On Linux, I use <code>g77 -O3 -fomit-frame-pointer -funroll-loops</code>, with <code>-malign-double -mcpu=i686</code> on a Pentium II.) Note that Harminv looks for the standard BLAS library with <code>-lblas</code>, so the library file should be called <code>libblas.a</code> and reside in a standard directory like <code>/usr/local/lib</code>. (See also below for the <code>--with-blas=''lib''</code> option to Harminv's <code>configure</code> 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 [http://www.netlib.org/lapack/ LAPACK Home Page]. More LAPACK links can be found on [http://SAL.KachinaTech.COM/B/0/LAPACK.html SAL].+
- +
-Note that Harminv looks for LAPACK by linking with <code>-llapack</code>. This means that the library must be called <code>liblapack.a</code> and be installed in a standard directory like <code>/usr/local/lib</code> (alternatively, you can specify another directory via the <code>LDFLAGS</code> environment variable as described below). (See also below for the <code>--with-lapack=''lib''</code> option to Harminv's <code>configure</code> script, to manually specify a library location.)+
== Compiling Harminv Itself == == Compiling Harminv Itself ==

Current revision

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 Intel MKL, HP CXML, IBM ESSL, SGI sgimath, and other libraries. An excellent, high-performance, free-software BLAS implementation is OpenBLAS; another is ATLAS.

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

get http://www.netlib.org/blas/blas.tgz
gunzip blas.tgz
tar xf blas.tar
cd BLAS
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 MPB 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 MPB'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.

Note that our software 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 earlier). (See also below for the --with-lapack=lib option to our configure script, to manually specify a library location.)

I currently recommend installing OpenBLAS, which includes LAPACK so you do not need to install it separately.

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