Ubuntu – How to install a Fortran 77 compiler

aptfortranpackage-managementsoftware installation

I have just installed 12.04 LTS on my laptop and I'm kinda new in this. I am required to write some program in Fortran 77 and I need a Fortran 77 compiler. I have tried installing g77 as described in the Ubuntu website but was unable to do so. I have typed in the following in terminal:

sudo apt-get install g77

and get the following:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package g77 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'g77' has no installation candidate

May I know what is the problem? I have tried searching g77 in the software center but apparently it is not there. Does this mean it is not available for 12.04?

I'm currently using an Asus K43S laptop with Intel Core i5-2450M processor and my Ubuntu is installed alongside Windows.

Best Answer

There is GNU Fortran 95 compiler in the repositories, which can be installed using

sudo apt-get install gfortran

This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms supported by the gcc compiler. It uses the gcc backend to generate optimized code.

If you specifically need the bleeding edge features of Fortran 77, there's f2c program which apparently can translate Fortran 77 into C.

f2c translates FORTRAN 77 (with some extensions) into C so that it can then be compiled and run on a system with no Fortran compiler. The C files must then be linked against the appropriate libraries.

This is an actively maintained FORTRAN to C translator and with the fort77 frontend provides an ideal way to compile FORTRAN routines as black boxes (for example for invocation from C). Source level debugging facilities are not available, and error messages are not as well developed as in g77.

I'm not sure about what happened to the g77 compiler - apparently, it was present in older versions of Ubuntu, but not anymore, at least not in the standard repositories.