Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Exemplar Fortran 77, Exemplar C: Exemplar C and Fortran 77 Programmer's Guide > Chapter 1 Introduction

Compiler usage

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

The examples in this section demonstrate the use of the C and Fortran 77 compilers. The functionality and options illustrated in any example in the book apply to both the C and Fortran 77 compilers.

Using the C compiler

The two C compilers are described below:

  • cc is the Exemplar C compiler and is located at /opt/ansic/bin/cc.

  • c89 is the Exemplar POSIX-conforming C compiler and is located at /opt/ansic/bin/c89.

The remainder of this book refers to the cc compiler. Any cc example also applies to the c89 compiler.

The cc compiler command has the form:

% cc [options]files

where

options

Is zero or more C compiler options

files

Is a space-separated list of one or more files

For example, the following command

% cc prog1.c prog2.c prog3.c

compiles the three files (prog1.c, prog2.c, prog3.c) and produces an executable, which is named a.out by default.

In this command,

% cc -o prog prog.c proc1.o

cc compiles prog.c to produce the object file prog.o, then calls the linker ld to link prog.o and proc1.o with the default start-up routines and library routines. The file prog.o is deleted after linking. The -o prog causes the resulting executable file to be named prog instead of a.out.

For additional information, see the cc(1) man page.

Using the Fortran 77 compiler

The two Fortran 77 compilers are described below:

  • f77 is the Exemplar Fortran 77 compiler and is located at /opt/fortran/bin/f77.

  • fort77 is the Exemplar POSIX-conforming Fortran 77 compiler and is located at /opt/fortran/bin/fort77.

The remainder of this book refers to the f77 compiler. Any f77 example also applies to the fort77 compiler.

The f77 compiler command has the form:

% f77 [options]files

where

options

Is zero or more Fortran 77 compiler options

files

Is a space-separated list of one or more files

For example, the command

% f77 -c prog.f

compiles the file prog.f to produce the object file prog.o, then (because of the -c option) suppresses linking. The prog.o file can be linked later by including it on a f77 command line or by using the linker (ld) directly.

In the following example,

% f77 -v prog1.f prog2.f

the verbose mode is enabled by using -v. When compiling in verbose mode, the compiler displays (to standard error) a step-by-step description of the compilation process.

This command

% f77 +O3 +Oparallel prog.f

shows the request of level 3 optimizations (+O3) and the request that the compiler honor the parallelism directives of the Exemplar programming model and generate parallel code where appropriate (+Oparallel). The +Oparallel option is only valid at +O3 and above.

For additional information, see the f77(1) man page.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.