[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index


Chapter 14
Compiler Directives

HP Fortran provides compiler directives to perform general-purpose tasks during compilation. You do not need to specify a compiler option to enable general directives.

Compiler directives are preceded by a special prefix that identifies them to the compiler.

This chapter describes:

  • Syntax rules for general directives ( Section 14.1)
  • ALIAS ( Section 14.2)
    Specifies an alternate external name to be used when referring to external subprograms.
  • ATTRIBUTES ( Section 14.3)
    Specifies properties for data objects and procedures.
  • DECLARE and NODECLARE ( Section 14.4)
    Generates or disables warnings for variables that have been used but not declared.
  • DEFINE and UNDEFINE ( Section 14.5)
    Specifies a symbolic variable whose existence (or value) can be tested during conditional compilation.
  • FIXEDFORMLINESIZE ( Section 14.6)
    Sets the line length for fixed-form source code.
  • FREEFORM and NOFREEFORM ( Section 14.7)
    Specifies free-format or fixed-format source code.
  • IDENT ( Section 14.8)
    Specifies an identifier for an object module.
  • IF and IF DEFINED ( Section 14.9)
    Specifies a conditional compilation construct.
  • INTEGER ( Section 14.10)
    Specifies the default integer kind.
  • IVDEP ( Section 14.11)
    Assists the compiler's dependence analysis.
  • MESSAGE ( Section 14.12)
    Specifies a character string to be sent to the standard output device during the first compiler pass.
  • OBJCOMMENT ( Section 14.13)
    Specifies a library search path in an object file.
  • OPTIONS ( Section 14.14)
    Affects data alignment and warnings about data alignment.
  • PACK ( Section 14.15)
    Specifies the memory starting addresses of derived-type items.
  • PSECT ( Section 14.16)
    Modifies certain characteristics of a common block.
  • REAL ( Section 14.17)
    Specifies the default real kind.
  • STRICT and NOSTRICT ( Section 14.18)
    Disables or enables language features not found in the language standard specified on the command line (Fortran 95 or Fortran 90).
  • TITLE and SUBTITLE ( Section 14.19)
    Specifies a title or subtitle for a listing header.
  • UNROLL ( Section 14.20)
    Tells the compiler's optimizer how many times to unroll a DO loop.

14.1 Syntax Rules for General Directives

The following general syntax rules apply to all general compiler directives. You must follow these rules precisely to compile your program properly and obtain meaningful results.

A general directive prefix (tag) takes the following form:


  • cDEC$

c

Is one of the following: C (or c), !, or *.

The following are source form rules for directive prefixes:

  • Prefixes beginning with C (or c) and * are only allowed in fixed and tab source forms.
    In these source forms, the prefix must appear in columns 1 through 5; column 6 must be a blank or tab. From column 7 on, blanks are insignificant, so the directive can be positioned anywhere on the line after column 6.
  • Prefixes beginning with ! are allowed in all source forms.
    The prefix can appear in any valid column, but it cannot be preceded by any nonblank characters on the same line. It can only be preceded by whitespace.

A general directive ends in column 72 (or column 132, if a compiler option is specified).

General directives cannot be continued.

A comment can follow a directive on the same line.

Additional Fortran statements (or directives) cannot appear on the same line as the general directive.

General directives cannot appear within a continued Fortran statement.

If a blank common is used in a general compiler directive, it must be specified as two slashes (/ /).

14.2 ALIAS Directive

The ALIAS directive lets you specify an alternate external name to be used when referring to external subprograms. This can be useful when compiling applications written for other platforms that have different naming conventions.

The ALIAS directive takes the following form:


  • cDEC$ ALIAS internal-name, external-name

c

Is one of the following: C (or c), !, or * (see Section 14.1).

internal-name

Is the name of the subprogram as used in the current program unit.

external-name

Is a name, or a character constant delimited by apostrophes or quotation marks.

If a name is specified, the name (in uppercase) is used as the external name for the specified internal-name. If a character constant is specified, it is used as is; the string is not changed to uppercase, nor are blanks removed.

The ALIAS directive affects only the external name used for references to the specified internal-name.

Names that are not acceptable to the linker will cause link-time errors.

For More Information:

  • On syntax rules for all general directives, see Section 14.1.
  • On the linker, see the HP OpenVMS Linker Utility Manual.

14.3 ATTRIBUTES Directive

The ATTRIBUTES directive lets you specify properties for data objects and procedures. It takes the following form: 1


  • cDEC$ ATTRIBUTES att [,att]... :: object [,object]...

c

Is one of the following: C (or c), !, or * (see Section 14.1).

att

Is one of the following:
ADDRESS64 DESCRIPTOR32 REFERENCE
ALIAS DESCRIPTOR64 REFERENCE32
ALLOW_NULL   REFERENCE64
    STDCALL
C EXTERN VALUE
DECORATE IGNORE_LOC VARYING
DEFAULT NO_ARG_CHECK  
DESCRIPTOR NOMIXED_STR_LEN_ARG  

object

Is the name of a data object or procedure.

The following table shows which properties can be used with various objects:

Property Variable and
Array Declarations
Common Block Names1 Subprogram Specification and EXTERNAL Statements
ADDRESS64 Yes Yes No
ALIAS No Yes Yes
ALLOW_NULL Yes No No
C No Yes Yes
DECORATE No No Yes
DEFAULT No Yes Yes
DESCRIPTOR Yes 2 No No
DESCRIPTOR32 Yes 2 No No
DESCRIPTOR64 Yes 2 No No
EXTERN Yes No No
IGNORE_LOC Yes No No
NO_ARG_CHECK Yes No Yes 3
NOMIXED_STR_LEN_ARG No No Yes
REFERENCE Yes No Yes
REFERENCE32 Yes No No
REFERENCE64 Yes No No
STDCALL No Yes Yes
VALUE Yes No No
VARYING No No Yes

1A common block name is specified as [/]common-block-name[/].
2This property can only be applied to INTERFACE blocks.
3This property cannot be applied to EXTERNAL statements.

These properties can be used in function and subroutine definitions, in type declarations, and with the INTERFACE and ENTRY statements.

Properties applied to entities available through use or host association are in effect during the association. For example, consider the following:


MODULE MOD1
  INTERFACE
    SUBROUTINE SUB1
    !DEC$ ATTRIBUTES C, ALIAS:'othername' :: NEW_SUB
    END SUBROUTINE
  END INTERFACE
  CONTAINS
    SUBROUTINE SUB2
    CALL NEW_SUB
    END SUBROUTINE
END MODULE

In this case, the call to NEW_SUB within SUB2 uses the C and ALIAS properties specified in the interface block.

The properties are described as follows:

  • ADDRESS64
    Specifies that the object has a 64-bit address. This property can be specified for any variable or dummy argument, including ALLOCATABLE and deferred-shape arrays. However, variables with this property cannot be data-initialized.
    It can also be specified for COMMON blocks or for variables in a COMMON block. If specified for a COMMON block variable, the COMMON block implicitly has the ADDRESS64 property.
    ADDRESS64 is not compatible with the AUTOMATIC attribute.
  • ALIAS
    Specifies an alternate external name to be used when referring to external subprograms. Its form is:

    • ALIAS:external-name

    external-name

    Is a character constant delimited by apostrophes or quotation marks. The character constant is used as is; the string is not changed to uppercase, nor are blanks removed.

    The ALIAS property overrides the C (and STDCALL) property. If both C and ALIAS are specified for a subprogram, the subprogram is given the C calling convention, but not the C naming convention. It instead receives the name given for ALIAS, with no modifications.
    ALIAS cannot be used with internal procedures, and it cannot be applied to dummy arguments.
    cDEC$ ATTRIBUTES ALIAS has the same effect as the cDEC$ ALIAS directive (see Section 14.2).
  • ALLOW_NULL
    Enables a corresponding dummy argument to pass a NULL pointer (defined by a zero or the NULL intrinsic function) by value for the argument.
    ALLOW_NULL is only valid if the REFERENCE property is also specified; otherwise, it has no effect.
  • C and STDCALL
    Specify how data is to be passed when you use routines written in C or assembler with FORTRAN or Fortran 95/90 routines.
    C and STDCALL are synonyms.
    When applied to a subprogram, these properties define the subprogram as having a specific set of calling conventions.
    The following table summarizes the differences between the calling conventions:
    Convention C1 STDCALL1 Default2
    Arguments passed by value Yes Yes No

    1C and STDCALL are synonyms.
    2Fortran 95/90 calling convention.


    If C or STDCALL is specified for a subprogram, arguments (except for arrays and characters) are passed by value. Subprograms using standard Fortran 95/90 conventions pass arguments by reference.
    Character arguments are passed as follows:
    • By default, hidden lengths are put at the end of the argument list.
    • If C or STDCALL (only) is specified, the first character of the string is passed (and padded with zeros out to INTEGER(4) length).
    • If C or STDCALL is specified, and REFERENCE is specified for the argument, the string is passed but the length is not passed.
    • If C or STDCALL is specified, and REFERENCE is specified for the routine (but REFERENCE is not specified for the argument, if any), the string is passed but the length is not passed.

    For details, see information on mixed-language programming in the HP Fortran for OpenVMS User Manual. See also the description of REFERENCE in this list.
  • DECORATE
    Specifies that the external name used in cDEC$ ALIAS or cDEC$ ATTRIBUTES ALIAS should have the prefix and postfix decorations performed on it that are associated with the calling mechanism that is in effect. These are the same decorations performed on the procedure name when ALIAS is not specified.
    The case of the external name is not modified.
    If ALIAS is not specified, this property has no effect.
    See also the summary of prefix and postfix decorations in the above description of ATTRIBUTES options C and STDCALL.
  • DEFAULT
    Overrides certain compiler options that can affect external routine and COMMON block declarations.
    It specifies that the compiler should ignore compiler options that change the default conventions for external symbol naming and argument passing for routines and COMMON blocks.
    This option can be combined with other cDEC$ ATTRIBUTES options, such as STDCALL, C, REFERENCE, ALIAS, etc. to specify attributes different from the compiler defaults.
    This option is useful when declaring INTERFACE blocks for external routines, since it prevents compiler options from changing calling or naming conventions.
  • DESCRIPTOR
    Specifies that the argument is passed by VMS descriptor. This property can be specified only for dummy arguments in an INTERFACE block (not for a routine name).
  • DESCRIPTOR32
    Specifies that the argument is passed as a 32-bit descriptor.
  • DESCRIPTOR64
    Specifies that the argument is passed as a 64-bit descriptor.
  • EXTERN
    Specifies that a variable is allocated in another source file. EXTERN can be used in global variable declarations, but it must not be applied to dummy arguments.
    EXTERN must be used when accessing variables declared in other languages.
  • IGNORE_LOC
    Enables %LOC to be stripped from an argument.
    IGNORE_LOC is only valid if the REFERENCE property is also specified; otherwise, it has no effect.
  • NO_ARG_CHECK
    Specifies that type and shape matching rules related to explicit interfaces are to be ignored. This permits the construction of an INTERFACE block for an external procedure or a module procedure that accepts an argument of any type or shape; for example, a memory copying routine.
    NO_ARG_CHECK can appear only in an INTERFACE block for a non-generic procedure or in a module procedure. It can be applied to an individual dummy argument name or to the routine name, in which case the property is applied to all dummy arguments in that interface.
    NO_ARG_CHECK cannot be used for procedures with the PURE or ELEMENTAL prefix. If an argument has an INTENT or OPTIONAL attribute, any NO_ARG_CHECK specification is ignored.
  • NOMIXED_STR_LEN_ARG
    Specifies that hidden lengths be placed in sequential order at the end of the argument list.
  • REFERENCE and VALUE
    Specify how a dummy argument is to be passed.
    REFERENCE specifies a dummy argument's memory location is to be passed instead of the argument's value.
    VALUE specifies a dummy argument's value is to be passed instead of the argument's memory location.
    When a dummy argument has the VALUE property, the actual argument passed to it can be of a different type. If necessary, type conversion is performed before the subprogram is called.
    When a complex (KIND=4 or KIND=8) argument is passed by value, two floating-point arguments (one containing the real part, the other containing the imaginary part) are passed by immediate value.
    Character values, substrings, assumed-size arrays, and adjustable arrays cannot be passed by value.
    If REFERENCE (only) is specified for a character argument, the string is passed but the length is not passed.
    If REFERENCE is specified for a character argument, and C (or STDCALL) has been specified for the routine, the string is passed with no length. This is true even if REFERENCE is also specified for the routine.
    If REFERENCE and C (or STDCALL) are specified for a routine, but REFERENCE has not been specified for the argument, the string is passed with the length.
    VALUE is the default if the C or STDCALL property is specified in the subprogram definition.
    For more details, see information on mixed-language programming in the HP Fortran for OpenVMS User Manual.
  • REFERENCE32
    Specifies that the argument is accepted only by 32-bit address.
  • REFERENCE64
    Specifies that the argument is accepted only by 64-bit address.
  • VARYING
    Allows a variable number of calling arguments. If VARYING is specified, the C property must also be specified.
    Either the first argument must be a number indicating how many arguments to process, or the last argument must be a special marker (such as --1) indicating it is the final argument. The sequence of the arguments, and types and kinds must be compatible with the called procedure.

Options C, STDCALL, REFERENCE, VALUE, and VARYING affect the calling conventions of routines:

  • You can specify C, STDCALL, REFERENCE, and VARYING for an entire routine.
  • You can specify VALUE and REFERENCE for individual arguments.

For More Information:

  • On syntax rules for all general directives, see Section 14.1.
  • On using the cDEC$ ATTRIBUTES directive, see the HP Fortran for OpenVMS User Manual.

Note

1 The following form is also allowed: !MS$ATTRIBUTES att [,att]... :: object [,object]...

14.4 DECLARE or NODECLARE Directives

The DECLARE directive generates warnings for variables that have been used but have not been declared (like the IMPLICIT NONE statement). The NODECLARE directive (the default) disables these warnings.

The DECLARE and NODECLARE directives take the following forms: 1


  • cDEC$ DECLARE
  • cDEC$ NODECLARE

c

Is one of the following: C (or c), !, or * (see Section 14.1).

The DECLARE directive is primarily a debugging tool that locates variables that have not been properly initialized, or that have been defined but never used.

For More Information:

Note

1 The following forms are also allowed: !MS$DECLARE and !MS$NODECLARE.


Previous Next Contents Index