Skip to content

forall-statement (OB071)

This rule is unstable and in preview. The --preview flag is required for use.

This rule is turned on by default.

What it does

Checks for forall statements.

Why is this bad?

The F2018 standard made forall statements obsolescent in favour of do concurrent. They were orginally added with the intention of parallelising loops across multiple processors, however, they turned out to have too many restrictions for compilers to be able to take full advantage of them.

Instead, the do concurrent statement was introduced, which solved many of these difficulties (although not without its own issues, see [1]), along with the use of pointer rank remapping.

Example

forall (i=1:N)
  b(i) = a(i) * c(i)
end forall

Use instead:

do concurrent (i=1:N)
  b(i) = a(i) * c(i)
end do concurrent

References