fpt and WinFPT Reference Manual - Command-line Commands
| SimCon Home | Ref Manual Home |
SEPARATE DO AND GOTO DESTINATION LABELS
Syntax:
[DO NOT] SEPARATE DO AND GOTO [STATEMENT] [DESTINATION] LABELS
Function:
A GOTO, arithmetic IF or alternate return may transfer control to the statement label which terminates a DO loop. There are two possible situations:
fpt modifies all labelled statements which are referenced both by DO and by GOTO statements to separate the target labels. New labels are generated, and fpt therefore renumbers all statement labels so as to maintain a consistent order throughout the program. Please see RENUMBER LABELS for a description of this process.
If the GOTO statement is inside the DO loop, the expected behaviour is that the current iteration of the DO loop ends and the next iteration begins. Many compilers have been tested to verify this behaviour and no exceptions have been observed. fpt therefore modifies the labelled statement as shown in the first example below.
If the GOTO statement is outside the DO loop, the behaviour depends on the compiler in use. The following have been observed:
fpt modifies the code as shown in the second example below. A new labelled CONTINUE statement is written after the end of the DO loop, and this becomes the target for the GOTO statement.
Where to Use this Command
| Operating system command line | Yes |
| Configuration file, config.fsp | Yes |
| Specification (fsp) files, *.fsp | Yes |
| Interactively, to FPT> prompt | Yes |
| Interactive command files | Yes |
| Embedded in the Fortran code | Yes |
Default:
No change is made by default.
Examples:
In the code shown below, the GOTO statement is within the DO loop.
DO 100 I=1,10 IF (A(I) .GT. CRIT) GOTO 100 A(I)=CRIT 100 CALL STATENT(A(I))
fpt rewrites the code:
DO 1010 I=1,10 IF (A(I) .GT. CRIT) GOTO 1000 A(I)=CRIT 1000 CONTINUE CALL STATENT(A(I)) 1010 CONTINUE !-------------^--------------------------------------------------------------- ! FPT - 2311 GOTO from inside loop directed to different label !-----------------------------------------------------------------------------
In the following example, the GOTO is outside the loop:
IF (INIT .EQ. -1) GOTO 220 DO 220 J=1,5 220 C(J)=0.0
Note that this code is legal on a number of systems. fpt rewrites the code:
IF (INIT .EQ. -1) GOTO 1040 DO 1030 J=1,5 C(J)=0.0 1030 CONTINUE 1040 CONTINUE !-------------^--------------------------------------------------------------- ! FPT - 2311 GOTO from outside loop directed to different label !-----------------------------------------------------------------------------
See Also
Copyright ©1995 to 2025 Software Validation Ltd. All rights reserved.