Wednesday, June 10, 2009

Installing VisIt on Ubuntu 9.04 Jaunty Jackalope

-->This post represents the next episode in installing ParFlow on the Ubuntu/Debian system. The purpose of adding Silo support when installing ParFlow is to utilize VisIt for visualization with ParFlow. VisIt is a free and powerful visualization tool that works very well with ParFlow outputs. The VisIt website provides precompiled binaries for several platforms, none of which are Ubuntu/Debian. In order to use VisIt on Ubuntu/Debian, we must build from source code.

I have prepared a precompiled binary for 64-bit Ubuntu systems (which may also work on 64-bit Debian systems). It is known to work on one computer other than my own so far. If you would like to try it, let me know by commenting this post. I make no guarantees that it will work.

Like my ParFlow installation, this installation was filled with repetitions, loops and mulligans, which I will not detail. Building VisIt is a complicated and time intensive process. The developers of VisIt have prepared the “build_visit” script, which automates the process of building VisIt, its prerequisites and optional libraries, making it a little easier. After several problems installing optional libraries, I decided to forgo the optional packages, as they are not needed for ParFlow visualization.

Visit requires several prerequisite libraries and programs be installed before VisIt can be built. The build_visit script will download and install most these, but there are a few preparations that must be made before running the script. Here are the steps that I completed before running the script (successfully).

  1. First I added “libxmu-dev” using the Synaptic Package Manager. This can also be completed using apt-get. Note that there is also a “libxmuu-dev” package. Pick the one that has one “u.”
  2. Next I made a “visit” directory in my “parflow” directory (/visit) and downloaded the VisIt source code here:
  3. I downloaded the build_visit script and placed it in the visit directory with the visit source code tarball. The source code needs to be unpacked in this directory before running the build_visit script.
  4. VisIt needs to be built using the gcc compiler. My .bash_aliases has not changed since installing ParFlow, so I also needed to cancel the CFLAGS associated with the Intel Compiler.
export CC=gcc
export CFLAGS=
  1. Finally, in order to run the build_visit script, it needs to be made executable.
chmod 700 /visit/build_visit

Now we are ready to build VisIt. The build_visit script should download the needed third-party packages for you. If you would prefer to do it yourself, download the following packages from the bottom of the page at and place them in the /visit directory. They do not need to be unpacked as the build_visit script takes care of that.
  • CMake 2.4.5 sources
  • Mesa 5.0 sources
  • Python 2.5 sources
  • Qt X11 3.3.8 sources
  • VTK 5.0.0c sources

To run the build_visit script, cd into the /visit directory and type:

The script will run through a series of input screens. Spacebar marks check boxes, enter/return moves to the next window, and I never figured out how to cancel, but that option appears to exist as well.

In the first window, I selected to install a parallel version of VisIt with Python support. I did not select any of the other options and I did not install any optional libraries. Do not install Java support. VisIt will not compile properly with that option. I tried to install with some optional packages initially and could not successfully complete the installation.

If you opt to install a parallel version of VisIt, you will be asked about directories for MPI. If you installed OpenMPI to the default location before building ParFlow, the given directories should be correct.

After agreeing to the Qt license agreement, the script took over and I had more than an hour free while it worked. If the build gets interrupted or stops due to an error, it will pick up where it left off when restarted.

If the build_visit script fails during the part where it is actually building VisIt, try entering the following environmental variables and running the build_visit script again.
export CFLAGS=-02
export CXXFLAGS=-02

Once installation of VisIt was complete, I added the following line to the .bash_aliases file:
vi ~/.bash_aliases
export PATH=$PATH://visit/visit1.11.2/src/bin

To call VisIt from the command line, simply type visit.

Wednesday, June 3, 2009

Installing ParFlow on Ubuntu 9.04 Jaunty Jackalope

NOTE:  If you're looking for instructions to install ParFlow on Ubuntu systems, the Ubuntu instructions included in the post entitled "Running ParFlow on Windows using VirtualBox (also updated instructions for installing ParFlow in Ubuntu)" provides clearer and better instructions than this post, and those instructions appear to work on most Linux systems.

Before installing ParFlow on the Ubuntu system, I first had to make sure the prerequisite software was included and prepared on my system, including compilers and scripting language. Once that portion was completed, I was able to build ParFlow using various combinations of compilers. The end result is a working full version of ParFlow that passes (almost) all of the test cases. In writing this narrative of the trials and tribulations doing this install, I’m going to assume the reader holds a basic knowledge of file-system navigation by command line on a Linux system, what a compiler is and does, how to operate the vi text editor, and has already installed Ubuntu.

I installed a full version of ParFlow (r375) that includes CLM, supports MPI, supports SILO output and includes Hypre, a high-performance solver pre-conditioner. I also installed VisIt, a visualization platform that uses the SILO output files, but there is a compatibility issue between VisIt and Ubuntu that I have yet to resolve, so I will not detail that installation here.

This is the order of operations for installing ParFlow that I would use if I were to do it again. I shall spare the reader the loops and repetitions from my maiden voyage.
  1. Install GNU Compilers
  2. Download the following:
  1. Install OpenMPI*
  2. Install Intel Compilers
  3. Install Tcl/Tk
  4. Set environmental variables
  5. Build Silo
  6. Build Hypre
  7. Build Parflow
*If you are not using a multi-core processor, multiple processors or a cluster, MPI is probably not needed.
**Intel compilers are available for free download for non-commercial use.

GNU Compilers
There are several GNU compilers that need to be available:
  • gcc
  • g++
  • gdc
  • gfortran
The GNU compiler collection can be installed via “apt-get” or the Synaptic Package Manager included in Ubuntu. I used the Synaptic Package Manager found in the System menu > Administration > Synaptic Package Manager. You will need to have administrative privileges to do this. Use the “Quick Search” to find gcc, gdc, g++ and gfortran, then install them.

The machine on which I installed ParFlow uses a dual-core processor, so I decided to install MPI to take full advantage of the processor. I downloaded OpenMPI and installed it according to the included instructions to the default directory (/usr/local/mpi) by leaving the “--prefix” flag off the ./configure line. This directory requires administrative privileges and the use of the “sudo” command.

sudo ./configure
sudo make all install

Intel Compilers
I was not able to get ParFlow to build using the GNU compilers alone, so I installed the Intel C and Fortran Compilers. The installers for the compilers make the installation process nearly fool-proof. I installed to the default directory (/opt/intel). During installation of the second compiler, I received a warning message about overwriting a library installed with the first. This is not a problem as the two compilers share the same library.

Tcl/Tk provides the scripting support needed to initiate ParFlow. It is available through the Synaptic Package Manager and “apt-get,” however when installing with the Synaptic Package Manager, I was unable to figure out the correct pieces to get Tcl/Tk configured correctly. By downloading and installing the latest versions of Tcl and Tk from the source code, you get a complete installation. Tcl and Tk must be installed separately. I installed the Unix versions of Tcl and Tk to the default directory (/usr/local/). I used two flags on the configure line to specify a shared library and 64-bit support. If you are not using a 64-bit processor, the “--enable-64bit” flag is unecessary. Again, this installation requires administrative privileges.

sudo ./configure --enable-shared --enable-64bit
sudo make
sudo make install
sudo make test

I used the same procedure to install Tk. In the event that either portion must be reinstalled, it is important to run “sudo make distclean” first to completely remove the previous installation. Not doing this turned out to cause problems in running ParFlow.

The “make test” command runs several thousand tests. One test failed on Tcl. Several tests failed on Tk. ParFlow works in spite of the test failures, so I'm not going to worry about them much.

Setting Environmental Variables
This is the part of the process that allows the programs to find each other, essentially, and is thus important. This is also the part where you assign directories for ParFlow, Silo, Hypre and VisIt. I made a ParFLow directory, ~/parflow, in my home directory. From now on, I will call this directory “~PF.” I unpacked each *.tar.gz file in my ~PF directory, and renamed each simply “ParFlow,” “Silo” and “Hypre.”

Environmental variables can be set from the terminal command line or saved in the .bash_aliases file (so you only have to do it once). The terminal in Ubuntu does not load .bash_aliases by default. In fact, the file does not exist. To enable bash to load the .bash_aliases, I edited the ~/.bashrc file, located in my home directory.

vi ~/.bashrc

I found the following section in the .bashrc file and uncommented the boldface lines (delete “#” signs):

# Alias definitions. # You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases

Next I created the .bash_aliases file and added the following entries to it (numbers not included):
vi ~/.bash_aliases
  1. export PARFLOW_DIR=~PF/parflow
  2. export SILO_DIR=~PF/silo
  3. export HYPRE_DIR=~PF/hypre
  4. export PATH=$PATH:/opt/intel/Compiler/11.0/083/bin/intel64*
  5. export LD_LIBRARY_PATH=/opt/intel/Compiler/11.0/083/lib/intel64*
  6. export FC=ifort
  7. export F77=ifort
  8. export F90=ifort
  9. export CC=icc
  10. export CFLAGS='-no-multibyte-characters'
*This path may be different depending on version and installation path.

1-3 set the directories for ParFlow, Silo and Hypre. 4 and 5 configure the Intel compilers to run from the command line. 6-9 make the Intel compilers default. 10 circumvents a compiler error.

This is the setup to build ParFlow. Silo does not compile correctly using the Intel C Compiler, so I reset the C compiler to gcc by entering the following on the command line.

export CC=gcc
export CFLAGS=

This setting is only valid in the current terminal window for the current session. Starting a new session will load the .bash_aliases file and revert to the Intel C Compiler.

Installing Silo
With the C compiler set to gcc, the installation of Silo went according to the instructions contained in the INSTALL file included in the package. I used a “--disable-silex” flag on the ./configure line. This disables a utility that ParFlow does not use that would complicate the installation.

./configure --prefix=$SILO_DIR --disable-silex
make check
make install

The “make check” line runs a series of tests. These should all pass. During my installation, I had plenty of problems getting the program to compile, but once it did, the tests passed.

Installing Hypre
I installed Hypre using the same set of compilers as Silo, and it worked. In the interest of leaving well-enough alone, I did not try it with other combinations of compilers. The autoconf package for Hypre is located in the “src” subfolder (~PF/hypre/src). Like Silo, the installation of Hypre went according to the instructions contained in the INSTALL file. I used the “--with-MPI” flag. If MPI is to be enabled in ParFlow, MPI must be enabled in Hypre as well. For ParFlow builds without MPI, a “--without-MPI” flag is necessary. MPI must be capitalized.

./configure --prefix=$HYPRE_DIR --with-MPI (or “--without-MPI”)
make install

That is all.

Installing ParFlow
Now I'm ready to install a full version of ParFlow with Hypre and Silo support and coupled with CLM. This installation is completed in three parts.

Before beginning, ParFlow seems to compile using the Intel compilers, but not the GNU compilers. If your .bash_aliases file has the same 10 lines as mine above, the easiest way to set the correct compilers is to open a new terminal window and work there. Otherwise, entering lines 10 and 11 from the .bash_aliases above on the command line will make the necessary settings.

1. Installing ParFlow: the autoconf package for ParFlow is located in the ~PF/parflow/pfsimulator directory. I used many flags in the ./configure line to enable all of my extensions.

./configure --prefix=$PARFLOW_DIR --with-amps=mpi1 (or --with-amps=seq, if you're not running MPI) --with-clm --with-silo=$SILO_DIR --with-hypre=$HYPRE_DIR --enable-timing

You're only going to want to type that once, so don't close your terminal window until you're done.

make install

2. If that worked, now it's time to install “pftools,” located in ~PF/parflow/pftools. I used the same ./configure line as above by pressing the up arrow. The autoconf for pftools ignores the flags that do not apply.

make install

3. If that worked, the last step is to test ParFlow. Tests are located in ~PF/parflow/test

make check

One test run, the “forsyth2” test did not pass. ParFlow appears to have completed the problem, but the output does not match the correct output. The remaining fourteen tests passed.

That completes installation of ParFlow with CLM, with Silo and Hypre support, and MPI enabled on an Ubuntu 9.04 Jaunty Jackalope system.