VMS Help  —  FORTRAN  Statements  MODULE
  A program unit containing specifications and definitions that can
  be made accessible to other program units.  Format:

     MODULE nam
        [specs]
     [CONTAINS
        mod-sub
        [mod-sub]...]
     END [MODULE [nam]]

     nam      Is the name of the module.

     specs    Is one or more specification statements,
              except for the following:

              ENTRY
              FORMAT
              AUTOMATIC (or its equivalent attribute)
              INTENT (or its equivalent attribute)
              OPTIONAL (or its equivalent attribute)
              Statement functions

              An automatic object must not appear in a
              specification statement.

     mod-sub  Is a function or subroutine subprogram that
              defines the the module procedure.  A function
              must end with END FUNCTION and a subroutine
              must end with END SUBROUTINE.

              A module subprogram can contain internal
              procedures.

  If a module name appears following the END statement, it must be
  the same name as the name specified in the MODULE statement.

  The module name cannot be the same as any local name in the main
  program or the name of any other program unit, external procedure,
  or common block in the executable program.

  A module is host to any module procedures it contains, and entities
  in the module are accessible to the module procedures through host
  association.

  A module must not reference itself (either directly or indirectly).

  Although ENTRY statements, FORMAT statements, and statement
  functions are not allowed in the specification part of a module,
  they are allowed in the specification part of a module subprogram.

  Any executable statements in a module can only be specified in a
  module subprogram.

  A module can contain one or more procedure interface blocks, which
  let you specify an explicit interface for an external subprogram or
  dummy subprogram.

  Every internal subprogram must be of the same extrinsic kind as its
  host, and any internal subprogram whose extrinsic kind is not given
  is assumed to be of that extrinsic kind.

  EXAMPLES:

  The following example shows a simple module that can be used to
  provide global data:

    MODULE MOD_A
      INTEGER :: B, C
      REAL E(25,5)
    END MODULE MOD_A
    ...
    SUBROUTINE SUB_Z
      USE MOD_A               ! Makes scalar variables B and C,
                              ! and array E available to this
                              ! subroutine
    END SUBROUTINE SUB_Z

  The following example shows a module procedure:

    MODULE RESULTS
    ...
    CONTAINS
      FUNCTION MOD_RESULTS(X,Y)  ! A module procedure
      ...
      END FUNCTION MOD_RESULTS
    END MODULE RESULTS

  The following example shows a module containing a derived type:

    MODULE EMPLOYEE_DATA
      TYPE EMPLOYEE
        INTEGER ID
        CHARACTER(LEN=40) NAME
      END TYPE EMPLOYEE
    END MODULE

  The following example shows a module containing an interface block:

    MODULE ARRAY_CALCULATOR
      INTERFACE
        FUNCTION CALC_AVERAGE(D)
          REAL :: CALC_AVERAGE
          REAL, INTENT(IN) :: D(:)
        END FUNCTION
      END INTERFACE
    END MODULE ARRAY_CALCULATOR
Close Help