Archive for September, 2009

Installing deal.II v6.2.1 (deal II) on Mac OSX v10.5.8

Monday, September 21st, 2009

Apparently installing deal.II (finite element library) on a Mac, seems like a fairly straightforward thing, in practice it took me a loot of time to do it because there was one very nasty thing that had to be done and it was not at all obvious. So I try here to give a walkthrough of all the steps I took to install deal.II on my mac. I installed it with MPI, so that I could use the multiprocessing capabilities.PRE-REQUISITESIn order to install deal.II you need to have installed some other packages:

  • LAPACK and BLAS
  • OpenMPI (v1.3.3)
  • Boost (v1.4.0)
  • PETSc (v2.3.3)

Let’s do it by parts, you should follow this order of installation:Directory structureI decided to install all libraries, except the compiler and LAPACK and BLAS on my home directory. I put all my source files and downloaded archived on a folder:~/Programs/srcAll the installed libraries I put them on a folder inside:~/Programs/installSo, most probably you do not have this directory structure hence open a terminal window and do the following to create these directories:

1
mkdir ~/Programs
2
mkdir ~/Programs/src
3
mkdir ~/Programs/install

LAPACK and BLASIn order to compile anything you need a compiler, hence you need something like the gcc collection. You can use some other compilers but I haven’t tried them. The easiest way to get up and running with compilers on a mac it’s by installing Xcode and the Xcode gFortran plugin. With this you get the gcc collection and also gfortran.For free you also get an optimized version of LAPACK and BLAS with vecLib. Hence you don’t need to have any additional work in order to have LAPACK and BLAS installed.OpenMPII installed version 1.3.3. You can dowload it from here. You can either download it from the browser and put it in the ~/Programs/src folder or you can go to the terminal and do:

1
cd ~/Programs/src
2
wget http://www.open-mpi.org/software/ompi/v1.3/downloads/openmpi-1.3.3.tar.gz

After this just extract the contents of the archive:

3
tar xvf openmpi-1.3.3.tar.gz

Now go inside the newly created directory:

4
cd openmpi-1.3.3

Run configure with the prefix to the directory where we want to install openMPI, in this case inside ~/Programs/install/openmpi:

5
./configure --prefix=~/Programs/install/openmpi

This should configure all the compilation variables with no problem so, after all the output just start compiling:

6
make all

Then install:

7
make install

If everything went fine you should have openMPI installed properly. Now it is only necessary to update your PATH and some other environment variables. To do that you need to edit your .bash_profile file, hence to do it type:

8
emacs ~/.bash_profile

Once emacs is open with your .bash_profile file, just add the following lines to it:

# Set up environment variables for openmpiexport PATH=/Users/gorkiana/Programs/install/openmpi/bin:${PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib/openmpi:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/include:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/include/openmpi/ompi/mpi/cxx/:${LD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib:${DYLD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib/openmpi:${DYLD_LIBRARY_PATH}

Notice that /Users/gorkiana/Programs/install… is for my own computer, my username is gorkiana, so you should put your own username instead of gorkiana. Save it with control+x+s and exit with control+x+c.Now run your updated bash_profile:

9
. ~/.bash_profile

Now you should have a properly working openMPI. To check if in fact it is, move inside the examples directory:

10
cd examples

And make all the example programs:

11
 make all

Run some of the examples, for example:

12
 mpirun -n 2 hello_c

You should get something like this as output:

13
Hello, world, I am 0 of 2
14
Hello, world, I am 1 of 2

If you get this you have a well installed OpenMPI! Next step.BoostI installed version version 1.4.0. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:

1
wget http://downloads.sourceforge.net/project/boost/boost/1.40.0/boost_1_40_0.tar.gz?use_mirror=kent

After that you must extract the contents of the archive, for that do:

2
tar xvf boost_1_4_0.tar.gz

Move to the extracted directory:

3
cd boost_1_4_0

Run the configuration script:

4
./bootstrap.sh --prefix=~/Programs/install/boost_1_4_0

Edit the file ./user-config.jam:

5
emacs ./user-config.jam

Add the following line: using mpiSave and exit with control+x+s and control+x+c.Build Boost and install it:

6
./bjam install

Now you just need to add some directories to the environment variables by editing your .bash_profile file. Type:

6
emacs ~/.bash_profile

And add the following lines:

# Set up environment variable for boost_1_4_0export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/lib:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/boost/include:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/boost:${LD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/lib:${DYLD_LIBRARY_PATH}

Save and exit with: control+x+s and control+x+c.You should now have a working installation of Boost! Next step…PETScI installed version version 2.3.3. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:

1
cd ~/Programs/src
2
wget http://ftp.mcs.anl.gov/pub/petsc/software_old/petsc-2.3.3.tar.gz

After that you must extract the contents of the archive, for that do:

2
tar xvf petsc-2.3.3.tar.gz

Move to the extracted directory:

3
cd petsc-2.3.3-p15

Now you need to set up some environment variables for PETSc:

4
export PETS_DIR=~/Programs/src/petsc-2.3.3-p15
5
export PETS_ARCH=macosx

Run the configuration program:

6
python ./config/configure.py --prefix=~/Programs/install/petsc-2.3.3 --with-blas-lapack-lib="-framework vecLib" --with-mpi-dir=~/Programs/install/openmpi/ --with-shared=1 --with-debugging=0

This says that one should use the vecLib LAPACK and BLAS libraries, the openmpi installation that we just did, generate shared libraries and don’t build debugging libraries, that is, build optimized libraries. Good for production code, faster.Now build it:

7
make all

VERY IMPORTANTYou should see a lot of output. When it finishes you should check if there was any error in the end stating that it was unable to make the shared libraries. You can also check if you have any .dylib files (shared libraries) in the directory ~/Programs/src/petsc-2.3.3-p15/lib/macosx. Just type:

8
ls ~/Programs/src/petsc-2.3.3-p15/lib/macosx | grep .dylib

If you get several files, than you are ok, if not, then you need to do the following. This is very important since if you do not have this files, you are stuck in this step and you are unable to build deal.II. This was what took me a lot of time to solve. Thank you Wendy Mason from the Underworld project for the helpful solution!If you do not have the dylib files you need to edit the file ~/Programs/src/petsc-2.3.3-p15/bmake/common/rules.shared.based, doing:

9
emacs ~/Programs/src/petsc-2.3.3-p15/bmake/common/rules.shared.based

Search for a line where there is something like shared_darwin8: shared_darwin7 and add the following line after that one:

10
shared_darwin9: shared_darwin7

Save the file and exit with control+x+s and control+x+c.Make the shared libraries with:

11
make PETSC_ARCH=macosx shared

Now this should work and you should have the shared libraries. Redo:

12
ls ~/Programs/src/petsc-2.3.3-p15/lib/macosx | grep .dylib

And confirm that in fact you have the .dylib files you need.Just install it:

13
make install

Now you just need to add some directories to the environment variables by editing your .bash_profile file. Type:

14
emacs ~/.bash_profile

And add the following lines:

# Set up environment variables for pets-2.3.3export PATH=~/Programs/install/petsc-2.3.3/bin:${PATH}export LD_LIBRARY_PATH=~/Programs/install/petsc-2.3.3/lib/macosx:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=~/Programs/install/petsc-2.3.3/include:${LD_LIBRARY_PATH}export PETSC_DIR=~/Programs/install/petsc-2.3.3export PETSC_ARCH=macosx

Save and exit with: control+x+s and control+x+c.Run you new bash_profile:

15
. ~/.bash_profile

You should now have a working installation of PETSc! Next step.deal.III installed version version 6.2.1. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:

1
cd ~/Programs/src
2
wget http://www.dealii.org/download/deal.nodoc-6.2.1.tar.gz

After that you must extract the contents of the archive, for that do:

3
tar xvf deal.nodoc-6.2.1.tar.gz

Move to the extracted directory:

4
cd deal.II

Run the configuration script:

5
./configure CC=mpicc CXX=mpicxx --with-boost-include=/Users/gorkiana/Programs/install/boost_1_4_0/include/boost --with-boost-lib=/Users/gorkiana/Programs/install/boost_1_4_0/lib LIBS="-framework vecLib"

Notice that one has to give the MPI compilers no the default ones. If you do not do this, then you will get an error stating that it cannot find some MPI functions. Also you need to give Boost directories and LAPACK and BLAS connected to vecLib, the Apple provided optimized version of LAPACK and BLAS.The configuration process should work fine, after this you just need to build:

6
make all

You should now have a working installation of deal.II.

del.icio.us Slashdot Digg Technorati Google StumbleUpon

Installing Trilinos in Mac OSX 10.5.7

Thursday, September 10th, 2009

To get Trilinos to work it is necessary to get it from here and compile it.In order for the compilation to be successful it is needed a c compiler, a c++ compiler and a fortran compiler. One set of these compilers is given by the gcc bundle. If you install Xcode from Apple you will get gcc and g++ but not gfortran. To get gfortran you can use the one given by macports. Having downloaded Trilinos, you must unpack it. Now, inside the root dir of the unpacked Trilinos tree you should create a directory for you build, even if you just plan on making one build, this is always good. I name it OSX_SINGLE, and move inside it, doing:

1
mkdir OSX_SINGLE
1
cd OSX_SINGLE

Now inside it you should run config, but running config with no special settings gives rise to problems. Hence you should use the following:

1
../configure --cache-file=config.cache --prefix=/usr/local/trilinos-8.0.8-serial CC=/usr/bin/gcc CXX=/usr/bin/g++ F77=/usr/local/bin/gfortran --with-libs="-framework vecLib" --with-ldflags="-Wl,-multiply_defined -Wl,suppress" --enable-amesos --enable-epetra --enable-anasazi --enable-aztecoo --enable-examples --enable-didasko --enable-teuchos --enable-triutils --enable-galeriD

Doing this it should result in a good configuration for make.After this Trilinos is now able to be compiled. To do that you should run:

1
make everything

And then if everything was compiled correctly you should install it, with sudo:

1
sudo make install

After this you should have a working Trilinos installation.

del.icio.us Slashdot Digg Technorati Google StumbleUpon