29

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.

3 Answers 3

26

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.

19

Type in your terminal;

  • For the Fortran 95 Compiler:

    sudo apt-get install gfortran
    
  • For the Fortran 77 Compiler:

    sudo apt-get install fort77
    
2
  • And for Fortran 90? Mar 5, 2018 at 7:40
  • On Ubuntu 18.04, I ended up installing gfortran-7 that is compatible with the gcc-7. I also needed g++, so I did sudo apt-get install gcc-7 g++-7 gfortran-7. The weird thing was that there was no symlink for gfortran like that was for gcc and g++, so sudo ln -s /usr/bin/gfortran-7 /usr/bin/gfortran. launchpad.net/ubuntu/bionic/+package/gfortran-7 There is also a gfortran-8. Jul 24, 2019 at 9:47
1

You may also try f77, from Intel. There is a free license if you are a student, an educator of an open source contributor (there are also other profiles that fit Intel's requirements for free software license, usually you fit if you are not using it for commercial proposes).

https://software.intel.com/en-us/qualify-for-free-software

Just click on one of the user profiles above, register,download and install. I'm using Intel Parallel Studio XE, which also comes with support to MPI so you can run parallel tasks. When downloading it, you can chose the complete installer with a few GB or the partial installer which will let you choose what tools you want to install. As I just wanted Fortran, I downloaded the partial installer and installed using the following:

$ tar -xvf parallel_studio_xe_2018_update1_cluster_edition_online.tgz 
$ cd parallel_studio_xe_2018_update1_cluster_edition_online
$ sudo ./install_GUI.sh

After that just follow the instructions to finish the procedure. When done, you must load the environment so you can use the compiler. Just type

$ source /opt/intel/bin/ifortvars.sh intel64

And after that, you will notice the commands ifort and f77 are available at terminal. Those are compilers to Fortran. You can find more information about it here: https://software.intel.com/en-us/intel-fortran-compiler-17.0-user-and-reference-guide

Remember that you have to load the environment every time you start a new session on terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .