How to compile Fortran 77 files in linux?

54,599

Solution 1

GCC's Fortran compiler name has changed: g77 has been replaced by gfortran, which handles Fortran 95 and possibly more recent variants.

The package in Ubuntu is called gfortran:

sudo apt-get install gfortran

(or use synaptic)

The package in Fedora is called gfortran and is part of gcc, which you probably already have:

sudo yum install gcc

(or use pirut)

Similar searches should work for your distribution as well.

Update: On RedHat 4.1.2 the package seems to be called gcc4-gfortran. Incidentally, you ought to be able to search for this with yum, and that may be the best answer to your question:

yum search "*fortran*"

Solution 2

For Amazon Linux:

 sudo yum --enablerepo=epel install gcc-gfortran

Solution 3

"Quark" wrote in his answer that g77 is renamed gfortran. That is not correct.

g77 ang gfortran are different compilers. g77 is replaced by gfortran in the GNU compiler collection (GCC), it is not renamed gfortran.

gfortran is a modern Fortran compiler based on the g95 compiler. g77 is abandonware. They do not share codebase. Binary files and libraries are also not compatible between g77 and gfortran, as they use different ABIs.

g77 is the same compiler known as f2c (which can be downloaded from Netlib), or more precisely a shell script called fc which called f2c and then cc on the output. All g77 did was to skip C as an intermediate language as it came with a speed penalty in the 1980s and early 1990s. f2c and g77 was written by the same man and are otherwise identical. With a modern CPU (long pipeline and branch prediction) and a modern C compiler (much better alias analysis), g77 gives you no advantage over the original f2c. gfortran, on the other hand, supports modern Fortran standards (Fortran 90, 95, 2003, and 2008) in addtion to the older Fortran 77 and Fortran 66 (aka FORTRAN IV), and is a clear improvement over g77 and f2c. It also generates faster code and gives us better error messages.

g77 is binary compatible with f2c, but not with gfortran. gfortran can be forced to assume g77 ABI by passing -ff2c. This compiler option should be avoided if possible as it degrades the performance of the Fortran code.

Solution 4

There's http://www.g95.org/ that's available.

If I remember well GNU doesn't have a FORTRAN compiler but a FORTRAN preprocessor (or whatever the name for that is). It just translates your code to C and the compiles it with the C compiler. Of course performance becomes crap in the process.

However if you're using FORTRAN I assume it's a kind of computation project. If it's for free (not academic and not course related) you can get Intel FORTRAN compiler for free. In my experience it goes about 3-4 times faster than any free implementation.

Solution 5

gcc-fortran is the package name for Fortran compiler for openSUSE 11.x.

linux-y3pi: # zypper what-provides gcc-fortran
Loading repository data...                                                                                                                                                        
Reading installed packages...
S | Name        | Type    | Version | Arch   | Repository             
--+-------------+---------+---------+--------+------------------------
i | gcc-fortran | package | 4.5-4.2 | x86_64 | openSUSE-11.3-Oss      
i | gcc-fortran | package | 4.5-4.2 | x86_64 | openSUSE-11.3 11.3-1.82
v | gcc-fortran | package | 4.5-4.2 | i586   | openSUSE-11.3-Oss      
[1]+  Done                    yast2
linux-y3pi: # 

http://gcc.gnu.org/fortran/

Share:
54,599

Related videos on Youtube

chris
Author by

chris

Updated on July 09, 2022

Comments

  • chris
    chris almost 2 years

    I need a compiler for Fortran 77 in linux.

    Are there any free compilers out there that people use?

    I've heard about g77, but I can't find the rpm or how to install it in linux.

    Thanks!

  • chris
    chris almost 15 years
    where can i get the Free copy of intel fortran for linux? I am having difficulty finding the free version on google.
  • chris
    chris almost 15 years
    i have redhat. i tried "sudo yum install g77" and also gfortran but it says no package g77/gfortran available. am i doing it wrong?
  • Stephen C
    Stephen C almost 15 years
    I think he might be referring to the free 30 day evaluation license.
  • Stobor
    Stobor almost 15 years
  • Stobor
    Stobor almost 15 years
    Also, gfortran is a full compiler: gcc.gnu.org/wiki/GFortran
  • Tim Whitcomb
    Tim Whitcomb almost 15 years
    If you're doing non-commercial development, the Intel compiler is a great deal.
  • quark
    quark almost 15 years
    It's not called g77 for one thing. I did a Google search for "Redhat 4.1.2 gfortran". The package is apparently called "gcc4-gfortran". Updating the answer.
  • Sturla Molden
    Sturla Molden over 9 years
    g77 is not renamed gfortran. Those are not the same.
  • Vladimir F Героям слава
    Vladimir F Героям слава over 9 years
    Hi didn't write that. He wrote GCC now has a compiler with different name which replaced g77. The accepted answer is correct.
  • Sturla Molden
    Sturla Molden over 9 years
    It is correct now. It wasn't when I commented.

Related