A subroutine that modifies a dummy argument causes a constant actual argument to be changed.
Arguments are passed by reference in FORTRAN, so an assignment to a dummy argument will modify the actual argument. Sometimes, this is intentional, but other times it is not. In particular, it is possible to modify objects that should be constant, which can have unpredictable results. This diagnostic flags this case.
This same kind of error can also happen when a FORTRAN dummy argument of type subroutine is invoked. That is, the subroutine that is invoked through a dummy argument may exhibit the same problem as can occur in a direct call. In this case, the problem may or may not happen depending on what subroutine was passed to the dummy argument of subroutine type. There will be an additional observation in such cases that identifies the call site where the subroutine argument was passed in.
ID |
Observation |
Description |
---|---|---|
1 |
Call site |
The call that caused a constant argument to be corrupted |
2 |
Memory write |
The statement that indirectly modified the formal parameter |
subroutine badsub(i) integer :: i i = i+1 print *,i end subroutine goodsub(i) integer :: i print *,i+1 end subroutine subsub(sub) external sub call sub(2) ! argument #1 is modified when actual for "sub" is badsub. See... print *,2 end external goodsub,badsub integer, parameter :: p = 2 call goodsub(3) call badsub(3) ! argument #1 is modified in "badsub". See... print *,3 call subsub(goodsub) call subsub(badsub) end
Copyright © 2010, Intel Corporation. All rights reserved.