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] | REFERENCE32 [3] |
ALIAS | DESCRIPTOR64 [3] | REFERENCE64 [3] |
ARRAY_VISUALIZER [2] | DLLEXPORT [2] | STDCALL |
C | DLLIMPORT [2] | VALUE |
DEFAULT | EXTERN | VARYING |
DESCRIPTOR [3] | REFERENCE | |
[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 |
ARRAY_VISUALIZER[2] | Yes | No | No |
C | No | Yes | Yes |
DEFAULT | No | Yes | Yes |
DESCRIPTOR | Yes[3] | No | No |
DESCRIPTOR32 | Yes[3] | No | No |
DESCRIPTOR64 | Yes[3] | No | No |
DLLEXPORT | No | Yes | Yes |
DLLIMPORT | No | Yes | Yes |
EXTERN | Yes | No | No |
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).
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 90 routines.
On Intel 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 |
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 and Tru64 UNIX
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 90 conventions pass arguments by reference.
On Intel 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.
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 for only 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.
If a procedure (or data) is declared with the DLLEXPORT property,
it must be defined in the same module of the same program.
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.
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)
have 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 (if any), 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]...