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

Not using Call?

reneeculver
初学者
1,478 次查看
Is there a way in Fortran to not use Call?

Renee
0 项奖励
6 回复数
IanH
名誉分销商 III
1,478 次查看
Yes - never use subroutines. Personally I'd find that rather limiting.

Why do you ask?
0 项奖励
GVautier
新分销商 III
1,478 次查看
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 项奖励
mecej4
名誉分销商 III
1,478 次查看
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 项奖励
reneeculver
初学者
1,478 次查看
Well, I remember everything but the Calls....yuck.

Renee
0 项奖励
jeremy_h
新分销商 I
1,478 次查看
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 项奖励
Steven_L_Intel1
1,478 次查看
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 项奖励
回复