PHASTA/Compiling PHASTA With CMake
There is an unofficial, but popular version of the PHASTA solver which uses a [CMake] based build system. Generally, an out-of-source build is used, meaning that you have a separate directory for your executables and intermediate files.
Assuming you have your desired compiler and a current version of CMake (2.8.5 or newer) in your path, you must first create and change into an empty directory to store your build
mkdir build cd build
You can then run cmake to create your makefile
If you're using the Intel compiler suite:
CC=icc CXX=icpc FC=ifort ccmake ../phasta
If you're using the PGI compiler suite:
CC=pgcc CXX=pgCC FC=pgfortran ccmake ../phasta
IF you're using the GNU toolchain:
CC=gcc CXX=g++ FC=gfortran ccmake ../phasta
This will open a "GUI" of sorts. You can use the arrow keys to navigate. Press enter to edit the highlighted field, and then enter again to save your change. Press the "c" key to compute the options. Press "g" to write out the makefile and quit. You'll need to press "c" several times, and fill in any desired options before you can generate your makefile.
You may want to set the "CMAKE_BUILD_TYPE" field to either "Release" or "Debug" to get an optimized build or a debugable build respectively.
Once you've completed this process, you can simply run "make" to build the code. The executable will be in the "bin" sub-directory of your build directory.
make
Tips
If you run into trouble, it may be useful to see how the compiler is being invoked. You can do this by running:
make VERBOSE=1
(after having already run cmake)
To add additional compiler flags, use the CMAKE_C_FLAGS, CMAKE_CXX_FLAGS and CMAKE_Fortran_FLAGS fields when you configure
The build options are in a (somewhat) human readable format in a file called "CMakeCache.txt" in the root of your build directory - this can be very useful if you need to figure out which options were used for a particular build.
If you add a new file, you need to tell CMake that the source has changed (this is not usually necessary if you've simply edited an existing source file). You can do this as follows (from your build directory):
touch CMakeCache.txt
CMake uses the MPI wrappers to find your MPI install by default - mpicc and mpif90 must be in your PATH prior to running ccmake
If you'd like to use CMake in a non-interactive fashion, you can use "cmake" instead of "ccmake" and specify and options on the command line by prepending them with "-D". For example:
cmake -DCMAKE_BUILD_TYPE=Release -DPHASTA_INCOMPRESSIBLE=ON -DACUSOLVE_LIB=$HOME/libles.a ../phasta make
The incompressible solver is disabled by default. You'll need to set the PHASTA_INCOMPRESSIBLE option to "ON" and specify the full path to the Acusolve library when prompted.
A fairly generic version of PHASTA, which includes this build system, can be found on the viz nodes in /users/matthb2/phasta-tocmake/phasta