forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FTN95 fails to compile valid Fortran 77 program

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 1580

PostPosted: Tue Oct 26, 2021 1:37 am    Post subject: FTN95 fails to compile valid Fortran 77 program Reply with quote

The program below is valid Fortran 77 code. FTN95 considers the array B to be a function and refuses to compile the code.

Code:
      program tst
C
      EQUIVALENCE (B(4),B3), (B(5),B4)
      DIMENSION B(16)
      b(4) = 10
      b4 = 5.0
      print *,b3,b(5)
      end


Although elements of the array B appear in the equivalence statement before the declaration of B as an array, in general all the declarative statements in a program unit had to be read and processed together, given the limitations of that language (Fortran 77).

The old FTN77 compiler accepts the same code without quibbles.

A workaround is to move the DIMENSION statement up. In the bigger code where this issue arose, there are over 500 EQUIVALENCE statements in the 50,000 line program, so doing similar relocations of such lines would take quite a bit of work.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7142
Location: Salford, UK

PostPosted: Tue Oct 26, 2021 8:19 am    Post subject: Reply with quote

mecej4

Thank you for the bug report which I have logged for investigation.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2268
Location: Yateley, Hants, UK

PostPosted: Wed Oct 27, 2021 11:12 pm    Post subject: Reply with quote

Sometimes I am amazed at the way other people program, and discover new things all the time. I had no idea that EQUIVALENCE could come before array declarations. And as for equivalencing B3 to B(4) - well, I can imagine that would give rise to all sorts of potential problems of comprehension years down the line, or even as little as 5 minutes after you punched the darn thing on that IBM card punch! I don't envy your job of understanding what the program is supposed to do.

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1580

PostPosted: Thu Oct 28, 2021 2:13 am    Post subject: Reply with quote

Eddie, sometimes the disorder in Fortran code is a sign of success -- different people extend an existing program to add new features, alter the way in which it works, make it more efficient, use less memory, etc.

It is natural that different people have different styles and, in the absence of a required "house style", the code starts looking rather odd after a few years. As long as the code is working, style and neatness may be given lower priority than new features and speed.

For an example, see the Digital Datcom program, available from https://www.pdas.com/datcomdownload.html .

Section 3.5, "Order of Statements and Lines", in the Fortran 77 standard, https://wg5-fortran.org/ARCHIVE/Fortran77.html , lays out some restrictions on the order of statements, but there is considerable leeway.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2351
Location: Sydney

PostPosted: Thu Oct 28, 2021 2:41 pm    Post subject: Reply with quote

Eddie,

I am with you on this one. I always put equivalence after declarations. Perhaps that was a rule from McCracken ?

Also, (not to include your views with this) I am amazed at the OOP examples that are published with hundreds of lines of code that do nothing.

For me coding is about defining a clearly set out data structure and then doing calculations that produce a useful result.
Some are trying to tell us that Modern Fortran should not do that.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2268
Location: Yateley, Hants, UK

PostPosted: Thu Oct 28, 2021 10:43 pm    Post subject: Reply with quote

mecej4 & John, I wasn't saying that it was wrong to do it in a way that I wouldn't. Generally speaking, I need to understand what I wrote 5 decades ago, but even though that means that I no longer need to do things in a way that they are understandable 5 decades hence - I stick to my own set of rules.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7142
Location: Salford, UK

PostPosted: Mon Nov 22, 2021 9:41 am    Post subject: Reply with quote

This failure has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group