[UP]


Manual Reference Pages  - implicit (7)

NAME

IMPLICIT(7f) - [FORTRAN:STATEMENT] specify default type (if any) associated to a starting letter

CONTENTS

Synopsis
Description
Options
Example

SYNOPSIS

IMPLICIT [NONE]|[declaration-type-spec (letter-spec-list)]
determine default mapping between between the first letter of a data entity and a type.

DESCRIPTION

Every data entity has a type. If a type is not explicitly assigned to a variable or function it will (by default) be assigned one according to the following rule -- the type is INTEGER if the name starts with the letters from I to N (the first two letters of the word "integer"); otherwise it defaults to REAL.

The IMPLICIT statement allows the default rule to be changed or set to null. To turn off implicit typing enter one and only one IMPLICIT statement in the scoping unit

      implicit none ! Disable all implicit typing

Each data entity will now require explicitly having a type declared (INTEGER, REAL, DOUBLE, COMPLEX, ...).

This must appear after any USE statements and before any type declarations, including PARAMETER statements (which must know the rules to determine what type names are that have not been explicitly declared).

In most new code implicit typing is turned off either with an "IMPLICIT NONE" or sometimes by a compiler switch. On the other hand, the majority of pre-fortran90 code depends on implicit defaults.

Each prefix letter may have the type assigned to it declared only once in a unit.

The default rule, expressed as an IMPLICIT statement is

      implicit real(a-h,o-z),integer(i-k)

To make the default for all names be a DOUBLEPRECISION type one could enter

      implicit doubleprecision (a-h,o-z)

In another unit one might specify (multiple statements and compound statements are allowed, as illustrated):

      implicit complex (c), doubleprecision (d)
      implicit integer (i)
      implicit logical (l)
      implicit real (r)
      implicit character(len=8) (a,b,e-h,j,k,m-q,s-z)

There is no way to make some letters default to no type and others have a default. Either nothing has a default type or everything does:

      implicit (a-h)  ! NOT ALLOWED. A TYPE MUST BE SPECIFIED

The default for an internal or module procedure is the mapping in the host scoping unit.

Any data entity that is not explicitly declared by a type declaration statement, is not an intrinsic function, and is not accessed by use or host association is declared implicitly to be of the type (and type parameters) mapped from the first letter of its name, provided the mapping is not null.

The mapping may be to a derived type that is inaccessible in the local scope if the derived type is accessible in the host scoping unit. The data entity is treated as if it were declared in an explicit type declaration in the outermost scoping unit in which it appears. An explicit type specification in a FUNCTION statement overrides an IMPLICIT statement for the name of the result variable of that function subprogram.

OPTIONS

NONE If IMPLICIT NONE is specified in a scoping unit, it shall precede any PARAMETER statements that appear in the scoping unit and there shall be no other IMPLICIT statements in the scoping unit. or declaration-type-spec
letter-spec
  is (letter-or-range[,letter-or-range] [,letter-or-range] ) If the minus and second letter appear, the second letter shall follow the first letter alphabetically. A letter-spec consisting of two letter s separated by a minus is equivalent to writing a list containing all of the letters in alphabetical order in the alphabetic sequence from the first letter through the second letter. For example, A-C is equivalent to A, B, C. The same letter shall not appear as a single letter, or be included in a range of letters, more than once in all of the IMPLICIT statements in a scoping unit.

EXAMPLE

The following are examples of the use of IMPLICIT statements:

        module example_module
           implicit none
           ...
           interface
              function fun (i)    ! not all data entities need to
                 integer fun      ! be declared explicitly
              end function fun
           end interface
        contains
           function jfun (j)      ! all data entities need to
              integer jfun, j     ! be declared explicitly.
              ...
           end function jfun
        end module example_module

subroutine sub implicit complex (c) CM = (3.0, 2.0) ! CM is implicitly declared COMPLEX ... contains subroutine sub1 IMPLICIT INTEGER (A, C) C = (0.0, 0.0) ! C is host associated and of ! type complex Z = 1.0 ! Z is implicitly declared REAL A = 2 ! A is implicitly declared INTEGER CC = 1 ! CC is implicitly declared INTEGER ... end subroutine sub1 subroutine sub2 Z = 2.0 ! Z is implicitly declared REAL and ! is different from the variable of ! the same name in SUB1 ... end subroutine sub2 subroutine sub3 USE EXAMPLE_MODULE ! Accesses integer function FUN ! by use association Q = FUN (K) ! Q is implicitly declared REAL and ... ! K is implicitly declared INTEGER end subroutine sub3 end subroutine sub

The following is an example of a mapping to a derived type that is inaccessible in the local scope:

program main implicit type(blob) (a) type blob integer :: i end type blob type(blob) :: b call steve contains subroutine steve integer :: blob .. aa = b .. end subroutine steve end program main

In the subroutine STEVE, it is not possible to explicitly declare a variable to be of type BLOB because BLOB has been given a different meaning, but implicit mapping for the letter A still maps to type BLOB, so AA is of type BLOB.


implicit (7) March 18, 2019
Generated by manServer 1.08 from 91533d77-267a-4802-8728-e7ee4dabd3b3 using man macros.