LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-17-2009, 09:06 PM   #1
GradientDrift
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

Quote:
$ f77 -c readmixed.f -o readmixed.o
$ f77 -c subroutines.f -o subroutines.o
but the linking fails with
Quote:
$ 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:

Quote:
-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

Quote:
readmixed.f:14.16:

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

integer i
1
Warning: Nonconforming tab character at (1)
readmixed.f:2063.16:

character st*(*)
1
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:

Quote:
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:

Quote:
# yum -y install compat-gcc-34-g77-3.4.6-13.x86_64
.
.
.
Installed:
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:

Quote:
$ uname -a
Linux xxx.xxx.edu 2.6.30.9-96.fc11.x86_64 #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
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Knoppix
Posts: 1,823
Blog Entries: 14

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

http://www.linuxquestions.org/questi...kware--763423/

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

I do have a few suggestions.

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

Quote:
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
GradientDrift
LQ Newbie
 
Registered: Aug 2008
Distribution: Fedora 9
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks.

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 ...
 
  


Reply


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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 AM.

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