Installing and developing your own C, C++, or Fortran program in the CSC computing environment
Case A: you have the source code, you want to install and run it
Create a directory for your code. The recommended location is under the /projappl directory of your project:
mkdir-p /projappl/<project>/myprog # replace <project> with your CSC project, e.g. project_2001234
You need the source files of the code. Depending on the software, you can typically download them from e.g. GitHub. If you have the source code on your own computer, use e.g. scp to upload the data to the supercomputer.
If the source files are distributed as a zip file, use unzip to decompress:
unzip filename.zip # modify the filename accordingly
Read and follow any instructions on how to install. Usually, the code comes with a README or INSTALL file outlining the installation procedure.
When compiling, consider using the fast local disk on the login nodes ($TMPDIR) to move I/O load away from the parallel file system.
Scenario A1: The code uses cmake
Load the cmake module:
module load cmake
Download and install external libraries that the code might need. Always check first if these can be found as pre-installed modules (the most common ones are available):
module spider <modulename> # replace <modulename>, e.g. fftw
Create and move to a build directory in the root of the source code:
mkdir build
cd build
Run cmake with cmake /path/to/source/code:
cmake ..
If you get errors, try to fix the problems. Sometimes it might be easiest to remove everything and start from the beginning, i.e. by unzipping the .zip file.
After cmake, run make to compile the specific applications you want to use:
module load or install separately all required libraries. Check for availability of modules with:
module spider <modulename> # replace <modulename>, e.g. fftw
Load the library modules with:
module load <modulename>/<version> # replace <modulename>/<version>, e.g. fftw/3.3.10-mpi
Edit the Makefile manually or by running ./configure to replace compile and link commands with proper ones for Mahti or Puhti.
Run the command make to compile and make install to install. Custom installation location is typically specified with the --prefix option of the configure script.
./configure --prefix=/projappl/<project>/myprog # replace <project> with your CSC project, e.g. project_2001234
make
make install
Read any error messages and try to fix the possible issues.