Gordon JC Pearce wrote:
Carlos E Murillo-Sanchez wrote:
by the numerical scientific computing community.
I even know
why, but I don't want to star a language war.
Aw go on, tell us... I for one would love to know why, if only to see
if it's worth brushing up my rather rusty FORTRAN "skills".
Ok, you asked for it...
1) There is an inertia factor, of course, with all those superb routine
libraries in FORTRAN (LAPACK, SCALAPACK and all that stuff at the
legendary netlib)
2) FORTRAN has been optimized for many decades to do just one kind
of task: computations involving arrays of floats, with
a very specific fetch/multiply/add to accumulator/increment pointers
sequence. This is a very regular task and the optimizations in
FORTRAN are directed to do this very efficiently. C compiler optimizers
must address many other possibilities (C is a much more "general
purpose" language). Thus, like it or not, for numeric computations
involving matrix/vector float operations, FORTRAN is usually
slightly faster than C. Of course, if you program a fast
Fourier transform in FORTRAN, it might actually be slower because
some of the operations don't fit the structure described
above: you have to negate bits in pointers to form the "butterflies"
(the basic FFT block). Why, even the storage scheme in FORTRAN
reflects numerics-specific thinking: 2D matrices are stored
column-wise, an appropriate choice if you know that en numerics,
matrix/vector multiplication is best thought of as a weighted
sum of the columns of the matrix, with the weights being the
elements of the vector. C, being designed by non-numerics people,
stores numbers row-wise. If you program numerics in C, you must
always store matrices transposed to get around this fact.
So, short explanation: FORTRAN is faster for array numerics, which
forms the core of scientific numeric computing, simply because
that's what the optimizer expects to find. C, having a more
general purpose, considers many other possibilities and is
less "tuned" to the needs of numerics.
Carlos.
Carlos E. Murillo-Sanchez email: carlos_murillo at
ieee.org
Dean of Engineering, Universidad Autonoma de Manizales, Manizales, Colombia
----
"Western civilization... thought like the greek, organized itself like
the romans and believed in itself like the hebrew." -- Ortega y Gasset.