Compiling and Linking on Linux (WORK IN PROGRESS)

This should allow you to get your Analysis Control code linked into an executable.

We assume you're using gcc...

0. Make your life easier.

Execute the following commands:

alias build_job $CODE/cdfsoft1/development/bin/Linux2-EGCS_1_1/build_job.exe
alias expand $CODE/cdfsoft1/development/bin/Linux2-EGCS_1_1/

1. Run build_job and expand.

This procedure differs somewhat from that documented in CDF Note 384. build_job runs as in the note. However, you want to give the command "WRITE [filename].F" when you are ready to write the file, instead of giving it a .cdf extension. (In particular do not use EXIT to save your file; use QUIT and save yourself some confusion.)

The next step is to turn the ".F" file produced by build_job into a real FORTRAN file; this is done with the command

expand [filename].F

1.5. (Possibly) rename your FORTRAN files.

If your files have .f or .for extensions, you must rename them with the upper case extension .F. gcc needs this so it knows to run the preprocessor on them.

2. Compile your .F files to .o files.

The command is:

g77 -I$CODE/cdfsoft1/development/include -DUNIX -fno-second-underscore -fdollar-ok -c yourfile.F [-O2] [-g]

where the optional argument -O2 will optimize the output and -g will add debugging information.

Repeat as necessary until all the .F files are compiled. This method produces files sharing the name of the code files but with .o extensions.

3. Link.

This bit is the current problem; there's supposedly a standard way of doing this with SoftRelTools, but I can't figure it out. To do it the quick and dirty way (no .opt files, sorry!), do this:
  1. Get the Makefile.
  2. Edit the Makefile, so that the second line reads
    OBJECTS = myfile1.o myfile2.o ...
    where myfile?.o are the names of the .o files produced in step 2, and the first line reads
    EXENAME = target
    where target is the name of the executable you want.
    You can alter the other lines above the warning to fit your configuration. In particular, BINTYPE should be changed if you are using KCC-generated libraries.
  3. Run make. It should produce your executable.

4. Get the Makefile to do it all for you.

Experimentally, you can use the Makefile to run expand for you. Get this version of expand that does not overwrite the .CDF file, edit the line EXPAND in the Makefile to point to it, save the output of build_job to .CDF files, and make.

Quickly thrown together 5/18/00, Peter Onyisi
Last update 8/7/00, PO