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 90 Programmer's Reference: HP Series 700/800 Computers > Chapter 10 HP Fortran 90 statements

CALL

» 

Technical documentation

» 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.

subr-act-arg-spec-list

is a comma-separated list of subr-act-arg-spec.

subr-act-arg-spec

is [keyword =]subr-act-arg.

subr-act-arg

is one of the following:

  • expression

  • variable

  • procedure-name

  • *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 sequence of events when a CALL statement is executed is as follows:

  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 specifier argument (of the form * label).

The correspondence between actual and dummy arguments is primarily by position: the first actual argument corresponds to the first dummy argument, the second to the second, and so on. The positional correspondence may be overridden by argument keywords, where a keyword name attached to an actual argument specifies a correspondence to the dummy argument of the same name. The following conditions govern the use of argument keywords:

  • If an argument keyword is used, all subsequent arguments in the CALL statement must also be accompanied by keywords.

  • If an optional argument is omitted, the keyword form is required for any following arguments.

  • If an argument keyword is used, the procedure interface must be explicit; that is, the procedure must be an intrinsic procedure, an internal procedure, a module procedure, or an external procedure with an interface block accessible to the program unit making the call.

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

The %VAL and %REF built-in functions are provided as HP extensions. These allow cross-calling between languages by enabling arguments to be passed by value and by reference, respectively. %VAL causes its argument to be passed by value, as if to a C function; it is sign-extended to a 32-bit value if it is less than 32 bits. %REF causes its argument to be passed by reference, similar to the default Fortran 90 behavior, except that the hidden length parameter of a CHARACTER string is not passed.

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. See the INTERFACE statement in this chapter for more information.

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
CALL draw (5., -4., 2., .6, "DASHED")
! Arguments given by position.
! Optional argument scale omitted.
 
CALL draw (scale=.4, x_end=0., y_end=0., &
           x_start=.5, y_start=3.)
! Arguments given by keyword.
! Optional argument form omitted.

Related statements

INTERFACE and SUBROUTINE

Related concepts

The correspondence between the dummy arguments of a subroutine and the actual arguments specified in its invocation ("Argument association") is discussed in detail in Chapter 7, as are the other methods of association between a program unit and a subroutine called by it.

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