[ACCEPTED]-How to compile Fortran 77 files in linux?-fortran
GCC's Fortran compiler name has changed:
g77 has 11 been replaced by
gfortran, which handles Fortran 10 95 and possibly more recent variants.
The 9 package in Ubuntu is called
sudo apt-get install gfortran
(or use synaptic)
The 8 package in Fedora is called gfortran and 7 is part of gcc, which you probably already 6 have:
sudo yum install gcc
(or use pirut)
Similar searches should 5 work for your distribution as well.
Update: On RedHat 4 4.1.2 the package seems to be called
gcc4-gfortran. Incidentally, you 3 ought to be able to search for this with 2 yum, and that may be the best answer to 1 your question:
yum search "*fortran*"
For Amazon Linux:
sudo yum --enablerepo=epel install gcc-gfortran
"Quark" wrote in his answer that 32 g77 is renamed gfortran. That is not correct.
g77 31 ang gfortran are different compilers. g77 30 is replaced by gfortran in the GNU compiler collection 29 (GCC), it is not renamed gfortran.
gfortran is a 28 modern Fortran compiler based on the g95 27 compiler. g77 is abandonware. They do not 26 share codebase. Binary files and libraries 25 are also not compatible between g77 and 24 gfortran, as they use different ABIs.
g77 23 is the same compiler known as f2c (which 22 can be downloaded from Netlib), or more precisely 21 a shell script called fc which called f2c 20 and then cc on the output. All g77 did was 19 to skip C as an intermediate language as 18 it came with a speed penalty in the 1980s 17 and early 1990s. f2c and g77 was written 16 by the same man and are otherwise identical. With 15 a modern CPU (long pipeline and branch prediction) and 14 a modern C compiler (much better alias analysis), g77 13 gives you no advantage over the original 12 f2c. gfortran, on the other hand, supports 11 modern Fortran standards (Fortran 90, 95, 2003, and 10 2008) in addtion to the older Fortran 77 9 and Fortran 66 (aka FORTRAN IV), and is 8 a clear improvement over g77 and f2c. It 7 also generates faster code and gives us 6 better error messages.
g77 is binary compatible 5 with f2c, but not with gfortran. gfortran 4 can be forced to assume g77 ABI by passing 3 -ff2c. This compiler option should be avoided 2 if possible as it degrades the performance 1 of the Fortran code.
There's http://www.g95.org/ that's available.
If I remember 12 well GNU doesn't have a FORTRAN compiler 11 but a FORTRAN preprocessor (or whatever 10 the name for that is). It just translates 9 your code to C and the compiles it with 8 the C compiler. Of course performance becomes 7 crap in the process.
However if you're using 6 FORTRAN I assume it's a kind of computation 5 project. If it's for free (not academic 4 and not course related) you can get Intel 3 FORTRAN compiler for free. In my experience 2 it goes about 3-4 times faster than any 1 free implementation.
gcc-fortran is the package name for
Fortran compiler for
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 + Done yast2 linux-y3pi: #
I did the following steps and worked!
Edit 2 your
add this text in that file (
deb http://hu.archive.ubuntu.com/ubuntu/ hardy universe deb-src http://hu.archive.ubuntu.com/ubuntu/ hardy universe deb http://hu.archive.ubuntu.com/ubuntu/ hardy-updates universe deb-src http://hu.archive.ubuntu.com/ubuntu/ hardy-updates universe
Save 1 file
Open terminal, type :
sudo apt-get install fort77
The means for getting software installed 17 is distribution-specific. For example, in 16 Ubuntu9, I would kick up Synaptic and do 15 a search for Fortran or g77 (apt-get can 14 also be used).
The other distributions I 13 know little about although I've heard of 12 yum and yast for (I think but I'm not sure) RedHat 11 and Suse.
If it's not available through your 10 standard package installer, you'll have 9 to find another solution, such as:
- using a different Fortran; or
- building it from the source.
That second 8 method sounds ominous but it's really not 7 (other than ensuring you have the right 6 dependencies). The configure/make/install 5 process that most source packages follow 4 makes it remarkably easy to do in a cross-distribution 3 manner.
Some RPMs can be found here. The GNU 2 software is available here or you may want to 1 check out their mirrors for a faster site.
You can also use Netbeans and make c&c++ project 4 and make add Fortran with new .f90 file 3 and use Netbeans tools to run and debug 2 . before that you must install gcc and gfortran 1 packages .
In my experience, Red Hat distributions 10 (and those based on it) have gfortran included, but 9 it is an option when you do the installation, so 8 it seems probable that your system was set 7 up without gfortran. If you have installation 6 media, I think you should be able to install 5 gfortran from there.
Otherwise, to get the 4 proper gfortran RPM for your system, I suggest 3 the related rpmfind page.
Once you get gfortran installed, I 2 think the "-std=legacy" (quotes 1 mine) should allow an F77 compile to work.
More Related questions