MODULE

Purpose

The MODULE statement is the first statement of a module program unit, which contains specifications and definitions that can be made accessible to other program units.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-MODULE--module_name-----------------------------------------><

Rules

The module name is a global entity that is referenced by the USE statement in other program units to access the public entities of the module. A user-defined module must not have the same name as any other program unit, external procedure, common block, binding labels of global entities in the program, nor can it be the same as any local name in the module.

If the END statement that completes the module specifies a module name, the name must be the same as that specified in the MODULE statement.

Examples

MODULE MM
   CONTAINS
     REAL FUNCTION SUM(CARG)
       COMPLEX CARG
       SUM_FNC(CARG) = IMAG(CARG) + REAL(CARG)
       SUM = SUM_FNC(CARG)
       RETURN
     ENTRY AVERAGE(CARG)
       AVERAGE = SUM_FNC(CARG) / 2.0
     END FUNCTION SUM
     SUBROUTINE SHOW_SUM(SARG)
       COMPLEX SARG
       REAL SUM_TMP
  10   FORMAT('SUM:',E10.3,' REAL:',E10.3,' IMAG',E10.3)
       SUM_TMP = SUM(CARG=SARG)
       WRITE(10,10) SUM_TMP, SARG
     END SUBROUTINE SHOW_SUM
END MODULE MM

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us