Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP Fortran statements

CALL

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Invokes a subroutine.

Syntax

CALL subr-name[([ subr-act-arg-spec-list ])]
subr-name

is the name of the subroutine being invoked.

actual-argument-list

is a comma-separated list of entities of the form:

[keyword =]actual-argument

actual-argument

is one of the following:

  • expression

  • variable

  • procedure-name

  • *label or &label

keyword

is one of the dummy argument names of the subroutine being invoked. If any keyword is specified, the subroutine interface must be explicit.

Description

A CALL statement is used to invoke (call) a subroutine, and to specify actual arguments, if any. Execution of the subroutine begins with the first executable statement. The following sequence of events occurs when a CALL statement executes:

  1. Actual arguments that are expressions are evaluated.

  2. The actual arguments are associated with the corresponding dummy arguments.

  3. Control transfers to the subroutine being called, and the subroutine executes.

  4. Control returns from the subroutine, normally to the statement following the CALL statement, or to a statement label indicated by an alternate return argument—*label or &label. (The & label form is provided as a compatibility extension and can be used in fixed source form only.)

A subroutine can call itself, directly or indirectly; in this case the keyword RECURSIVE must be specified in the SUBROUTINE statement of the subroutine definition.

The %VAL and %REF built-in functions are provided as HP extensions. They can be used to change argument-passing conventions calling a routine written in another language.

The only subroutine invocation other than by the CALL statement in Fortran 90 is through “defined assignment”, where a defined type assignment operator that has been defined by means of a subroutine is used.

Examples

! Interface for subroutine draw
INTERFACE
SUBROUTINE draw (x_start, y_start, x_end, y_end, form, scale)
REAL x_start, y_start, x_end, y_end
CHARACTER (LEN = 6), OPTIONAL :: form
REAL, OPTIONAL :: scale
END SUBROUTINE draw
END INTERFACE

! References to draw
! arguments given by position; optional argument scale omitted
CALL draw (5., -4., 2., .6, ”DASHED”)
! arguments given by keyword; optional argument form omitted
CALL draw (scale=.4, x_end=0., y_end=0., x_start=.5, y_start=.3)

Related statements

INTERFACE and SUBROUTINE

Related concepts

For related information, see the following:

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.