The f77 Problem Page
People who know me might know that I
think f77 is a problem itself, however this page is dedicated to f77reorder
the f77 filter which solves some compatibility problems of the
f2c fortran-2-c translator and other f77-extended-standard compilers.
The f2c program is a big
help for compiling fortran programs on linux. There are other compilers
available, among them g77 by the FSF (gnu).
g77 suffers however from
some serious incompatibilies which makes it unusable for standard
HEP code. But g77 is not yet completed. It needs
founding of a
small scale compared to normal HEP software costs. We did not hear
of any experiences with the NAG fortran compilers. Feel free to
submit them to me
f77 extensions handled by f77reorder
Download the latest version of f77reorder(2.28)
(A set of new functions for libf77 & a man page by
Alex Romosan for the Debian GNU/Linux project.
See Changelog for details)
If you have any kind of problems with the f77reorder script, don't
hesitate a second to tell
about it. Otherwise the problem will certainly NOT get fixed.
The following extensions to f77 are not allowed within f2c. f77reorder
modifies the code passed to f2c in order to avoid compilation errors.
- <tab><digit> line continuation.
is converted to 5 space characters followed by a > sign.
- Include path search.
If using the -cpp option for the C-preprocessor, all fortran
are automaticly converted to cpp #include statements in order to use the
better include path search.
- Data statement reordering.
Standard f77 requires DATA statements to follow all variable
declarations and common block definitions. Due to the extensive
use of patchy/cmz this
requirement is not always easily fulfillable for HEP
reads in all initialization statements of functions/subroutines filters
out the DATA statements and places them at the end of the initialization
before the code begins.
is therefore transformed to
initialization within the declaration
This is also forbidden by standard f77. f77reorder contains a large
piece of code (I would call it sophisticated;-) to split
into pure declarations and data statements. This code is however not
tested too well and may produce wrong results, even if the declaration
does not contain initializations but only some unknown form of variable
integer a,b,c(n),d /2*0,3*1/, e, f/1/
is transformed by f77reorder to
Missing commatas at the end of common block definition lines
(since version 2.4)
In some f77 dialects it is possible to omit the comma at the end
of a continued line. Thus f77reorder will change
common /block/ a, b, c
& d, e, f
common /block/ a, b, c
> , ! inserted by f77reorder
& d, e, f
Bitoperations are not standard f77 function.
The libraries libf77.a for
both elf and aout format coming with f77reorder contain the functions
btest, ishft, iand, ior, ibset, ibclr, ieor.
However if you use this functions
in your code, you have to declare them as functions to your routine like
as they are not part of the compiler but only external functions.
The fortran function fdate is now also included in libf77 thanks to
Debug Comments - a 'D' at the start of a line
(since version 2.12)
Without the compiler flag -GD the 'D' at the start of a line is
replaced by 'C' and thus the line is marked as a comment. The
compiler flag -GD will make f77 replace the 'D' by a space character
and thus compile the line.
f77 extensions NOT handled by f77reorder
f77reorder error messages
f77reorder is not forgiving any errors it encounters in the variable
declaration part of the f77 functions. In fact it stops execution at
the first error it finds. This behaviour should be fixed in a later
Due to my lack of f77 knowlegde it might also happen that f77reorder
regards some variable declaration as an error which in fact is an
allowed one. Please send me the complete source files in such a case
to fix the problem. We were however not able to find any inconsistencies
in 40000 lines of f77 code tested...
f77reorder error messages are:
Debugging f77 code
A collegue of mine states that you do not need debuggers if you write
good code (I will *not* include his code to test his statement here ;-)
There are two options of including debug information for f77 code with
- Debugging in the f2c generated C code
The options to pass to f77 in this case are -g --keepC. This will
tell f2c (using the f2c option -c) to include the original f77 lines
into the program as C comments.
The advantage for the programmer is that the access of
common blocks with this method is easy as one gets the f2c generated common
block names from the C code while being able to check the execution of the
f77 code in the f77 code inlined as C comments.
- Debugging in the f77 source code
The options to pass to f77 are -g only (available since
version 2.15 of f77reorder). f77reorder passes the -g option to
f2c causing it to spit out #line information in the C code.
f77reorder then corrects this #line information in a second step
to change it back to the original source and include file lines before
cpp and f77reorder steps which probably changed the line and source file
Debugging works well here. One has to take into account that common blocks
are put into structures by f2c and can use the common-block name together
with gdb's TAB-expansion to get to the generated common-block names.
Variables and functions can however be accessed directly.
With one exception: To set a break point at the program start one
has to type
on the gdb prompt.
Last modified: Thu Nov 05 17:13:45 1998