Intel fortran-80 Laptop User Manual


 
FORTRAN-SO Functions
And
Subroutines
When a
RETURN
is
executed in a
FUNCTION
subprogram,
the value
of
the func-
tion must be available to the referencing
program
unit.
Whenever
RETURN
is
executed, the association between the
dummy
arguments
of
an
external procedure
and
the current actual arguments
is
terminated (but see sec-
tion 5.2.5, the SA VE statement).
Example:
C TH
REE
N
UM
BERS ARE ADDED AN D TH E FLAG
'POSTor
SET TO
C TO 11F THEIR
TOTAL
IS
POSITIVE
SUBROUTINE POSTOT(A,B,C)
IF
((A
+ B +
C)
.GE.
0)
THEN
POSTOT = 1
ELSE
POSTOT
= 0
ENDIF
RETURN
END
5.2.5 SAVE Statement
The SAVE statement can be used to
make
sure
that
common
variables within a
FUNCTION
or
SUBROUTINE
subprogram
do not become undefined when a
RETURN
or
END
is
executed.
The
format
of
the SAVE statement
is
SAVE
lebl
[,Iebl] ...
where
'cb'
is
a named
common
block. Naming the
common
block saves all items in
that
block. A specific
common
bloj:k
cannot
be listed
more
than
once in a single
SA VE statement. Entities in blank
common
never become undefined as the result
of
executing
RETURN
or
END.
Example:
SAVE IBLOCK1/,/BLOCK21
5.2.6 EXTERNAL Statement
The
EXTERNAL
statement confirms
that
a symbolic
name
represents
an
external
or
dummy
procedure
and
allows
that
name
to
be used as
an
actual
argument.
The
format
of
the
EXTERNAL
statement
is
EXTERNAL
proe
[,proe]
...
where
'proc'
is
the
name
of
an
external
or
dummy
procedure.
If
an intrinsic function
name
is
specified in
an
EXTERNAL
statement,
that
name
can no longer be used
to
specify
an
intrinsic function in the
program
unit, but in-
stead becomes the
name
of
an
external procedure.
A symbolic name can be specified only once in all the
EXTERNAL
statements in a
program
unit.
Example:
EXTERNAL HYP,
POSTOT, SIN
5-7