Subroutine called as function

A subroutine that does not return a value is used as if it did.

This usually indicates a mismatch between the declaration and definition of the subroutine in question.

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 might 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 place the subroutine was called

Example


subroutine IAmASubroutine(i)
integer :: i
i = 5
end

real function IAmAFunction(i)
integer :: i
read *,i
IAmAFunction = 3.14 + i
end

subroutine ICallMyArg(sub)
external :: sub
integer :: j
print *,sub(j)
! actual subroutine "IAmASubroutine" is called as function
print *,j
end

external :: ICallMyArg,IAmASubroutine,IAmAFunction
integer :: k
call ICallMyArg(IAmASubroutine)
call ICallMyArg(IAmAFunction)
! IAmASubroutine is called as a function
print *,IAmASubroutine(k)
end        
        

Copyright © 2010, Intel Corporation. All rights reserved.