Installing MPB

I wanted to try MPB also, it’s a photonic bandgap simulator by MIT. So I downloaded the package and tried to install in my office workstation. The config stage couldn’t pass since it didn’t find the FFTW library, though I have one installed. It turns out that mine is fftw3 while MPB is not compatible with fftw3 yet. So I have to installed fftw2 into my local directory. The installation for fftw2 is pretty straightforward. Now I need to specify both fftw2, libctl and HDF5 location into the configure of MPB (you may want to refer to Meep installation also, it’s quite similar). This is what I typed to configure MPB.

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/local/fftw2/lib -L/scratch/kurniawano/Download/hdf5/lib" CPPFLAGS="-I/scratch/kurniawano/local/fftw2/include -I/scratch/kurniawano/Download/hdf5/include" --with-libctl=/scratch/kurniawano/local/share/libctl

However, when I typed make, it gives me an error, from this page, I found out that the problem is that I am using HDF5 version 1.8, so I needed to pass through the option -DH5_USE_16_API=1 in the CPPFLAGS. After adding this, my installation works fine 🙂

Installing Meep 1.1.1

I tried to install Meep 1.1.1 in my CentOS workstation. It turns out that it needs some more packages to be installed. First Meep requires guile and libctl, So after downloading them, I tried to install guile. But it failed since guile requires GNU MP (sigh). So I downloaded GNU MP 4.3.1 and did configure, make, make install. I successfully installed in in a local folder. Then in configure guile, I need to specify the location of the GNU MP as well as the libltdl, so I typed:

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/local/lib/" CPPFLAGS="-I/usr/share/libtool/libltdl/ -I/scratch/kurniawano/local/include"

I also need to specify the gmp.h location using CPPFLAGS. Otherwise, I will get an error “At least GNU MP 4.1 is required, see README”. After that I successfully installed guile 1.8.7. Once this is done I configure libctl and specifying the location of guile using LDFLAGS in the configure command. libctl was successfully installed also 🙂

During configure, a warning message shows that I didn’t have hdf5.h in my system. So I downloaded hdf5 and included the header files in the CPPFLAGS when installing meep 1.1.1. Before installing hdf5, I need to install SZIP library first. The installation for SZIP library is pretty simple and no problem encountered. However, it requires me to rebuild libctl again. After I installed hdf5, meep configure gives no error. But when I did make, it gives me error undefined reference to some hdf5 libraries. The problem is that some interface has changed in hdf5 1.8.x version. In one of the forum, it was suggested to install h5utils version 1.11.1.

To overcome this problem, I installed h5utils version 1.12.1 from MIT website, and configure it as follows:

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/Download/hdf5/lib -L/scratch/kurniawano/local/lib" CPPFLAGS="-I/scratch/kurniawano/Download/hdf5/include -I/scratch/kurniawano/local/include" LIBS="-lhdf5"

If you use the shared library, you need to add the hdf5/lib into your LD_LIBRARY_PATH to make the configure successful. Besides that to create png, jpg image from hdf5 output of Meep, you need to install libpng, libjpeg. Another library that is required by h5utils is matheval.

To configure meep 1.1.1, I typed:

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/Download/hdf5/lib -L/scratch/kurniawano/local/lib" CPPFLAGS="-I/scratch/kurniawano/Download/hdf5/include" LIBS="-lhdf5" --with-libctl=/scratch/kurniawano/local/share/libctl

This configures fine, but when I run make, it gives me this error:

libtool: link: warning: library `/scratch/kurniawano/Download/hdf5/lib/libhdf5.l
a' was moved.
grep: /mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/lib/ No
such file or directory
/bin/sed: can't read /mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/l
ib/ No such file or directory
libtool: link: `/mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/lib/li' is not a valid libtool archive

though, I have installed szip library, it seems that hdf5 looks at a different location. So I needed to edit the file under the hdf5/lib folder, and comment the line for dependency_libs then add the line for szip lib location:

# Libraries that this one depends upon.
#dependency_libs=' -L/mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/l
ib /mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/lib/ -lz -l
dependency_libs='/scratch/kurniawano/local/lib/ -lz -lm'

After this, the make and make install runs fine.

If you want to build Meep with MPI enabled for parallel computation, add –with-mpi during the configure stage.

Adding Generalized Eigenvalue functions to IT++

I have added a functions call to lapack DGGEV and ZGGEV functions to solve generalized eigenvalue problem. There are three files to modify: lapack.h, eigen.h, and eigen.cpp. The diff files can be obtained from this link.

To test the code, I ran an example for generalized complex eigenvalue problem found in the NAG site. The test program is shown below:


using namespace itpp;

//These lines are needed for use of cout and endl
using std::cout;
using std::endl;

int main()

  cmat cA,cB;
  cA="-21.10-22.50i 53.50-50.50i -34.50+127.50i 7.50+0.50i; 
        -0.46-7.78i -3.50-37.50i -15.50+58.50i -10.50-1.50i; 
        4.30-5.50i 39.70-17.10i -68.50+12.50i -7.50-3.50i; 
        5.50+4.40i 14.40+43.30i -32.50-46.00i -19.00-32.50i";

  cB="1.00-5.00i 1.60+1.20i -3.00+0.00i 0.00-1.00i; 
        0.80-0.60i 3.00-5.00i -4.00+3.00i -2.40-3.20i;  
        1.00+0.00i  2.40+1.80i -4.00-5.00i 0.00-3.00i;  
        0.00+1.00i -1.80+2.40i  0.00-4.00i  4.00-5.00i";

  cout<< "cA = " << cA<<endl;
  cout<< "cB = " << cB<<endl;

  cvec lambda;
  cmat evecs;
  cout<< "eig(cA,cB)\n";
  cout << "lambda = "<<lambda<<endl;
  cout << "evecs = "<<evecs<<endl;

  //Exit program:
  return 0;


And the output is:

cA = [[-21.1-22.5i 53.5-50.5i -34.5+127.5i 7.5+0.5i]
 [-0.46-7.78i -3.5-37.5i -15.5+58.5i -10.5-1.5i]
 [4.3-5.5i 39.7-17.1i -68.5+12.5i -7.5-3.5i]
 [5.5+4.4i 14.4+43.3i -32.5-46i -19-32.5i]]
cB = [[1-5i 1.6+1.2i -3+0i 0-1i]
 [0.8-0.6i 3-5i -4+3i -2.4-3.2i]
 [1+0i 2.4+1.8i -4-5i 0-3i]
 [0+1i -1.8+2.4i 0-4i 4-5i]]
lambda = [3-9i 2-5i 3-1i 4-5i]
evecs = [[-0.823768-0.176232i 0.639741+0.360259i 
                  0.977535+0.0224645i -0.906234+0.0937662i]
 [-0.152951+0.0706552i 0.0041597-0.000546503i 
                  0.159101-0.11371i -0.0074303+0.00687504i]
 [-0.0706552-0.152951i 0.0402123+0.0226448i 
                  0.120899-0.15371i 0.0302078-0.00312554i]
 [0.152951-0.0706552i -0.0226448+0.0402123i 
                  0.15371+0.120899i -0.0145859-0.14097i]]

Installing laspack

Laspack is

a package for solving large sparse systems of linear equations like those which arise from the discretization of partial differential equations.

To install it, first you need to download the file laspack.tgz. Then you can read the installation guide from this page. First, we need to unarchive the file and then run the ./install script. This, however, will install to your $HOME/bin and $HOME/lib directory. If you want to install to somewhere else, you need to modify all the makefiles in all the directories. If you only want to install into the /usr/local/bin and /usr/local/lib, you just need to type

./install local

without any modifications. Once you run it, it will compile and install into your corresponding directory, and then it will run a test. For my case, however, it didn’t run the test, so I need to go manually to the “check” folder and run the test by typing ./check. Then if everything is alright, you will see

LASPack tested successfully.