Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28522 Discussions

Error: The CALL statement is invoking a function subprogram as a subroutine.

Alex_S_5
Beginner
1,407 Views

Why isthatthe Compaq Visual Fortran compiles this code:

integer function ifun()

ifun=111

end

program test

call ifun()

!i=ifun()

end

OK. Whilethe Intel Visual Fortran 10.0 displays the error:

Error: The CALL statement is invoking a function subprogram as a subroutine.

If I uncomment

i=ifun()

and comment call ifun() IVF, understandably,compiles it OK.

I was under the impression that Fortran allows functions to be call as subroutines

(the pgplot library that we usestopped compiling because of this).

An input from more experienced colleagues is much appreciated.

0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,408 Views
No, the Fortran language does NOT allow this. CVF allowed it under some cirucmstances, but we realized that some of the cases where this was allowed could still cause problems such as floating stack corruption. The number of cases where it was safe was outweighed by the number where it wasn't, and we decided to bite the bullet and disable this "feature" for the Intel compilers.
0 Kudos
Alex_S_5
Beginner
1,408 Views

Thanks Steve for straightening it out.

Intel guysmay want to edit the following web page:

http://www.intel.com/support/performancetools/libraries/mkl/sb/cs-017175.htm

where it is explicitly stated that Fortran DOES allow to "call functions

as though the were subroutines...":

Because Fortran lets you call functions as though they were subroutines, however, there is a mechanism for returning the complex value correctly when the function is called from a C program. When a Fortran function is called as a subroutine, the return value shows up as the first parameter in the calling sequence - a feature that can be exploited by the C programmer.

This and the fact that all the other Fortran compilers I tried in the past allowed that

got me confused.

Alex



0 Kudos
Steven_L_Intel1
Employee
1,408 Views
Thanks - I'll ask that that page be corrected.
0 Kudos
mecej4
Honored Contributor III
1,408 Views
Steve, they seem to need a reminder!
0 Kudos
Steven_L_Intel1
Employee
1,408 Views
Ok, will see what I can do.
0 Kudos
Steven_L_Intel1
Employee
1,408 Views
Nowadays I can fix this myself - and I have done so.
0 Kudos
Reply