[Beowulf] f2c

Jim Lux James.P.Lux at jpl.nasa.gov
Thu Mar 15 18:45:30 EDT 2007


At 11:38 AM 3/15/2007, Robert G. Brown wrote:
>On Thu, 15 Mar 2007, Leif Nixon wrote:
>
>>"Peter St. John" <peter.st.john at gmail.com> writes:
>>
>>>I had thought that after some point (say, f77) the practical thing was to
>>>translate fortran to C and use the C compiler, just because compiler writers
>>>love C, adopted it hugely, and write great compilers. Apparently I was
>>>mistaken.
>>
>>Compilers are designed to compile code written by humans.
>>Autogenerated code typically does not optimize well.
>
>Or be human-readable.  f2c code was just about as evil as any zomby
>woof or eskimo boy could be.  I used to try to use it to START porting
>fortran sources to C, but rapidly concluded that it was actually easier
>and saner to just rewrite the algorithms in native C by hand.  It was a
>really educational experience for those that would assert that fortran
>is "just like" C on the back end, though -- "just like" is well defined
>by the required compatibility libraries and stuff that has to be done to
>convert data structures.  They were not, not, not pretty...



Essentially this is no different than expecting to be able to read 
any of the intermediate pass outputs of the compiler (ASM if it 
generates it, or raw object code).  IF f2c were guaranteed bug free, 
it would be no different than compiling FORTRAN to assembler, and 
there would be no value in being able to human read the intermediate 
form (quick now, how many of you, except embedded processor 
programmers and compiler and benchmark geeks, actually look at the 
code the compiler generates? - or given the readership of this list.. 
how many of you in that small minority not fitting in the previous categories)

And, my very limited experience with f2c showed that it generated 
incorrect code in some cases (or, at least, a perfectly reasonable 
FORTRAN program that compiled and ran with a FORTRAN compiler either 
did not compile/link or give the same output).  That, in itself, 
prompted me to abandon any thought of it (well.. I actually abandoned 
it after actually looking at the generated output, thinking, naively, 
that there would be some simple problem in the C code that could be 
fixed up...)

Then, the issue that Leif raises is important... the output of f2c is 
not generally designed to match the expectations of an optimizing c 
compiler.  It could be, but I doubt that was intent of writing 
it.  This is why it's basically a hack to get around having a *real* 
FORTRAN compiler.

And of course, as the compiler writers on this list will tell you, 
every language is different, and leads to different optimization 
strategies, particularly if you care about performance. There's a 
significant difference in semantics between languages, as well as syntax.

Good compilers are worth their substantial development cost (whether 
the cost is borne by the buyer, by some generous soul donating their 
time to the cause, or by a company using them as a marketing 
tool).  Good compiler writers are worth their (hopefully) substantial wages.


James Lux, P.E.
Spacecraft Radio Frequency Subsystems Group
Flight Communications Systems Section
Jet Propulsion Laboratory, Mail Stop 161-213
4800 Oak Grove Drive
Pasadena CA 91109
tel: (818)354-2075
fax: (818)393-6875 


_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf

!DSPAM:45f9cced308931246014193!



More information about the Beowulf mailing list