C, C++, Fortran and Java

The purpose of this page is to provide useful information for first time C, C++, FORTRAN and Java users on CBS Research Grid. Although this document won't show you how to program, it will help you get started and point you to other useful documentation.

Editing Your Programs

Before you use any programming language, you need to be familiar with a text editor, which you will use to write and make changes to your programs.  Emacs and Nano (Open Source version of pico) are the text editors are available on CBS Research Grid.

Compilers on CBS Research Grid

The following table contains information on the compilers that are available on CBS Research Grid.

Name

Description

Command

Manuals & Documentations

C

GNU Project C – V3.4.6

gcc

At command prompt, type: man gcc;
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/

C++

GNU Project C++ – V3.4.6

g++

At command prompt, type: man g++
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/

FORTRAN

GNU Project g77 – V3.4.6

f77

At command prompt, type: man g77
http://gcc.gnu.org/wiki/GFortran#download

NAGWare Fortran – V5.0

f95

/apps/NAG/NAGWare_f95-amd64/doc
/apps/NAG/NAGWare_f95-amd64/html

Java

Sun Microsystems, V6

java

/apps/jdk/README.html
http://java.sun.com/reference/docs/


Example for Using Compilers

The following example demonstrates how to use the compilers to compile an executable file that carries the same file name as the source code:

cc d01ajce.c -I/apps/NAG/cll6a08dgl/include /apps/NAG/cll6a08dgl/lib/libnagc_nag.a -lpthread -lm -o d01ajce.exe


Options

Description

cc

calls the GNU C compiler

d01ajce.c

name of your source file to be compiled. In this case.  In this particular case, d01ajce.c is a
sample program you can find under /apps/NAG/dll6a08dgl/examples.

-I

A flag that indicates what directory will be searched for include files

-L

Flag a directory that contains the NAG object library

-lnagc

Flag linking other NAG C library

-o

A flag to direct output to a different file

This command will invoke the "cc" compiler, compile a program called "d01ajce.c" search through directory "/apps/NAG/cll6a08dgl/include" and for additional source code and subroutine libraries, and create an executable file "d01ajce.exe."