How to cross-reference Fortran entities#

This guide shows how to create reliable, clickable links between Fortran entities.

Reference by entity name#

Use the role that matches the entity type. For a function:

See :f:func:`compute` for the algorithm.
See {f:func}`compute` for the algorithm.

This renders as

See compute for the algorithm.

For the full list of roles, see the Roles reference.

Reference an entity in another module#

Use dot-separated qualified names:

Uses :f:func:`physics.kinetic_energy` internally.
Uses {f:func}`physics.kinetic_energy` internally.

This renders as

Uses physics.kinetic_energy internally.

If a f:currentmodule is active, unqualified names are searched in that module first.

Handle case-insensitive names#

Fortran is case-insensitive, and so are sphinx-ford cross-references. All of these resolve to the same entity:

:f:mod:`MY_MODULE`
:f:mod:`my_module`
:f:mod:`My_Module`
{f:mod}`MY_MODULE`
{f:mod}`my_module`
{f:mod}`My_Module`

This renders as:

Reference type components#

Type components (f:member) and bound procedures (f:boundproc) are qualified through their parent module, not the type:

:f:mem:`my_module.component_name`
{f:mem}`my_module.component_name`

This renders as:

my_module.component_name