Skip to main content

Search this Site

DartPulse Alerts

Chrome Printing Issues


DartPulse Outages

Overall System Status:

Upcoming Scheduled Outages

New to Dartmouth?

Resources for:

Information Security

Connect with ITS

facebook twitter Wordpress Blog

Writing and Running Programs on a Linux Computer

What Types of Programming are Supported by Research Computing

  • Basic and advanced programming in Fortran, C/C++, Java
  • Basic GPU programming under CUDA, CUDA directives under Fortran and C (PGI compilers), Basic MATLAB CUDA programming
  • Web programming: PHP, HTML, CSS, Database programming and support
  • Scripting: Perl, Pyhton, CSH, BASH, KSH
  • Parallel Programming: Converting serial codes to parallel using MPI, OpenMP, Hybrid programming
  • Code Debugging: use Totalview to debug  codes
  • Code development: Serial and parallel codes
  • Code porting: Mainly to Linux environments including Math and Scientific libraries
  • Application programming: Matlab programming, SAS programming, Visualization with Visit and VTK

How Do I Use Compilers on Research Computing's Linux Systems?

Most Research Computing Linux computers have three different kinds of compilers: GNU compilers, Portland Group compilers, and Intel compilers.

Below is a table that shows the different compilers and their commands:


File Suffix


Type of Compiler

Fortran 77



Portland Group






.f .F .for



Fortran 90

.f .f90


Portland Group


.f .f90






Portland Group










.c .C











No one compiler works best for all kinds of code. If you are interested in optimizing your application, you will want to test various compiler options and compilers to see which ones work the best for your application. There is a man page for each compiler that lists the compiler options.

In general, gcc/g++ is the most flexible since it runs on a variety of different computer platforms. Many people use gcc/g++ so it will be easy to port their code to other platforms. gfortran is the Fortran GNU compilers.

The Portland Group compilers will compile f77, f90, C, and C++ codes. Many Fortran codes use extensions to the language, and the Portland Group compilers support those extensions. Portland Group recommends you use the pgf90 for both Fortran 90 and Fortran 77 codes to gain additional code speed up.

The Intel compilers do a good job of compiling code to make use of the architectural features of the Intel processors.

Here is a table of frequently used compiler flags, common to the above compilers.

Compiler Option What the option does
-c Produce an object file only
-o filename Create an executable called filename(the default is a.out)
-O {0,1,2,3} Specify the optimization level ( 0 is none and 3 is most aggressive)
-g Include a symbol table, needed for debugging
-pg Generate profiling code
-I Look for include files in this directory (default include directory is: /usr/include)
-L Look for libraries in this directory (default library directory: /lib, /usr/lib, /usr/lib64
-larchive Link in a library called (or .a)
-static Link only with static libraries (compilers use shared libraries by default)

For more options and detailed information:

  • Consult man pages(e.g., man gcc) for more options and more detailed information. Send questions, corrections, or additional information about these compilers to Research Computing

Top of page

How Do I Use Debuggers on Research Computing's Linux Systems?

In general, you should use either the debugger that is supplied with each type of compiler or a general-purpose debugger like totalview. The table below provides the compilers and their associated debuggers for the compilers installed on the Research Computing Linux Computers.



GNU gcc, g++


Portland Group pgcc,pgf77,pgCC,pgf90


Intel compilers icc, ifort


Java compiler javac


Works with GNU, Intel, and Portland

Group Compilers


Notes on the Debuggers

All of the compilers can be used in three different modes: To interactively run and debug a program, to debug a core file that was created by a program, or to connect to a running process. The documentation for each debugger provides information about how to run them.

gdb is the debugger used for code compiled with the GNU compilers gcc and g++. It can be run from the command line, from emacs or xemacs, from ddd or from eclipse.

pgdb is the debugger for thePortland Group compilers. If you are running X Windows, pgdb has a graphical user interface; otherwise, it has a command-based interface.

idb is the debugger for the Intel  compilers. It can be configured to run using the gdb or dbx commands. It can be run with a command-based interface, from emacs, xemacs, or ddd.

jdb is the command line debugger for java.

TotalView is a powerful GUI-based debugger that works with several compilers, including the GNU, Portland Group, and Intel Compilers. It can debug MPI, OpenMP, and other threaded C/C++ or Fortran programs.

Top of page

How Do I Use the Compilers on 64-bit Linux Computers

A 64-bit computer can handle more computations, memory, and I/O than a 32-bit computer. To take advantage of this additional power, software must be built with 64-bit compilers. The 64-bit computer can run 32-bit applications, but running them in 32-bit mode doesn't use all the expanded capabilities of the 64-bit computer. However, software built to use a 64-bit computer cannot run on a 32-bit computer.

All of the C/C++ and FORTRAN compilers on the public 64-bit Linux computers  will build 64-bit applications by default when you run them on a 64-bit computer. You can specify options to these compilers to build a 32-bit executable instead of a 64-bit. The table below provides more information on these options for the installed  compilers.

If you plan to build your application on both 32-bit and 64-bit Linux computers, and you want to use the same executable on both, compile the program for a 32-bit computer. If you plan to run only on  a 64-bit computer, compile the program for 64-bit, as it will run more efficiently.

The file command tells you which kind of application your executable is. For example, the following information is about an executable called shapley.

file shapley

shapley: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV).
for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped

If you try to run a 64-bit executable on a 32-bit computer, you will get an error message that says, "Exec format error. Wrong Architecture.".

Compiler Commands for Building 32-bit and 64-bit Applications on 64-bit Linux Computers






gcc -m32



g++ -m32

Portland Group C


pgcc -tp px

Intel C/C++


icc -m32

Top of page

Last Updated: 2/28/14