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

ID 767251
Date 9/08/2022
Public

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

Document Table of Contents

GAP Message (Diagnostic ID 30521)

NOTE:
This feature is only available for ifort.

Message

Assign a value to the variable(s) "%s" at the beginning of the body of the loop in line %d. This will allow the loop to be parallelized.

Advice

Check to see if you can unconditionally initialize the scalar variables at the beginning of the specified loop. If so, do the code change for such initialization (standard), or list the variables in the private clause of a parallel directive (advanced). This allows the parallelizer to privatize those variables for each iteration and to parallelize the loop.

Example

Consider the following:

     subroutine foo (A, B, cond1, cond2)
       integer, parameter :: N = 100000
       integer I
       real(8) A(N), B(N), T
       logical cond1, cond2
  
       do I = 1, N
          if (cond1) T = i + 1
          if (cond2) T = i - 1
          A(I) = T
       end do
     end

In this case, the compiler does not parallelize the loop because it cannot privatize the variable t without further information. If you know that cond1 or cond2 is true, or both cond1 and cond2 are true, then you can assist the parallelizer by ensuring that any iteration that uses t also writes to t before its use in the same iteration. One of the ways to do this is to assign a value to t at the top of each iteration.

If you determine it is safe to do so, you can modify the program code as follows:

     subroutine foo (A, B, cond1, cond2)
       integer, parameter :: N = 100000
       integer I
       real(8) A(N), B(N), T
       logical cond1, cond2
 
       do I = 1, N
          T = 0
          if (cond1) T = i + 1
          if (cond2) T = i - 1
          A(I) = T
       end do
     end

Verify

Confirm that in the original program, any variables fetched in any iteration of the loop have been defined earlier in the same iteration.