Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

132 Characters per line limit in Fortran 90

Status
Not open for further replies.

Opteron

Technical User
Sep 14, 2010
4
GR
Dear all

i have made a small program in Fortran 90 and in a line i had to specify the double precision variables i wanted to use. The program worked fine. Some time later i have found that in fortran a line can contain a maximum of 132 characters. The line in which i have specified the double precision variables does exceed the 132 characters limit. But as i have said the program works without warning and errors. Should i split the aforementioned line in more keeping the limit in mind or should i leave the program as it is?


Thanks!
 
Your fortran compiler has probably a switch to allow more than 132 characters in a line.

I depends of personal programming style, but IMHO the sources with short lines are better readable.

I personally like to write short lines up to 80 characters in every programming language I'm using - and that's not only Fortran or COBOL but languages without line length limitation like: Perl, VBscript, SQL, ...
 
Well the source file i am using is in free form. According to my compiler's manual :

The default line length for standard Fortran is 72 characters. Microsoft Fortran PowerStation allows 72, 80, and 132 characters per line for fixed form source code. You can select a line length in one of three ways:
· Use the !MS$LINELENGTH metacommand
· Use the /4L{72|80|132} command line option
· Specify the line length in Microsoft Developer Studio, in the Project Settings menu, Fortran tab, at the Language Extensions category

Line length is in effect for the remainder of the source file and applies to any include files, unless you specify differently. If you set a different line length in an included file, the line length returns to its original value after the end of the include file.
Statements can contain up to 7200 characters. This can be defined in a number of ways, including 100 continuation lines in 72 column fixed source, 54 continuation lines in 132 column fixed form, or one very long line when using the /4Yf command line option.



So, when does the 132 limit and the 7200 limit apply?
 
Opteron said:
So, when does the 132 limit and the 7200 limit apply?
First of all I'm not familiar with Microsoft Fortran PowerStation.
But i think, that 7200 characters for one statement applies always
and the 132 characters line length applies as written in your manual:
[ul]
[li]when you declare it in your project[/li]
[li]or use the metacommand (mentioned above) in your source[/li]
[li]or use the command line switch (mentioned above)[/li]
[/ul]
 
Thank you very much for your help!


Regards!
 
You'll need a very good reason to exceed the 7200 character limit. In Fortran IV, I've only seen someone exceed the 20 continuation line (which was the FIV limit) twice. That was because he had 32 character identifier names (a FIV extension) and a complex formula. He only managed 2 variables per line.

The other time was from autogenerated code. It was an array initialization. This was solved by reading the initial values in from a file.

There really isn't any need to do this: the individual parts of the formula can be broken up and then put together in a simpler form. The amount of code generated is the same but debugging is a lot simpler when it is broken up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top