fpt and WinFPT Reference Manual - Command-line Commands
| SimCon Home | Ref Manual Home |
UNWIND
Syntax:
!% UNWIND
Function:
!% UNWIND is written as a comment in the Fortran code immediately before a DO statement. The loop is marked as a candidate for unwinding. The marked loops are unwound in resonse to the UNWIND MARKED LOOPS command. If fpt unwinds the loop the original DO statement, and the terminating ENDDO statement (if present) are commented out. The code is repeated for each iteration and the DO loop control variable is replaced by its literal value.
The loops to be unwound may be terminated by statement labels or by ENDDO statements. Iteration must be controlled by a DO loop control variable, which may be INTEGER, REAL or DOUBLE PRECISION. The bounds and stride must be compile time constants. DO WHILE and DO UNTIL loops are not unwound.
Unwinding continues, starting either with the most deeply nested loops or with the outer loops, until all !%UNWIND commands have been processed. The order of unwinding is controlled by the command UNWIND { INNER | OUTER } LOOPS FIRST.
Statement labels are renumbered when loop unwinding is carried out, as described for the RENUMBER LABELS command.
Inline expansion of subroutines and functions is always carried out before loop unwinding.
Unwinding of loops is suppressed by the command DO NOT UNWIND LOOPS, which may be issued on the command line or interactively. This is useful if !% UNWIND commands have already been embedded in the code and fpt is run only to check or to reformat a program. The DO NOT UNWIND LOOPS command may be overridden by the command UNWIND MARKED LOOPS and vice versa.
Unwinding of loops is also suppressed by the command IGNORE COMMANDS IN THE CODE.
Where to Use this Command
| Operating system command line | No |
| Configuration file, config.fsp | No |
| Specification (fsp) files, *.fsp | No |
| Interactively, to FPT> prompt | No |
| Interactive command files | No |
| Embedded in the Fortran code | Yes |
Default
Loops are not unwound by default.
Examples
The loop shown below:
!% UNWIND DO I=1,3 A(I)=C(I)+DC(I)*DT ENDDO
is unwound to read:
! ************************************************************* ! !% UNWIND ! DO I=1,3 ! ! I=1 ! A(1)=C(1)+DC(1)*DT ! ENDDO ! ! ************************************************************* ! !% UNWIND ! DO I=1,3 ! ! I=2 ! A(2)=C(2)+DC(2)*DT ! ENDDO ! ! ************************************************************* ! !% UNWIND ! DO I=1,3 ! ! I=3 ! A(3)=C(3)+DC(3)*DT ! ENDDO ! ! *************************************************************
See Also
UNWIND { INNER | OUTER } LOOPS FIRST
Copyright ©1995 to 2025 Software Validation Ltd. All rights reserved.