A few basic questions about FORTRAN 77 program
Author |
Message |
Tong Zha #1 / 5
|
 A few basic questions about FORTRAN 77 program
Hi, all: I came across a F77 program, there are several things I couldn't understand, hope someone may explain a bit: 1. in the program, some of the WRITE (*,*) statement have a 'F' at the 1st column, what dose it mean ? 2. at the very beginning of some .for files, there is this line: $DEBUG:'D' What does this mean ? will it do anything to the source file ? 3. About the line labels, does it matters if I write the numbers at the very beginning of the line or after column 6 ? Thanks, Tong
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Dr Ivan D Reid, muSR Facili #2 / 5
|
 A few basic questions about FORTRAN 77 program
Quote: > I came across a F77 program, there are several things I couldn't >understand, hope someone may explain a bit:
Do you know what computer/operating system it came from. There seem to be some non-standard features. Quote: > 1. in the program, some of the WRITE (*,*) statement have a 'F' at the > 1st column, what dose it mean ?
I'm guessing these are some sort of diagnostic print statements that are only activated when a particular flag is used when compiling. Quote: > 2. at the very beginning of some .for files, there is this line: > $DEBUG:'D' > What does this mean ? will it do anything to the source file ?
Some compilers have an extension to the 'C' in the first column for a comment where a 'D' there is treated as a comment unless compiled with a debug flag. It seems this is telling the compiler to do the same thing. Quote: > 3. About the line labels, does it matters if I write the numbers at the > very beginning of the line or after column 6 ?
Line numbers should be in columns 1-5; column 6 is for continuation characters. Statements (normally) are in columns 7-72. --
From 1/4/00: Dept of Physics & Astronomy, UCL, Gower St., London. WC1E 6BT KotPT -- "for stupidity above and beyond the call of duty".
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Kurt Kaellbl #3 / 5
|
 A few basic questions about FORTRAN 77 program
Quote: >Hi, all: > I came across a F77 program, there are several things I couldn't >understand, hope someone may explain a bit: > 1. in the program, some of the WRITE (*,*) statement have a 'F' at the > 1st column, what dose it mean ? > 2. at the very beginning of some .for files, there is this line: > $DEBUG:'D' > What does this mean ? will it do anything to the source file ? > 3. About the line labels, does it matters if I write the numbers at the > very beginning of the line or after column 6 ? > Thanks, > Tong
I guess the program was written for MS's fortran 77 ( 5.0 or 5.1). That compiler allowed any letter in column 1 to be used for comment lines. $DEBUG:'D' is one of MS's "metacommands". This one enabled some debug features as: Test of integer overflow. Test if assigned GOTO. Checks range of subscripts and substring. Some other things I don't remember. The string 'D' told the compiler to neglect any upper- or lowercase D in the first column and compile these lines into the program. The string could have more than one character. A statement label must be placed in column 1 through 5 but can start in any of these columns. Kurt Kaellblad, Ph.D. Dept. of Building Science Lund University, Sweden
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
N. Shamsunda #4 / 5
|
 A few basic questions about FORTRAN 77 program
Quote:
> Hi, all: > I came across a F77 program, there are several things I couldn't > understand, hope someone may explain a bit: > 1. in the program, some of the WRITE (*,*) statement have a 'F' at the > 1st column, what dose it mean ?
With most compilers, any character in Col-1 makes that line a comment line Quote: > 2. at the very beginning of some .for files, there is this line: > $DEBUG:'D' > What does this mean ? will it do anything to the source file ?
If the file is compiled with a compiler flag to include lines beginning with a 'D', such lines will not be treated as comment lines. If no compiler flag is used, these "D-lines" will be treated as comments. Quote: > 3. About the line labels, does it matters if I write the numbers at the > very beginning of the line or after column 6 ?
Yes, in fixed format Fortran columns 1-5 are the only place where a statement number can be placed. Quote: > Thanks, > Tong
N. Shamsundar University of Houston
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Richard Main #5 / 5
|
 A few basic questions about FORTRAN 77 program
Quote:
> With most compilers, any character in Col-1 makes that line a > comment line
I seriously doubt the accuracy of that statement. I'd be somewhat surprised to find *ANY* compilers that act this way. If there are any, then they are non-standard and will fail to compile a large percentage of Fortran codes. The standard allows statement numbers to start in column 1. I am aware that some people have a convention of avoiding this, but many other people do not, and the standard explicitly allows it. There is a huge amount of code out there with statement numbers starting in column 1. If I were to be really pedantic, I'd note that blank is a character. Now if you were to restrict the statement to characters other than digits or blanks, then the statement becomes at least plausible. I didn't know that there were compilers quite that liberal, but its at least an allowed extension. (I'd think it a rather unfriendly one, as it seems likely to quietly ignore reasonably simple errors like forgetting to indent a statement). The standard allows C and * as comment characters. I'm familiar with D as an extension for debugging. I hadn't heard of allowing F, but then I haven't heard of everything. -- Richard Maine
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
|
|