Examples of Linking and Running non-A_C jobs on cdfsga


Often the need the arises to compile and link a simple Fortran job that does not require the use of Analysis_Control and so does not use link_ana. We give some tips here for doing this. More detail about the Fortran compiler f77 can be found by doing man f77. There is also additional information about compiling, linking and the use of the make utility in the "UNIX at Fermilab" guide available from the 8th floor Computing Division library. It is also available online.

The following aliases will be useful, they should be added to your $HOME/.cshrc file.


	alias for f77 -c -u -static !*
	alias ford f77 -c -u -g -static !*
	alias forO2 f77 -c -u -static -O2 !*
	
for does normal compilation
ford does debug compilation
forO2 does O2 optimized compilation

The -u option is like specifying IMPLICIT NONE in your code. Some programs that you might have (particularly those from theorists) don't use IMPLICIT NONE. You will then get lots of compliation errors so you will need to compile without the -u option.

Very often you will want to use the CERN libraries in your program. These are obtained with setup cern which gives you the current version. Other versions may also be available. You can find a list with ups list -a cern.
The libraries live in $CERN_DIR/lib. The commonly used ones are libpacklib.a (contains hbook), libkernlib.a and libmathlib.a.

Here is an example script link_norm to compile a program called norm.f that uses CERN libraries

Normal compilation/linking

#!/bin/csh 
setup cern
for norm.f
f77 -o norm.exe norm.o $CERN_DIR/lib/libpacklib.a \
$CERN_DIR/lib/libkernlib.a \
$CERN_DIR/lib/libmathlib.a $CERN_DIR/lib/libpacklib.a

Debug Compilation/linking
#!/bin/csh 
setup cern
ford norm.f
f77 -o norm.exe norm.o $CERN_DIR/lib/libpacklib.a \
$CERN_DIR/lib/libkernlib.a \
$CERN_DIR/lib/libmathlib.a $CERN_DIR/lib/libpacklib.a -g

O2 compilation/linking
#!/bin/csh 
setup cern
forO2 norm.f
f77 -o norm.exe norm.o $CERN_DIR/lib/libpacklib.a \
$CERN_DIR/lib/libkernlib.a \
$CERN_DIR/lib/libmathlib.a $CERN_DIR/lib/libpacklib.a -O2

For more complicated programs the make utility can be used to maintain the program. Please consult the "UNIX at Fermilab" guide for information about this topic.