Wednesday, March 10, 2010

Building ParFlow on OSX 10.6.x Snow Leopard

Snow Leopard has a number of nice features but because it is 64 bit there are a few tricks to compiling ParFlow and associated libraries. Here's step-by-step tips to get everything built.

Compilers:
1) gcc, I use the gcc that comes w/ X-Code Version 3.2.1 available free from Apple.
Its' version statement is:
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646) (dot 1)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


2) mpi, mpicc (an mpi-wrapper for c) comes packaged w/ X-Dev. I've found this works just fine with ParFlow.

3) gfortran, The only 64-bit compatible gfortran I've found, pre-built, is here:http://r.research.att.com/tools/
Its' version statement is:
GNU Fortran (GCC) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING


4) Libraries, I download and build SILO and HYPRE libraries from scratch.
SILO: https://wci.llnl.gov/codes/silo/silo-4.7.2/silo-4.7.2.tar.gz
HYPRE: v. 2.4.0b https://computation.llnl.gov/casc/hypre/software.html


5) Configure Lines
I find that all packages need to be told to build in 64 bit. This is usually done w/ an '-arch x86_64' flag in the configure line.
For SILO:
setenv SILO_DIR path-to-silo/silo-4.7.2/
or for bash
export SILO_DIR=path-to-silo/silo-4.7.2/

./configure CC='gcc -arch x86_64' CXX='g++ -arch x86_64' F77='gfortran -arch x86_64' FC='gfortran -arch x86_64' --disable-silex
make install

For HYPRE
setenv HYPRE_DIR path-to-hypre/hypre-2.4.0b/
or for bash

export HYPRE_DIR=path-to-hypre/hypre-2.4.0b/

./configure CC='gcc -arch x86_64' CXX='g++ -arch x86_64' F77='gfortran -arch x86_64' FC='gfortran -arch x86_64' --prefix=$HYPRE_DIR
make install

PARFLOW
I'm assuming you've set environmental variables PARFLOW_DIR to point to where PF is installed, SILO_DIR to point to SILO and HYPRE_DIR to point to hypre as above.
1) cd $PARFLOW_DIR/pfsimulator
2) ./configure CC='gcc -arch x86_64' F77='gfortran -arch x86_64' FC='gfortran -arch x86_64' --prefix=$PARFLOW_DIR --with-clm --enable-timing --with-silo=$SILO_DIR --with-hypre=$HYPRE_DIR --with-amps=mpi1
3) make install

The compilation process goes fine to almost the end, then errors out w/
ld: duplicate symbol start in /usr/lib/crt1.o and /usr/lib/crt1.10.6.o

These steps will fix this:
1) cd config
2) manually edit Makefile.config to change crt1.o in LDLIBS to crt1.10.6.o
3) cd ..
4) make install

PFTOOLS
1) cd $PARFLOW_DIR/pftools
2) ./configure CC='gcc -arch x86_64' F77='gfortran -arch x86_64' FC='gfortran -arch x86_64' --prefix=$PARFLOW_DIR --enable-timing --with-silo=$SILO_DIR --with-amps=mpi1
3) make install
The build process is very similar, it errors out on same linking step/error duplicate libraries. Here is how to fix:
1) cd config
2) manually change Makefile.config to reflect crt1.10.5.o to crt1.10.6.o this time in two places in the LDLIBS line (it might also be crt1.o in two places as above depending on the system)
3) make install
This now almost seems to work, but errors with an odd message at the end during the linking step
4) Manually adding the -arch x86_64 to the end of the tools linking step will fix this, you can link manually by typing:

ld -dylib pftappinit.o printdatabox.o readdatabox.o databox.o error.o velocity.o head.o flux.o diff.o stats.o tools_io.o axpy.o getsubbox.o enlargebox.o load.o usergrid.o grid.o region.o file.o pftools.o top.o water_balance.o water_table.o sum.o -o ./bin/parflow.dylib -L/usr/lib -L$PARFLOW_DIR/lib -lparflow -L$SILO_DIR/lib -lsilo -ltcl -lc -arch x86_64

from the command line.
5) make install
Everything should now work and you can cd $PARFLOW_DIR/test and make check to test that everything is working.

-Reed

ParFlow Movie Library on YouTube

Hi Folks-

We have a ParFlow Channel on YouTube, it will include a wide range of simulations-- check it out:
http://www.youtube.com/user/TheParFlow

If you have things you would like to upload, please let us know.

-Reed

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: https://wci.llnl.gov/codes/visit/source.html.
  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 https://wci.llnl.gov/codes/visit/source.html 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:
./build_visit

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.