The ATTRIBUTES directive lets you specify properties for data objects and procedures. It takes the following form: [See Note]
cDEC$ ATTRIBUTES att [,att]... :: object [,object]...
| ADDRESS64 [1] | DESCRIPTOR32 [3] | REFERENCE |
| ALIAS | DESCRIPTOR64 [3] | REFERENCE32 [3] |
| ALLOW_NULL | DLLEXPORT [2] | REFERENCE64 [3] |
| ARRAY_VISUALIZER [2] | DLLIMPORT [2] | STDCALL |
| C | EXTERN | VALUE |
| DECORATE | IGNORE_LOC | VARYING |
| DEFAULT | NO_ARG_CHECK | |
| DESCRIPTOR [3] | NOMIXED_STR_LEN_ARG | |
|
[1] VMS, WNT
| ||
The following table shows which properties can be used with various objects:
| Property | Variable and Array Declarations | Common Block Names [1] | Subprogram Specification and EXTERNAL Statements |
|---|---|---|---|
| ADDRESS64 | Yes | Yes | No |
| ALIAS | No | Yes | Yes |
| ALLOW_NULL | Yes | No | No |
| ARRAY_VISUALIZER[2] | Yes | No | No |
| C | No | Yes | Yes |
| DECORATE | No | No | Yes |
| DEFAULT | No | Yes | Yes |
| DESCRIPTOR | Yes[3] | No | No |
| DESCRIPTOR32 | Yes[3] | No | No |
| DESCRIPTOR64 | Yes[3] | No | No |
| DLLEXPORT | Yes[4] | Yes | Yes |
| DLLIMPORT | Yes | Yes | Yes |
| EXTERN | Yes | No | No |
| IGNORE_LOC | Yes | No | No |
| NO_ARG_CHECK | Yes | No | Yes[5] |
| 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 |
|
[1] A common block name is
specified as [/]common-block-name[/]
| |||
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:
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:
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.
Specifies an alternate external name to be used when referring to
external subprograms. Its form is:
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 15.1.2).
Enables a corresponding dummy argument to pass a NULL pointer
(defined by a zero or the NULL intrinsic) by value for the
argument.
ALLOW_NULL is only valid if the REFERENCE
property is also specified; otherwise, it has no effect.
Enhances the performance of the Array Visualizer.
When declaring allocatable arrays to be viewed using the Array
Viewer, this option can improve the performance of the Array Viewer.
For example:
When this option is used, array memory is shared between the
Array Viewer and your application. Otherwise, the array data is
copied during each faglUpdate call.
This option is not useful unless the array is viewed in the
Array Visualizer by using fagl* calls.
For more information on fagl* routines, see your online documentation
for Array Visualizer.
Specify how data is to be passed when you use routines written in
C or assembler with FORTRAN or Fortran 95/90 routines.
On x86 processors, C and STDCALL have slightly different
meanings; on all other platforms, they are interpreted as
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:
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
ALIAS:external-name
real(4), allocatable :: MyArray(:, :)
!DEC$ ATTRIBUTES array_visualizer :: MyArray
| Convention | C [1] | STDCALL [1] | Default [2] |
|---|---|---|---|
| Arguments passed by value | Yes | Yes | No |
| Case of external subprogram names | VMS: Uppercase
U*X: Lowercase WNT: Lowercase W9*: Lowercase |
VMS: Uppercase
U*X: Lowercase WNT: Lowercase W9*: Lowercase |
VMS: Uppercase
U*X: Lowercase WNT: Uppercase W9*: Uppercase |
| U*X only: | |||
| Trailing underscore added | No | No | Yes [3] |
| WNT, W9*: | |||
| Leading underscore added | Yes | Yes | Yes |
| Number of arguments added | No | Yes | Yes |
| Caller stack cleanup | Yes | No | No |
| Variable number of arguments | Yes | No | No |
|
[1] C and STDCALL are synonyms on OpenVMS, Tru64 UNIX,
and Linux systems, and Windows NT systems on Alpha processors.
| |||
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.
On x86 processors, an underscore ( _ ) is placed at the
beginning of the external name of a subprogram. If STDCALL is
specified, an at sign (@) followed by the number of argument
bytes being passed is placed at the end of the name. For example,
a subprogram named SUB1 that has three INTEGER(4) arguments and
is defined with STDCALL is assigned the external name _sub1@12.
Character arguments are passed as follows:
On all systems, the first character of the string is passed
(and padded with zeros out to INTEGER(4) length).
On all systems, the string is passed with no length.
On all systems, the string is passed with the length.
For more details, see information on mixed-language programming
in your user's manual or programmer's guide.
See also the following description of REFERENCE.
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 ALIAS external name is not modified.
If ALIAS is not specified, this option has no effect.
See also the summary of
prefix and postfix decorations in the above
description of ATTRIBUTES options C and STDCALL.
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. For example, in Visual Fortran the options
ignored would be: /iface, /names, and /assume:underscore.
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.
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).
Specifies that the argument is passed as a 32-bit descriptor.
Specifies that the argument is passed as a 64-bit descriptor.
Define a dynamic-link library's (DLL) interface for processes
that use them. The properties can be assigned to data objects or
procedures.
DLLEXPORT specifies that procedures or data are being exported to
other applications or DLLs. This causes the compiler to produce
efficient code, eliminating the need for a module definition
(.def) file to export symbols.
The DLLEXPORT property should be specified in the routine to which
it applies.
Symbols defined in a DLL are imported by programs that use them.
The program must link with the import DLL and use the DLLIMPORT
property inside the program unit that imports the symbol.
DLLIMPORT is specified in a declaration, not a definition, since
you cannot define a symbol you are importing.
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.
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.
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 can not 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.
Specifies that hidden lengths be placed in sequential order at the
end of the argument list. This is the method used on Tru64 UNIX
systems by default.
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
following occurs:
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 your user's manual or programmer's guide.
Specifies that the argument is accepted only by 32-bit address.
Specifies that the argument is accepted only by 64-bit address.
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.
Note: The following form is also allowed:
!MS$ATTRIBUTES att [,att]... :: object [,object]...