Diagnostic 7836: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element.

Error #7836: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element.

Normally, when calling a procedure, the Fortran language requires that each actual argument match its corresponding dummy argument in "rank", or number of dimensions.  This means that, in most cases, you cannot pass a scalar to an argument that is an array.

The language carves out some exceptions to this.  One that is most familiar to Fortran programmers is passing a single array element to a dummy argument that is an array.  For example:

real a(10)
...
call sub (a(4))
...
subroutine sub (x)
real x(*)
...
In this case, a Fortran language feature called "sequence association" applies.  Even though a(4) is a scalar, what happens is that x(1) is associated with a(4), x(2) with a(5), and so on through x(7) being associated with a(10).  x(8) and higher are not associated.  Sequence association requires that the array elements be in normal storage sequence order, as they are here.

However, if array a in this example is a POINTER array, then there is no guarantee that the elements are contiguous and the standard does not allow sequence association.  Error #8284 can also be issued if this rule is violated.

An exception to the rule is made for character scalar arguments passed to an array of single characters.  This allows passing character strings to an interoperable (C) routine.

Some solutions to the error include:
  • Making the array ALLOCATABLE instead of POINTER
  • Declaring the dummy argument as assumed shape.  This requires that an explicit interface be visible to the caller.
  • Passing an array section instead of a single element
Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.