sifunc.f
c<html>
c<body>
c<pre>
program sifunc
implicit none
real a,b,c,x,y,z,f1
data c / 5./
c
c This is a statement function. It is considered an executable
c statement, and commonly positioned at the beginning of executable
c statements. It may actually exist anywhere in the executable
c portion of the program unit before it is put to use.
c<a name="sf"><font color="FF0000">
f1(x,y)=a+b*x**2+c*y
c</font></a>
a = 1
b = 2
z = f1(2.,2.)
print *, 'f1(2.,2.) = ', z
z = f1( b,b)
print *, 'f1(b ,b ) = ', z
c
z = f2(2.,2.)
print *, 'f2(2.,2.) = ', z
z = f2( b,b)
print *, 'f2(b ,b ) = ', z
c
c The following CONTAINS statement marks the end of the main program unit
c and the beginning of a block of "INTERNAL" subprograms. Here I'm
c just including one function. Notice that it knows the values of
c a, b, and c set in the main program. (You can put internal subprograms
c at the end of normal external subroutines, functions, and modules)
c<a name="1"><font color="FF0000">
contains
c</a></font>
c
function f2(x,y)
real x,y,f2
f2 = a + b*x**2 + c*y
return
end function f2
c
c Don't forget the end statement for the main program
c
end
c</pre>
c</body>
c</html>