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

Understanding Fortran code

Pipa
Beginner
1,124 Views
Hi,
I have a Fortran 90 code which looks like the following:
=============================
Real :: e
Real :: a,b,c,d
Real :: a1,b1,c1,d1,p,q
a(a1,b1,c1,q) = a1+b1*c1-d1/8.
Integer :: i1
! Main computation starts
e = a(2.,5.,6.,9.)
==============================
Would you guys please explain what does the "a(a1,b1,c1,q) = a1+b1*c1-d1/8." line segment means? Is it similar to a function call? What do we call this capability in fortran or programming languages in general?
Thanks!
0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,124 Views
That is an obsolescent language feature called "statement function". It is a one-line declaration of a function named "a" that takes four arguments and returns as a result the expression on the right side of the equal sign. The datatype of "a" and its arguments are taken from the earlier declarations. The scope of the declaration of "a" is that routine only.

The last line calls "a" and passes it four arguments - the result is stored in "e".

Statement functions are still technically part of the Fortran language, but are termed "obsolescent" and will be flagged as such by compilers when standards checking is enabled. The recommend replacement is internal functions.

View solution in original post

0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,125 Views
That is an obsolescent language feature called "statement function". It is a one-line declaration of a function named "a" that takes four arguments and returns as a result the expression on the right side of the equal sign. The datatype of "a" and its arguments are taken from the earlier declarations. The scope of the declaration of "a" is that routine only.

The last line calls "a" and passes it four arguments - the result is stored in "e".

Statement functions are still technically part of the Fortran language, but are termed "obsolescent" and will be flagged as such by compilers when standards checking is enabled. The recommend replacement is internal functions.
0 Kudos
Pipa
Beginner
1,124 Views
Thanks a lot!!
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,124 Views
Steve,

Wouldn't this "obsolescent" "statement function" come back in Vogue as Lambda functions?
Lambda function in the sense of C++0x.

Jim

0 Kudos
Steven_L_Intel1
Employee
1,124 Views
Not really, because lambda functions are unnamed and are basically declared where they're used. But I suppose it's the closest that C++ has to the idea. Statement functions have awkward limitations and puzzling scope - internal procedures are much better, which is why statement functions were selected for deprecation.
0 Kudos
Reply