[Numpy-discussion] Fortran was dead ... [was Re: rewriting NumPy code in C or C++ or similar]

Sturla Molden sturla@molden...
Tue Mar 15 08:32:41 CDT 2011


Den 14.03.2011 23:02, skrev Sebastian Haase:
> Sturla has been writing so much about Fortran recently, and Ondrej now
> says he has done the move from C/C++ to Fortran -- I thought Fortran
> was dead ... !?   ;-)
> What am I missing here

No, it is just that Fortran receives less hype.  If Fortran was dead, 
why does OpenML define matrices in column major der? Why does ACML and 
Intel MKL define arrays as column major order?

> Apparently (from what I was able to read-up so far) there is a BIG
> difference between FORTRAN 77 and F95.
> But isn't gcc or gfortran still only supporting F77 ?

gfortran supports Fortran 77, Fortran 90, Fortran 95, most of Fortran 
2003 and some of Fortran 2008.


> How about IntelCC's Fortran ?  Is that superior?

Intel, Absoft and Portland are among the best Fortran compilers on the 
market, but gfortran is closing the gap fast.

Currently what maily makes Intel ifort and Absoft f95 produce faster 
binaries than gfortran is actually a faster math library.

> 1. How about debugging - does gdb work or is there somthing better ?

I use Absoft's Fx debugger.

gdb is ok, but it does not know anything about Fortran arrays.

> 2. How is the move of the F77 community to F95 in general ?   How many
> people / projects are switching.

F77 is hardly used for new projects. But F77 is  merely a subset of F95.

> 3. Or is the move rather going like Fortran 77 ->  C ->  Python ->
> Fortran 95   !?  ;-)

Fortran is good for only one thing, which is number crunching with data 
stored in arrays.

Fortran is much simpler than C, but still just as efficient. There are 
less room for shooting your own foot off.

First, Fortran 90 (and later) has a convinient array syntax, basically 
the same as NumPy and Matlab. The difference is that as Fortran 
compilers know these arrays, they can generate optimized code. Think of 
it as a form of compiled NumPy. In C++ one can make smart array classes 
that "think like a Fortran compiler" (cf. Blitz++) to avoid many 
temporary intermediates, but no array class for C++ is as smart as an 
autovectorizing Fortran compiler (Blitz++ is lagging far behind, and 
mainly abandonware).

Second, Fortran compilers can generate efficient code for parallel 
processing. This e.g. includes:

- autovectorization (SIMD, OpenMP) of array expressions.
- broadcasting arrays
- fortran pointers.
- aliasing disallowed.
- a large set of built-in, vectorized math functions.
- manual use of OpenMP.
- "where" and "forall" contructs.
- elemental and pure functions.
- internal functions.
- vectorized I/O with arrays.

For example: Parallel I/O in C or Python can take a lot of boiler-plate 
code and tunig with threads, asynchronous i/o, etc. In Fortran this is 
all done by the compiler. If a write or read statement takes an array as 
argument, the compiler Fortran knows what to do.


Sturla

















More information about the NumPy-Discussion mailing list