next up previous

2.0.5 Unix Compiler Options     continued...

Examples
cc -o parallel -O2 parallel.c
Calls the C compiler, cc, to compile parallel.c and writes the compiled, executable version of this file to parallel. The code is optimized to level 2.
f77 -o newfile -g parallel.f
Calls the Fortran compiler, f77, to compile parallel.f, writing the executable version of this file to newfile. Information for debugging is produced as well.

cc -c subr1.c
f77 -c subr2.f
f77 -o test mainprog.f subr1.o subr2.o

First, compile subr1.c with the C compiler, cc, without linking. This will produce an object file, subr1.o. Next, compile subr2.f with the Fortran compiler, f77, without linking. This will produce an object file, subr2.o. Finally, compile mainprog.f, with the Fortran compiler, f77, linking the libraries as well as subr1.o and subr2.o. The executable code produced will be written into test. This is useful when a program calls subroutines in both C and Fortran. If changes are only made to one subroutine, compiling subroutines separately and then compiling the main program with the object files can save time.