Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-17-2009, 09:06 PM   #1
LQ Newbie
Registered: Aug 2008
Distribution: Fedora 9
Posts: 5

Rep: Reputation: 0
Can't compile f77 code using gfortran or g77

I have legacy fortran 77 code that used to compile seamlessly using g77 on an old machine. I've tried to recompile it on a new machine (old one is dead) using the original makefile, but the linker fails under g77, while there are persisting syntax errors using gfortran.

I have two source files readmixed.f and subroutines.f.

Under g77 the object files are produced using

$ f77 -c readmixed.f -o readmixed.o
$ f77 -c subroutines.f -o subroutines.o
but the linking fails with
$ f77 readmixed.o subroutines.o -o readmixed
subroutines.o(.text+0x0): In function `norm1_':
: multiple definition of `norm1_'
readmixed.o(.text+0x3987): first defined here
subroutines.o(.text+0x59): In function `cross_':
: multiple definition of `cross_'
readmixed.o(.text+0x39e0): first defined here
subroutines.o(.text+0xb9): In function `xparse_':
: multiple definition of `xparse_'
---------------- snip ----------------

and many similar messages, for each subroutine ...
With gfortran, I don't get through the compile. The user guide suggests a couple of options that might be useful:

-ff2c -- for f77 code
-std=legacy -- (seems to be the best of the options)
-fPIC -- a gcc option, which I recall once seeing in a posting about x86_64 options
While I think that the -ff2c is likely the option that matters (most), for all permutations of these parameters, I get errors like


real*4 bx(sz0), by(sz0), bz(sz0), ex(sz0), ey(sz0), ez(sz0)
Error: Expression at (1) must be of INTEGER type, found REAL

integer i
Warning: Nonconforming tab character at (1)

character st*(*)
Warning: Nonconforming tab character at (1)
These seem to suggest that the complaint is with f77 declarations in general, as if the -ff2c option were not included (but it was).

The gfortran is part of a standard gcc install with Fedora 11:

gfortran --version
GNU Fortran (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
Copyright (C) 2009 Free Software Foundation, Inc.
while I obtained the f77 compiler from yum:

# yum -y install compat-gcc-34-g77-3.4.6-13.x86_64
compat-gcc-34-g77.x86_64 0:3.4.6-13

Dependency Installed:
compat-gcc-34.x86_64 0:3.4.6-13 compat-libf2c-34.x86_64 0:3.4.6-13
As the rpms suggest, I'm using Intel x86_64 hardware:

$ uname -a
Linux #1 SMP Wed Nov 4 00:02:04 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
Any suggestions for what flags to supply to either version would be appreciated!
Old 11-18-2009, 01:55 PM   #2
Senior Member
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
There's been another thread recently sort of related to this (see for example post #3)

so clearly there are some surprises with the latest gfortran and f77 compatibility.

I do have a few suggestions.

Warning: Nonconforming tab character at (1)
If possible you might want to replace your [tabs] with whitespace; that's easy to do automatically.

Error: Expression at (1) must be of INTEGER type, found REAL
Presumably you can fix this in code easily enough, earlier versions of fortran compilers probably just let it go or gave a warning only..

Otherwise I'd just try the other options and try to track down the errors one-by-one.
Old 11-18-2009, 10:18 PM   #3
LQ Newbie
Registered: Aug 2008
Distribution: Fedora 9
Posts: 5

Original Poster
Rep: Reputation: 0

While the posting you linked doesn't seem to address the specifics of my case, I'll try your suggestion about replacing the tabs with spaces ...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
g77 3x faster than gfortran - why? What can I do? VelocideX Linux - Software 2 05-15-2009 03:12 PM
g77 compiles fortran 77 code; gfortran gives weird errors. Why? VelocideX Programming 5 04-22-2009 02:03 AM
undefined gfortran references when compiling with g77 StudMuffin Linux - Software 4 02-17-2007 06:06 AM
f77 and g77 issue contiang Linux - Software 1 12-13-2005 01:24 PM
Compiling with g77 thank you very much...but I solved compile with g77 gambato79 Fedora 9 07-19-2005 11:35 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:18 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration