Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
공지
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Q about Do Loops

WSinc
새로운 기여자 I
535 조회수

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.

0 포인트
2 응답
andrew_4619
명예로운 기여자 III
535 조회수

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:

  1. 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.

  2. The iteration count (if any) is decremented by 1.

  3. The DO variable (if any) is incremented by the value of the increment parameter (if any).

  4. 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.

 

0 포인트
IanH
명예로운 기여자 III
535 조회수

The limit on the nesting of the various executable block constructs is specified as 512 in the documentation for the current release.
 

0 포인트
응답