Debugging
Compilation of Serial Code
Form for compiling a serial code: compiler -flags filename
The available compilers are C, C++, Fortran77 and Fortran 90.
There are several implementations of compilers on the CCR cluster. These are GNU, INTEL and PGI.
- GNU: gcc, g++, gfortran, g77
- INTEL: icc, icpc, ifort
- PGI: pgcc, pgCC, pgfortran, pgf77, pgf90
The GNU compilers are in the default path. A module must be loaded to set the paths for the INTEL and PGI compiler suites.
Basic syntax
Compilation of C code with GNU:
gcc -o exec filename.c
where -o specifies the executable file name, which in this case would be exec. If the -o flag is omitted, then the default executable is a.out.
Compilation of C code with INTEL:
module load intel
icc -o exec filename.c
where -o specifies the executable file name, which in this case would be exec. If the -o flag is omitted, then the default executable is a.out.
Learn more about modules commands
Example of compiling helloworld C program with gcc
[ccruser@vortex:~]$ cat hello-world.c #include <stdio.h> int main() { printf("Hello world!\n"); } [ccruser@vortex:~]$ gcc -o hello-gnu hello-world.c [ccruser@vortex:~]$ ./hello-gnu Hello world!
Example of compiling helloworld C program with icc
[ccruser@vortex:~]$ cat hello-world.c #include <stdio.h> int main() { printf("Hello world!\n"); } [ccruser@vortex:~]$ module list Currently Loaded Modulefiles: 1) null 2) modules [ccruser@vortex:~]$ module avail intel -------------------------- /util/Modules/modulefiles --------------------------- intel/10.0 intel/9.0 intel-mpi/4.0 intel/10.1 intel/9.1 intel-mpi/4.0.1 intel/11.0 intel/9.1.040 intel-mpi/4.0.3 intel/11.1(default) intel-ipp/7.0.1 intel-tbb/3.0.3 intel/12.0 intel-mpi/3.1 intel/12.1 intel-mpi/3.2 [ccruser@vortex:~]$ module load intel/12.1 [ccruser@vortex:~]$ icc -o hello-intel hello-world.c [ccruser@vortex:~]$ ./hello-intel Hello world!
Learn more about GNU Compliers
Learn more about Intel Compilers
Learn more about PGI Compilers
Learn more about MPI and Multi-threading
Getting a permissions error when trying to compile in the project directory? Check this out