- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a situation where I need to execute DO Loops where the final statement is not an ENDDO.
So, if I do a CYCLE, will it skip that statement , or execute that as well?
Of course, if had more than one statement to be executed at the end of the loop,
I would have to use a Go To instead.
Incidentally, does the compiler give us an upper limit regarding the depth of do loops inside each other ?
for example,
Do I1=1,10
do I2=1,10
do I3=1,10
enddo
enddo
enddo
Here, the depth is 3, but I came across a situation where the compiler gets confused when you have a depth much greater than that.
I had to solve the problem by moving the innermost statements into a separate routine.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a situation where I need to execute DO Loops where the final statement is not an ENDDO.
I don't get that, just insert and enddo problem solved. The is far clearer and more standard to always end loop on enddo and never to have a shared labelled statem,ent.
In answer to cycle:
CYCLE
Statement: Interrupts the current execution cycle of the innermost (or named) DO construct.
CYCLE [name]
name |
(Optional) Is the name of the DO construct. |
Description
When a CYCLE statement is executed, the following occurs:
-
The current execution cycle of the named (or innermost) DO construct is terminated.
If a DO construct name is specified, the CYCLE statement must be within the range of that construct.
-
The iteration count (if any) is decremented by 1.
-
The DO variable (if any) is incremented by the value of the increment parameter (if any).
-
A new iteration cycle of the DO construct begins.
Any executable statements following the CYCLE statement (including a labeled terminal statement) are not executed.
A CYCLE statement can be labeled, but it cannot be used to terminate a DO construct.
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that iteration of the construct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The limit on the nesting of the various executable block constructs is specified as 512 in the documentation for the current release.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page