Re: g95 versus gfortran



Tim Springer schreef:
For me this has raised the following questions.
1) Why are two compilers being developed.

OK. Boring history.

It started with just one compiler. Development of G95 was started in
early 2000 by Andy Vaught, but he was reluctant to include the work
from other people. At one point there were five different projects
working on some version of G95, working on different bits missing in
Andy's "official" G95 tree.

It also became clear in private conversations between Andy and others
(including myself) that Andy did not intend to follow the rules and
guidelines necessary to make G95 an integrated part of GCC. He wished
to instead keep it as a separate front end, like it is now (and like
e.g. the G77 and Ada front ends for GCC were for a long time). Andy
believed this approach would result in a more stable and usable
compiler for end users.

Other people wanted to integrate the front end with GCC for various
reasons, like not having to keep track of changes in GCC. If someone
wants to change the GCC interface between the code generator and the
front ends, it is his/her responsibility to keep all front end
workings. So the maintenance burden is spread out more if your front
end is an integral part of GCC, and as front end developers you don't
have to worry about the interface anymore.

The original G95 project (i.e. with more people than just Andy trying
to contribute) eventually fell apart in early 2003 when Paul Brook and
I forked G95. We imported the fork into the GCC code base a few months
later. This front end is now known as gfortran.

So the compilers have a common ancestor, but the way they are related
to GNU/GCC is different.

Basically you see Andy was "right" because he got a more stable
compiler out to end users more quickly, and that the gfortran fork was
"right" because gfortran benefits more quickly from improvements to
the GCC code generators. More on that below...



2) What are the differences between the compilers.

There are *lots* of differences, so I can only give some impressions
here:

The general impression seems to be that G95 conforms better to the
standard and has fewer bugs than gfortran. I know of at least some
points where G95 can compile that gfortran still cannot (e.g.
equivalence with an initializer). On the other hand, I also have
examples where gfortran compiles code while G95 choques on it.
(Gfortran uses the bug tracking system of gcc.gnu.org. If you run into
some problems, please report them there ;-)

Gfortran generally produces faster code than G95, because more
attention has been given to gfortran for producing easy-to-optimize
intermediate code, and because gfortran is based on a code generation
engine that is more recent than the one that G95 uses.

Gfortran has support for OpenMP and it tends to have fewer problems
with legacy g77 code. G95 has support for more Fortran 2003 features
than gfortran does.



3) Which compiler should a fortran program developer (like me) use and why.

Use both if you can, and use even more compilers if you have access to
them! ;-)
If you use more than one compiler, your code will be more portable
because different compilers can complain about different non-standard
code issues.


Gr.
Steven

.