Page 136 - Standard Handbook Of Petroleum & Natural Gas Engineering
P. 136
Computer Applications 121
DO 100 I = 1,10,2
PR(1) = PPE(1 - 1)
100 CONTINUE
DO 100 I = lO,l, - 1
DO 100 J = 1,lO
100 ATR(1,J) = PU,I)*FRIC
DO 100 I = - 5,25,5
PF(1) = TFP(1) - FFG
IF(PF(I).GE.LMT) GOT0 110
100 CONTINUE
110 MAXC = I
Statement functions are defined before any other executable statements in
the program and are called in the same way that subprogram or intrinsic
functions are called (see subprogram statements later). They are one-line
expressions that receive one or more parameters from the calling statement and
return a single calculated value to the function name in the calling statement.
For example, a statement function defined as
FDPT(X(I),Y(I),Z,I) = X(I)*Y(I) + Z**I
will calculate a value depending on the values of X(I),Y(I),Z, and I at the time
of calling and return the calculated value to the calling statement through FDPT.
Subprogram statements are those used to transfer control between program
units-the main program, functions, and subroutines. A function call is performed
by invoking the name of the function module in an assignment statement, such as
X = FDPR(Z,Y(I))*PRF
which will transfer control to the function FDPR and pass the values Z, and
Y(1) to that unit. An intrinsic function or a statement function may be called
in the same way. (See Table 1-27 for a list of FORTRAN 77 intrinsic functions.)
A subroutine call is performed by a statement such as
CALL CALCSUB(MATFOR,I,J,PVAL)
which will transfer control to the subroutine CALCSUB and pass (and/or return)
the values MATFOR,I,J, and PVAL. A subroutine may have an ENTRY name
(parameter list) statement imbedded within it, which when called in the same
manner as the main subroutine call, will receive control transfer at that point.
Control passes from the called unit back to the calling unit when a RETURN
statement is encountered. Given a subroutine
Subroutine CALCSUB(MAT,M,N,Pl)
REAL MAT( 100)
P1 = MAT(M) + MAT(N)
RETURN
ENTRY NEWCALC(MAT,M,N,P2)
P2 = MAT(M) + MAT(N)
RETURN
END

