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 3 Data types and data objects

Implicit and explicit typing

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

If an entity is declared or used without being explicitly typed, then the entity's type will be determined from the initial symbol of its name, known as implicit typing. The default implicit typing rules are as follows:

  • Names with initial letter A to H or O to Z: REAL

  • Names with initial letter I to N: INTEGER

Thus:

DIMENSION a(5), i(10)
   k=1
   b=k

implicitly declares a and b as default reals and i and k as default integers.

It is recommended that you do not utilize implicit typing, but explicitly type all entities using declaration statements. Implicit typing can be disabled with the IMPLICIT NONE statement, as described below, ensuring that any appearance of an entity which has not appeared in an explicit type declaration statement will be the subject of an error message and render the program invalid.

IMPLICIT statement

The IMPLICIT statement provides a means of changing or canceling the default implicit typing. This takes effect for the scoping unit in which it appears, except where overridden by explicit type statements.

The statement is one of:

  • IMPLICIT NONE

  • IMPLICIT implicit-spec-list

implicit-spec-list

is

type-spec (letter-spec-list)
letter-spec

is one of:

  • letter

  • letter - letter

IMPLICIT NONE overrides the predefined implicit type specification. If this statement is included in a scoping unit then all the names in that unit must have their types explicitly declared. It must appear before any PARAMETER statements. A scoping unit that includes an IMPLICIT NONE statement may not include any other IMPLICIT statements. A compile-line option, the +implicit_none option, can be specified that has the effect of including an IMPLICIT NONE statement in every program unit (see Chapter 13).

Following are examples of the IMPLICIT and IMPLICIT NONE statements with comments:

IMPLICIT NONE     
! Enforce explicit typing
IMPLICIT REAL(a-h,o-z),INTEGER(i-n)
! This is equivalent to the default typing:
!  a through h and o through z implies REAL
!  i through n implies INTEGER
IMPLICIT REAL(KIND=8)(d),COMPLEX(8)(z)
!  d implies REAL(8) z implies COMPLEX(8);
!  other letters retain any assigned types
IMPLICIT TYPE(node)(l,n)
! Derived types can be included

A scoping unit may contain more than one "active" IMPLICIT statement, but any letter must be included in only one letter-spec. IMPLICIT statements must precede all other specification statements except PARAMETER statements. The IMPLICIT statement has no effect on the default types of intrinsic functions.

The implicit rules of a host scoping unit will apply to a contained scoping unit, but can be completely or partially overridden by implicit statements within the contained scoping unit.

The +implicit_none compiler option forces the types of identifiers to be implicitly undefined. See Chapter 13 for further information.

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