Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Execution Control

Execution of a program consists of the asynchronous execution of the program in a fixed number of one or more of its images. Each image has its own execution environment, including floating-point status, a set of data objects, input/output units, and procedure pointers.

A program normally executes statements in the order in which they are written. Executable control constructs and statements, and procedure invocations, modify this normal execution by transferring control to another statement in the program, or by selecting blocks (groups) of constructs and statements for execution or repetition.

Procedures may be invoked by the CALL statement (subroutine), during expression evaluation (function), or as part of data definition and handling (user-defined operators and FINAL procedures). There are many ways to define a procedure: for example, external, internal, contained, type-bound, defined operator or assignment, and module. All procedures have one entry point; procedures usually return to their caller.

The control constructs ASSOCIATE, CASE, DO, IF, SELECT RANK, and SELECT TYPE contain blocks and can be named. The name must be a unique identifier in the scoping unit, and must appear on the initial line and terminal line of the construct. On the initial line, the name is separated from the statement keyword by a colon (:).

A block can contain any executable Fortran statement except an END statement. You can transfer control out of a block, but you cannot transfer control into another block.

DO loops cannot partially overlap blocks. The DO statement and its terminal statement must appear together in a statement block.

The following are execution control statements or constructs:

  • ASSOCIATE construct

    Creates a temporary association between a named entity and a variable or the value of an expression. The association lasts for the duration of the block.

  • BLOCK construct

    Executes a block of statements or constructs that can contain declarations.

  • CALL statement

    Transfers control to a subroutine subprogram.

  • CASE construct

    Conditionally executes one block of constructs or statements depending on the value of a scalar expression in a SELECT CASE statement.

  • CONTINUE statement

    Primarily used to terminate a labeled DO construct when the construct would otherwise end improperly with either a GO TO, arithmetic IF, or other prohibited control statement.

  • CRITICAL construct

    Limits execution of a block to one image at a time.

  • DO construct

    Controls the repeated execution of a block of statements or constructs. The following statements are used in DO constructs:

    • DO CONCURRENT statement

      Specifies that there are no data dependencies between the iterations of a DO loop.

    • DO WHILE statement

      Executes the range of a DO construct while a specified condition remains true.

    • CYCLE statement

      Interrupts the current execution cycle of the innermost (or named) DO construct.

    • EXIT statement

      Terminates execution of a DO construct

  • END statement

    Marks the end of a program unit.

  • IF construct and IF statement

    The IF construct conditionally executes one block of statements or constructs. The IF statement conditionally executes one statement. The decision to transfer control or to execute the statement or block is based on the evaluation of a logical expression within the IF statement or construct.

  • PAUSE statement

    Temporarily suspends program execution until the user or system resumes execution.

    These statements are deleted features in the Fortran Standard. Intel® Fortran fully supports features deleted in the Fortran Standard.

  • RETURN statement

    Transfers control from a subprogram to the calling program unit.

  • SELECT RANK construct

    Selects for execution at most one of its constituent blocks based on the rank of an assumed-rank variable.

  • SELECT TYPE construct

    Selects for execution at most one of its constituent blocks based on the dynamic type of an expression specified.

  • STOP and ERROR STOP statement

    The STOP statement initiates normal termination of an image before the execution of an END statement of the main program. The ERROR STOP statement initiates error termination.