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 03-30-2009, 06:36 PM   #1
VelocideX
LQ Newbie
 
Registered: Oct 2007
Posts: 23

Rep: Reputation: 15
g77 compiles fortran 77 code; gfortran gives weird errors. Why?


Hi all,

I am trying to compile some pretty old f77 code. It compiles fine with g77, but gfortran gives weird errors, like:
----
vpfit.f:403.21:

open(unit=18,name='tempresets.txt',iostat=ios)
1
Error: Syntax error in OPEN statement at (1)
vpfit.f:957.21:

6991 open(unit=13,name=p13file,status='old',err=691)
1
Error: Syntax error in OPEN statement at (1)
vpfit.f:960.72:

end
1
Error: Label 6991 referenced at (1) is never defined
make: *** [vpfit.o] Error 1
---

Now there's not actually anything wrong with this code! For example, the label 6991 is actually on the next line =\

What's going on here?
How can I make gfortran compile the code?

Thanks!
 
Old 03-31-2009, 05:37 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by VelocideX View Post
Hi all,

I am trying to compile some pretty old f77 code. It compiles fine with g77, but gfortran gives weird errors, like:
----
vpfit.f:403.21:

open(unit=18,name='tempresets.txt',iostat=ios)
1
Error: Syntax error in OPEN statement at (1)
vpfit.f:957.21:

6991 open(unit=13,name=p13file,status='old',err=691)
1
Error: Syntax error in OPEN statement at (1)
vpfit.f:960.72:

end
1
Error: Label 6991 referenced at (1) is never defined
make: *** [vpfit.o] Error 1
---

Now there's not actually anything wrong with this code! For example, the label 6991 is actually on the next line =\

What's going on here?
How can I make gfortran compile the code?

Thanks!
Does gfortran have language selector ? I mean, there are many Fortran dialects, so you probably need to choose the correct one.

From name it looks like g77 is explicitly for Fortran 77.
 
Old 04-01-2009, 08:14 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 18.3+19.3, MX-18, Mandrake
Posts: 4,462

Rep: Reputation: Disabled
I seem to remember we used "LUN" (logical unit number, capital letters) not "unit". What is more, there were no inline assignments like "unit=18" possible, you had to assign beforehand, not in the brackets"()" or just fill in the number (position made clear what you meant). No idea whether that is a reason to throw an error here...
 
Old 04-21-2009, 07:34 PM   #4
spierce
LQ Newbie
 
Registered: Apr 2009
Posts: 1

Rep: Reputation: 0
gfortran open statement error

I experienced the same unhelpful error message when switching from g77 to gfortran

I solved it by changing
"name=" to "file=", i.e.:

open(lun,file=fname,status='old',form='formatted')

worked for me under gfortran.

I suspect "file=" is standard, while "name=" was an extension to g77.

Cheers

-Steve
 
Old 04-21-2009, 09:48 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

More specifically:

Quote:
NAME= is a specifier of the inquire statement. In the open statement it should be FILE=
Here's a great compendium of resources that might be of interest:
http://www.star.le.ac.uk/~cgp/fortran.html

'Hope that helps .. PSM
 
Old 04-22-2009, 02:03 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 18.3+19.3, MX-18, Mandrake
Posts: 4,462

Rep: Reputation: Disabled
@spierce and @paulsm4: I overlooked that. Right and thanks.
 
  


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
ekkk no g77 or fortran! ninja master Linux From Scratch 2 06-11-2009 02:13 PM
g77 in gcc 4.1.0 not found only gfortran fortran 95 compiler! I need fortran 77. TheBrick Linux - Software 3 07-04-2007 06:39 AM
undefined gfortran references when compiling with g77 StudMuffin Linux - Software 4 02-17-2007 06:06 AM
Any Fortran 90/95/2003 compiles? halfpower Debian 1 10-21-2005 08:54 PM
G77 Fortran included in Fedora 2 ? aeslin Linux - Software 1 11-08-2004 07:27 AM

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

All times are GMT -5. The time now is 07:50 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