Channelflow installation Wed Sep 24 19:53:11 EDT 2008 NOTE: For more up-to-date installation documentation, see http://www.channelflow.org/dokuwiki/doku.php/docs ========================================================================= DIRECTORY STRUCTURE Channelflow follows standard GNU packaging structure as much as possible. The main subdirectories are channelflow/ the channelflow library source code programs/ executable programs programs-octave/ executable programs that require octave libs examples/ how to write and compile your own channelflow program matlab/ Matlab scripts for plotting channelflow data tests/ a suite of test programs for the library code data/ a few data files useful for the test programs doc/ tutorial, timing results doc/userguide/ in-depth LaTeX documentation obsolete/ code that doesn't compile now but might be brought back ========================================================================= BASIC INSTALLATION: ./configure; make; make install If you're moderately lucky you can compile, verify, install, and start using channelflow with a few commands. Most likely you will want to install channelflow into your home directory. Suppose your home directory is /home/brenda, and that you're installing channelflow-1.3.2. Then, run the following commands cd ~ tar xfpvz channeflow-1.3.2.tar.gz cd channelflow-1.3.2 ./configure --prefix=/home/brenda make make test # optional make install When this finishes, the channelflow executables, header files, and libraries will be installed in ~/bin, ~/include, and ~/lib, respectively (where ~ stands for /home/brenda). Now there is one last step. The channelflow executables are linked to the channelflow *shared library* in ~/lib, so you must put the ~/lib directory in your LD_LIBRARY_PATH. How you do this depends on what Unix shell you are using. If you use "bash" (the default on most Linux distributions and Mac OS X), run export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib If you're using "tcsh", run setenv ${LD_LIBRARY_PATH}:/home/myname/lib If you don't know which shell you're using, run "echo $SHELL". Now you should be able to run the channelflow utility programs in ~/bin. See the VERY BASIC USAGE section below for more on that. You'll probably want to put ~/bin in your path, if it's not already there. Please refer to your shell documentation on that (basically you want to add ~/bin to your PATH variable, just like you added ~/lib to your LD_LIBRARY_PATH). If you run into any problems, please see "Detailed installation instructions" below. Note: The executables in the programs-octave/ subdirectory use Octave (a C++ interface to LAPACK) and will only be compiled if you have the Octave development package installed. ========================================================================= IMPORTANT VARIATIONS ON BASIC INSTALLATION Before getting into greater detail, here are few important variations to the installation procedure. 1. I usually prefer to install channelflow into the build directory by running "./configure --prefix=/home/brenda/channelflow-1.3.2". (In bash you can do this more simply with "--prefix=$(pwd)".) 2. Or you can install into the default installation directory /usr/local by dropping the --prefix option to ./configure, e.g. run "./configure". If you do this you'll need to run "make install" as root. 3. It's also a good idea to tell the compiler to optimize for your particular chipset through the configuration step. E.g. ./configure --prefix=$(pwd) CFLAGS='-march=athlon64' athlon64 is a good choice for any 64 bit AMD Athlon or Intel Core 2 Duo processor. Please refer to GCC documentation for other good choices. ========================================================================= VERY BASIC USAGE: couette -h To check that the executables installed correctly, try running "couette.x -h" or "couette --help". For example, gibson@tansen$ ~/bin/couette --help couette : integrate plane Couette or channel flow from a given initial condition and save velocity fields to disk. options : -T0 --T0 default == 0 start time -T1 --T1 default == 100 end time -dt --dt default == 0.03125 timestep -vdt --variabledt adjust dt to keep CFL in bounds etc. Each channelflow executable program in ~/bin will print out a short description of the program's purpose and command line options, if you run it with a -h or --help option. For an overview of the most important programs and how to use them, please see channelflow-1.x.x/doc/TUTORIAL (to be written). ========================================================================= Detailed channelflow installation/compilation instructions, in five parts: 0. Prerequisites 1. Installing channelflow 1a. from a distribution tarball (e.g. channelflow-1.x.x.tgz) 1b. from subversion source files 2. Verifying correctness of installation 4. Compiling channelflow examples/ programs 5. Debugging and profiling 5a Compiling debugging and profiling libraries 5b. Debugging channelflow programs 5c. Profiling channelflow programs 6. Generic GNU install instructions. ========================================================================= 0. Prerequisites To install and use channelflow, you need a. a computer b. a C++ compiler c. make (the Unix "make" utility) d. the standard C++ library e. the standard C math library f. FFTW for computing Fourier transforms g. (optional) the Octave linear algebra libraries and headers Items b,c,d, and e should already be installed on any decent instance of item a. Channelflow is developed with GNU gcc, make, libstdc++, and libc on GNU/Linux systems, so if you're using a current Linux distribution, you should have no trouble. Channelflow should be easily compilable on other Unix variants and Mac OS X, and MS-Windows machines, too, with more work. (Please send documentation or patches to ease compilation on any particular platform to gibson@cns.physics.gatech.edu.) Item f, FFTW, is an elegant, efficient package for discrete Fourier transforms. The FFTW source code is available at www.fftw.org; most Linux distributions provide it as an optional package or packages. Make sure you install the FFTW development packages, if they're offered --you need the FFTW header files as well as the libraries. Channelflow programs can optionally use the linear algebra libraries provided by Octave. Octave is an interactive numerical linear algebra system, designed as a free alternative to Matlab. The Octave libraries offer a very convenient C++ interface to the efficient and well-tested Fortran Lapack and BLAS numerical libraries. For examples of how to use Octave with Channelflow, see the programs-octave subdirectory. The main Channelflow development is currently conducted on AMD Athlon X2 and Intel Core 2 Duo machines running OpenSUSE Linux 11.0 and Kubuntu 7.10 with these packages gcc-4.1.3, 4.3.1, make-3.81 glibc-2.5, 2.8 libstdc++43-4.3.1 fftw-3.1.2 fftw-devel-3.1.2 octave-3.0.0-22 octave-devel-3.0.0-22 autoconf-2.61 and automake-1.10.1 are used in the creation of the configure script but are not necessary for compilation. ========================================================================= 1. Installing channelflow Installing channelflow consists of getting the source files from a tarball or subversion configuring channelflow for your computer system compiling the channelflow libraries copying the channelflow headers and libraries to an appropriate place in your file system ------------------------------------------------------------------------- 1a. Installing channelflow from a distribution tarball. For the most part you can follow the generic GNU installation instructions listed in the INSTALL file, which boil down to tar xfpvz channeflow-1.3.0.tar.gz # maybe change release number cd channelflow-1.3.0 ./configure make make install The default installation directory is /usr/local. If you would like to install channelflow some place else, run these commands instead tar xfpvz channeflow-1.3.0.tar.gz # maybe change release number cd channelflow-1.3.0 ./configure --prefix=/some/other/directory make make install The headers will then be put in /some/other/directory/include/channelflow, and the libs in /some/other/directory/lib. Tips: I often set the installaton directory to the build directory, like this ./configure --prefix=$(pwd) That allows me to keep different channelflow versions installed in different directories, which is useful for development. I often also set compiler flags to optimize for my machine architecture, like ./configure --prefix=$(pwd) CFLAGS="-march=athlon64" For 64-bit Intel chips like the Core 2 Duo, -march=athlon64 or -march=nocona would probably be a good choice. Older chips would take i686, pentium4, pentium4m, etc. Refer to gcc documentation for more compiler flags. You might want to do benchmarks of different options for your machine. ------------------------------------------------------------------------- 1b. Installing channelflow from subversion source files This is currently possible only for people with computer accounts at the Center for Nonlinear Studies, School of Physics, Georgia Institute of Technology! (i) Check out channelflow from the subversion server, zero.physics.gatech.edu: (i.1) If you're within the CNS network, run svn co svn://zero.physics.gatech.edu/channelflow (i.2) Or, if you're connecting from the outside, run svn_tunnel -c channelflow assuming you have the CNS svn_tunnel, scp_tunnel, ssh_tunnel scripts (ii) Produce the configure scripts and Makefiles by running cd channelflow/trunk aclocal autoconf autoheader automake (iii) Now run the ./configure; make; make install, sequence described in (1a). Tip: I find it convenient to install the subversion tree some place other than my home directory, and then make a symbolic link from my home directory to the project trunk. In the long run this eliminates a lot of typing. For example, cd ~/cns svn_tunnel -c channelflow ln -s ~/cns/channelflow/trunk ~/channelflow cd ~/channelflow aclocal; autoconf; autoheader; automake; ./configure; ... ========================================================================= 2. Verifying correct behavior of installation The tests/ directory contains a number of test programs that verify that channelflow behaves corretly. The tests fall into two groups: simple tests of channelflow classes and their member functions, and tests of full-fledged Navier-Stokes simulations. To run the tests, run make test The output will look like tridagTest: pass helmholtzTest: pass tausolverTest: pass poissonTest: pass pressureTest: pass dnsZeroTest --cnfe1 --bulk pass dnsZeroTest --cnfe1 --bulk pass dnsZeroTest --cnfe1 --gradp pass dnsZeroTest --cnab2 --bulkv pass dnsZeroTest --cnab2 --gradp pass dnsZeroTest --cnrk2 --bulkv pass etc. If a test runs to completion but fails, you'll see "FAIL" instead of "pass". If a test seg faults or produces a run-time error, you'll get neither. In general, the tests produce a numerical approximation g to a known function f, and the passes if L2Norm(f-g)/L2Norm(f) < max_error, were max_error is set to a predetermined value for the given test-problem parameters. The test programs produce log files (e.g. tridiagTest.log) that detail the particular tests being run and their error norms. All the tests that run by "make -s check" should pass. If any fail, there's an error somewhere that needs to be tracked down and eliminated. All channelflow distribution tarballs with version numbers have passed the test suite on my development system (currently OpenSUSE-10.2 Linux with gcc-4.0.2 on a Pentium 4 M). ========================================================================= 3. Compiling your own channelflow programs The channelflow/examples directory has several examples of simple channelflow programs and a rudimentary Makefile. See examples/README for more instructions. ========================================================================= 4. Debugging and profiling channelflow programs ------------------------------------------------------------------------- 4a. Compiling debugging and profiling libraries. To compile debugging and profiling libraries, run these commands make clean ./configure --enable-debug make cp channelflow/libchflow.a /usr/local/libchflow-debug.a make clean ./configure --enable-profile cp channelflow/libchflow.a /usr/local/libchflow-profile.a If you set "--prefix=/some/other/directory" when in step 1., you should copy the libraries into /some/other/directory/lib" rather than /usr/local/lib. Warning: It's easy to let the debugging and profiling libraries get out of sync with the headers and the optimized library, since you have to remember to perform these steps whenever you modify the sources. I would like to automate these steps to reduce the potential for error. Ideally, optimized, debugging, and profiling libraries would be compiled and installed with a single "./configure; make; make install". Help from any autoconf/automake experts would be appreciated. ------------------------------------------------------------------------- 4b. Debugging channelflow programs The Channelflow debugging libraries have quite a few run-time checks for things like out-of-bounds errors on indices and discretization compatibility between binary operations on fields. You can catch such errors by running your channelflow programs with debugging turned on; the debugging libraries will will produce a relatively informative run-time error message, which can then be checked in-depth with a debugger. If you skip this check and run your channelflow programs with optimized libraries, the error will produce a seg fault, or worse, keep running without complaint! Thus it is always a good idea to test your channelflow programs with the debugging libs before running them for real. To compile a debugging executable, run "make .dx". E.g. akbar$ cd examples akbar$ make ./errorexamples.dx g++ -Wall -g -O1 -I/usr/local/include -o errorexamples.do -c errorexamples.cpp g++ -g -o errorexamples.dx errorexamples.do -L/usr/local/lib -lchflowdebug -lfftw3 -lm rm errorexamples.do akbar$ ./errorexamples.dx (deliberately causing an index-out-of-bounds error...) errorexamples.dx: /usr/local/include/channelflow/flowfield.h:347: int FlowField::flatten(int, int, int, int) const: Assertion `ny>=0 && ny.px". E.g. akbar$ cd examples akbar$ make couette.px g++ -Wall -pg -O2 -DNDEBUG -I/home/gibson/channelflow/include -o couette.po -c couette.cpp g++ -pg -o couette.px couette.po -L/home/gibson/channelflow/lib -lchflow-profile -lfftw3 -lm rm couette.po To produce a profiling analysis, run the profiled program, and run gprof on the raw profile-data output file gmon.out: akbar$ ./couette.px akbar$ gprof couette.px gmon.out > couette.profile Then look at the file couette.profile. It will contain the profiling results and some brief documentation on its meaning. See gprof documentation for more details. ========================================================================= (5) Generic GNU INSTALL instructions Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not support the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the `--target=TYPE' option to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc will cause the specified gcc to be used as the C compiler (unless it is overridden in the site shell script). `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details.