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
Principiante
2.330 Visualizações
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 Solução
Steven_L_Intel1
Funcionário
2.330 Visualizações
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.

Ver solução na publicação original

4 Respostas
Steven_L_Intel1
Funcionário
2.331 Visualizações
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.
Pipa
Principiante
2.330 Visualizações
Thanks a lot!!
jimdempseyatthecove
Colaborador honorário III
2.330 Visualizações
Steve,

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

Jim

Steven_L_Intel1
Funcionário
2.330 Visualizações
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.
Responder