In this guide, we assume the external libraries have been correctly installed, following the steps in the installation guide. We will essentially tell the PERIGEE code where are those libraries.
- Name the machine
- Modify the CMake file
- Create another CMake file for a cluster (optional)
- Modify the system_lib_loading.cmake file
Before you start, I recommend giving a meaningful name for your machine. What I typically do is that I give an environmental variable for my machine to name it. My first office desktop is called Bacon, and I have been using this name since then. To give your machine a name, go back to the home directory and open the .bashrc file, add export MACHINE_NAME=bacon to this file. Save it and close the terminal. Reopen the terminal and type
$ echo $MACHINE_NAMEYou shall see bacon on screen. With a manchine name, the configuration may detect the machine, and load the corresponding cmake file. This will make the configuration across platforms easier. For TACC machines, this environmental variable is already defined by them. For example, in Stampede2, the value of $MACHINE_NME is sp2.
There is a folder named conf in the PERIGEE code. It stores the CMake configuration files for compiling the code. You may find a file called machine_name.cmake. Now, let us first make a copy, with a different meaningful name.
$ cp machine_name.cmake linux_bacon.cmakeNow we open the linux_bacon.cmake and there will be a few variables to modify.
- Set
VTK_DIRto the VTK library location (e.g./home/jliu/lib/VTK-7.1.1-shared). - Set
PETSC_DIRto the PETSc library location (e.g./home/jliu/lib/petsc-3.11.3). - Set
PETSC_ARCHto the value used in PETSc installation (e.g.arch-linux2-c-debug). - Set
METIS_DIRto the METIS library location (e.g./home/jliu/lib/metis-5.0.3). - Set
HDF5_DIRto the HDF5 library location (e.g./home/jliu/lib/hdf5-1.8.16). - Set
CMAKE_C_COMPILERto$PETSC_DIR/$PETSC_ARCH/bin/mpicc - Set
CMAKE_CXX_COMPILERto$PETSC_DIR/$PETSC_ARCH/bin/mpicxx
After the editing, save and close linux_bacon.cmake. And you have your own configuration file setted up.
One is highly likely to edit, test, and debug the code on a local desktop, and the production code will be run on a cluster. So one may have to create another CMake configuration file for the cluster. There is a file named stampede2_juliu.cmake in the conf folder. It is quite similar to the linux_bacon.cmake file with different settings of the CMake variables. You are recommended to do the following to create your own CMake file first.
$ cp machine_name.cmake stampede2_yourname.cmakeAnd modify the file. Of course, you may need to consult installation guide to build necessary libraries. On Stampede2, PETSc and HDF5 are readily available. You need to have VTK, METIS, and (optionally) Gmsh installed.
Now, we may open system_lib_loading.cmake in conf folder. The file contains a two-level if-elseif statement to decide which .cmake configuration file to load. On the first level, the if-statement detects if the machine is a Mac OS or Linux system. I have a Mac Laptop, and you may see that my laptop is called poincare, and its cmake file is poincare_PETSc_VTK.cmake. On the second level, there is an if-elseif statement to check the system's environmental variable $ENV{MACHINE_NAME}. This is the variable you edited in the .bashrc file in the beginning of this guide. You may follow the code style add an elseif statement to load your cmake file.