Fortran module entities (data and procedures) have external names that differ from other external entities. Module names use the convention:
MODULENAME is the name of the module and is all uppercase by default. ENTITY is the name of the module procedure or module data contained within MODULENAME. ENTITY is also 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 .OBJ file on ia32 systems:
_MYMOD_mp_A
_MYMOD_mp_B@4
Or, on ia64 systems:
MYMOD_mp_A
MYMOD_mp_B
Compiler options can affect the naming of module data and procedures.
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 ia32 Systems | Procedure Name in .OBJ file on ia64 Systems |
---|---|---|
None | _MYMOD_mp_B@4 | MYMOD_mp_B |
C | _MYMOD_mp_b | MYMOD_mp_b |
STDCALL | _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. Examples are given in the section Using Modules in Mixed-Language Programming.