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:

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:

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:

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:

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

For More Information:

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