This tutorial demonstrates how to compile the example codes of wn_sparse_solve. It assumes you are in a Linux or Unix environment. If you are using a different operating system, please adjust the following instructions as appropriate.
Check for Dependencies
The wn_sparse_solve codes depend on SPARSKIT, a basic tool-kit for sparse matrix computations by Yousef Saad. Our tutorial shows how to download and compile SPARSKIT. The wn_sparse_solve codes also depend on wn_matrix. If you have not already done so, install the latest version of wn_matrix now. The steps to do this are covered in the download tutorial for wn_matrix.
Create a Temporary Directory
After downloading wn_sparse_solve, go to the directory src/examples of the distribution. For example, if your current installation of wn_sparse_solve is in the directory ~/modules/wn_sparse_solve/0.1/src/, type
cd ~/modules/wn_sparse_solve/0.1/src/examples
Create a temporary directory by typing
mkdir tmp
This command makes a temporary directory named "tmp" where the object files will be created during compilation.
Compile the Examples
You will first need to edit the Makefile. Look for this part of the Makefile:
#=============================================================================== # Edit the following lines to give the path to the wn_matrix codes, to choose # the compiler (gcc or g++), the flag for compiling fortran with g++, # and to choose whether you will check executable with Valgrind: #=============================================================================== GC=gcc FC=g77 FL= -lstdc++ SPARSKITDIR = ../../../../SPARSKIT2/ SPARSESOLVEDIR = ../ MATRIXDIR = ../../../../wn_matrix/0.7/src/ VALGRIND=yes PROFILE=no #=============================================================================== # End of editing #===============================================================================
You should only need to change the lines in this section if you installed SPARSKIT and wn_matrix in directories other than those suggested in our download tutorials. You might also want to change the compiler from gcc to g++ by setting GC=g++ or to optimize by setting VALGRIND=no. If you choose PROFILE=yes, the executable will leave a gmon.out file that you can view with gprof.
Note that we have set the compiler flags to check the executable with Valgrind. Valgrind works best without optimization, so you can optimize your executables by setting VALGRIND= no.
Now compile the examples by typing:
make all
This will generate all the executable files, example1*, example2* .... You can also make them separately. For example, type
make example1
to generate the executable file example1*.
Clean the Examples
To remove the object files created during compilation, type
make clean
To remove all the object and executable files, type
make cleanall