Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

Not using Call?

reneeculver
Beginner
800 Views
Is there a way in Fortran to not use Call?

Renee
0 Kudos
6 Replies
IanH
Honored Contributor III
800 Views
Yes - never use subroutines. Personally I'd find that rather limiting.

Why do you ask?
0 Kudos
GVautier
New Contributor III
800 Views
Hello

Subroutine (and call) in Fortran is equivalent to (void) function in C.

So if you don't want to use call, change your subroutines to integer functions returning 0.
SO

CALL my_subroutine(...)

will become

idum=my_function(...)

What is the benefit?
0 Kudos
mecej4
Honored Contributor III
800 Views
Yes.

Use only FUNCTION invocations or, if that is too similar to a SUBROUTINE call to meet your criteria, use GOTO (or, equivalently, if your compiler allows it, COMEFROM) and possibly, SENSE LIGHTs.

It will be stimulating to debug large programs written this way.

That's how things were in FORTRAN I.
0 Kudos
reneeculver
Beginner
800 Views
Well, I remember everything but the Calls....yuck.

Renee
0 Kudos
jeremy_h
New Contributor I
800 Views
Hi renee,

when we migrated from CVF, we had to fix probably a thousand CALLs. IVF seems very picky - a subroutine declared with a local prototype that returns a value must indeed return a value, and a subroutine with no function prototype must use CALL. It would have been nice to be able to turn this off, but it was not a big deal firstly because it is a compilation (not runtime) error, and secondly because we could fix these in the CVF baseline prior to the port.

- jeremy
0 Kudos
Steven_L_Intel1
Employee
800 Views
Yes, CVF would sometimes let you get away with CALLing a function, when it thought there was no harm. It turned out that the cases where you could get away with this were fewer than we thought and in the end we decided to just ban the whole thing (which is not legal Fortran in the first place). There were problems with corrupting floating point stacks and worse.
0 Kudos
Reply