Silverfrost Forums

Welcome to our forums

Understanding a FORTRAN code snippet

24 Apr 2013 4:42 #12097

Hi,

I need some help in understanding this bit of FORTRAN code which is written by soemone else.

we have:

data abc /1.0d0,0.5d0,0.5d0,0.375d0,0.375d0,0.313d0,0.313d0,0.273d0,0.273d0,1.0d0,0.6366197d0,0.5d0,0.4244131d0,0.375d0,0.3395305d0,0.3125d0,0.2910261d0,0.2734375d0/
data pol1 /1.00095d0,-.045316d0,.614739d0,-.968351d0,.700536d0/
data pol2 /1.00084d0,-.040091d0,.689775d0,-1.20273d0,1.42963d0
data pol3 /1.12d0,-0.23d0,10.6d0,-21.7d0,30.4d0/

Well, the above bit I undestand-no problem.

Next,

I calculate a varioable called 'efg' and 'hij' and 'a' then


efg=efg*poly(5,pol3,hij)*dsqrt(3.1415926d0*a)

I do not follow what 'poly' indicates above??

My code compiles and runs as expected, but I need to know what is 'poly'?

Can anyone please help?

Christy

24 Apr 2013 5:50 #12098

poly is the name of a function that your program is calling.

It might be defined somewhere else in your program or it might be defined in a library that your program is linked to.

To my knowledge it is not the name of a standard Fortran 95 function.

24 Apr 2013 8:41 #12099

Christy,

Search through your code for 'FUNCTION' to see if you have a function called POLY. It is best if your editor is case-insensitive, because it may be 'function' or 'Function' etc..

If you can't find it, then there are two other possibilities.

(1) the function is in an external library, or (2) it is defined in a STATEMENT FUNCTION.

Statement functions appear before any executable code in a subroutine, and have a scope local to that routine. So, if POLY is a statement function, it should appear AFTER the DATA statements but BEFORE an executable statement that uses it. If it is a statement function, it will take the form of a statement where

POLY( .... ) =

appears on the lefthand side of the assignment. The strength of the statement function is that it is compact - the weakness is that lots of people will miss it when reading the code.

Modern Fortran versions have a replacement system for statement functions.

Eddie

26 Apr 2013 8:18 #12108

Hi LitusSaxonicum and Paul,

Thank you very much.

Yes-it was a function. Thanks again

Christy

Please login to reply.