Fortran Module Names and ATTRIBUTES

Fortran module entities (data and procedures) have external names that differ from other external entities. Module names use the convention:

modulename_mp_entity_(Linux and Mac OS)
_MODULENAME_mp_ENTITY [ @stacksize ]
(Windows)

 

modulename is the name of the module. For Windows* systems, the name is uppercase by default.
entity
is the name of the module procedure or module data contained within MODULENAME. For Windows* systems, ENTITY is uppercase by default.
_mp_
is the separator between the module and entity names and is always lowercase.

For example:

    MODULE mymod       INTEGER a    CONTAINS       SUBROUTINE b (j)          INTEGER j       END SUBROUTINE    END MODULE

This results in the following symbols being defined in the compiled object file on Linux systems (On Mac OS systems, the symbols would begin with an underscore)::

mymod_mp_a_
mymod_mp_b_

The following symbols are defined in the compiled object file on Windows systems based on IA-32 architecture:

_MYMOD_mp_A
_MYMOD_mp_B

Compiler options can affect the naming of module data and procedures.

Note

Except for ALIAS, ATTRIBUTES options do not affect the module name.

The following table shows how each ATTRIBUTES option affects the subroutine in the previous example module.

Effect of ATTRIBUTES options on Fortran Module Names

ATTRIBUTES Option Given to Routine 'b' Procedure Name in .OBJ file on Systems Using IA-32 Architecture Procedure Name in .OBJ file on Systems Using Intel® 64 Architecture and IA-64 Architecture

None

mymod_mp_b_ (Linux)
_mymod_mp_b_ (Mac OS)
_MYMOD_mp_B
(Windows)

mymod_mp_b_ (Linux)
_mymod_mp_b_ (Mac OS)

MYMOD_mp_B
(Windows)

 

C

mymod_mp_b_(Linux)
_mymod_mp_b_(Mac OS)
MYMOD_mp_b
(Windows)

mymod_mp_b (Linux)
_mymod_mp_b (Mac OS)
MYMOD_mp_b
(Windows)

STDCALL (Windows only)

_MYMOD_mp_b@4

MYMOD_mp_b

ALIAS

Overrides all others, name as given in the alias

Overrides all others, name as given in the alias

VARYING

No effect on name

No effect on name

You can write code to call Fortran modules or access module data from other languages. As with other naming and calling conventions, the module name must match between the two languages. Generally, this means using the C or STDCALL convention in Fortran, and if defining a module in another language, using the ALIAS option to match the name within Fortran. For examples, see Using Modules in Mixed-Language Programming.