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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran 95 standard (Free source form) 1

Status
Not open for further replies.

PiperArrowIV

Programmer
Sep 5, 2009
2
US
A blank shall be used to separate names, constants, or labels from adjacent keywords, names, constants, or labels.

It then has an example,

For example, the blanks after REAL, READ, 30, and DO are required in the following:

REAL X
READ 10
30 DO K=1,3

Sure enough, a statement such as

READ10

fails in gfortran.

But a statement such as

GOTO100

should also fail, but doesn't. How should the standard really be interpreted?
 
That with the GOTO is interesting.
Yes, you can use GOTO10 or GOTO 10 as well GO TO 10 similar to ENDDO or END DO

But I'm using everytime only GOTO 10 or GO TO 10 instead of GOTO10 because the last variant is not recognized by my source code editor as an language keyword and therefore not syntax-highlighted. In difference: I'm using sometimes end do and sometimes enddo, it doesn't matter because my editor recognizes both forms.

Code:
[COLOR=#a020f0]program[/color] example
   [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'Before GOTO'[/color]
   goto10
   [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],[COLOR=#ff00ff]10[/color]
     [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'This should be never displayed !'[/color]
   [COLOR=#804040][b]enddo[/b][/color]
[COLOR=#6a5acd]10[/color] [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'After GOTO'[/color]
[COLOR=#a020f0]end program[/color] example
Code:
[COLOR=#a020f0]program[/color] example
   [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'Before GOTO'[/color]
   [COLOR=#804040][b]goto[/b][/color] [COLOR=#ff00ff]10[/color]
   [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],[COLOR=#ff00ff]10[/color]
     [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'This should be never displayed !'[/color]
   [COLOR=#804040][b]end do[/b][/color]
[COLOR=#6a5acd]10[/color] [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'After GOTO'[/color]
[COLOR=#a020f0]end program[/color] example
Code:
[COLOR=#a020f0]program[/color] example
   [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'Before GOTO'[/color]
   [COLOR=#804040][b]go to[/b][/color] [COLOR=#ff00ff]10[/color]
   [COLOR=#804040][b]do[/b][/color] i[COLOR=#804040][b]=[/b][/color][COLOR=#ff00ff]1[/color],[COLOR=#ff00ff]10[/color]
     [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'This should be never displayed !'[/color]
   [COLOR=#804040][b]end do[/b][/color]
[COLOR=#6a5acd]10[/color] [COLOR=#804040][b]write[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'After GOTO'[/color]
[COLOR=#a020f0]end program[/color] example
All above variants work and produce the same output:
Code:
$ g95 example.f95 -o example

$ example
 Before GOTO
 After GOTO

IMHO, it's so, because Fortran is very old language and therefore the compiler (to be backward compatible) should support all the old dialects - it's imilar with COBOL.
So one thing is the standard Fortran95, but other thing is that the recent fortran compiler(e.g. g95 or gfortran) hould support the older dialects too (e.g. Fortran77 and older)

 
mikrom said:
That with the GOTO is interesting.
Yes, you can use GOTO10 or GOTO 10 as well GO TO 10 similar to ENDDO or END DO

But I'm using everytime only GOTO 10 or GO TO 10 instead of GOTO10 because the last variant is not recognized by my source code editor as an language keyword and therefore not syntax-highlighted. In difference: I'm using sometimes end do and sometimes enddo, it doesn't matter because my editor recognizes both forms.

Thanks mikrom. I should point out that the Fortran 95 standard does explicitly allow GO TO 10 or GOTO 10, as well as END DO or ENDDO, etc. It does seem that the standard should not allow GOTO10.

Thanks for your reply
 
As I said, IMHO GOTO10 was probably allowed by older Fortran standards or dialects and therefore the recent fortran compilers support it too.
 
I think Fortran 95 standard is a standard, but the Fortran 95 compiler implements the standard + older standards/dialects too. (As you know g95 compiles g77 sources too).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top