ford.graphs module#

class ford.graphs.AfferentGraph(root, data, ident=None)#

Bases: FortranGraph

Shows the relationship between files which depend upon this one

exception ford.graphs.BadType(value)#

Bases: Exception

Raised when a type is passed to GraphData.register() which is not accepted.

class ford.graphs.BaseNode(obj, graph_data, hist=None)#

Bases: object

Graph node representing some Fortran entity

Parameters:
colour = '#777777'#
class ford.graphs.BlockNode(obj, gd, hist=None)#

Bases: BaseNode

colour = '#5cb85c'#
class ford.graphs.CallGraph(root, data, ident=None)#

Bases: FortranGraph

Adds edges indicating the call-tree for the procedures listed in the nodes.

RANKDIR = 'LR'#
class ford.graphs.CalledByGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs procedures called by this procedure

RANKDIR = 'LR'#
class ford.graphs.CallsGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs procedures that this procedure calls

RANKDIR = 'LR'#
class ford.graphs.EfferentGraph(root, data, ident=None)#

Bases: FortranGraph

Shows the relationship between the files which this one depends on

class ford.graphs.FileGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs relationships between source files

class ford.graphs.FileNode(obj, gd, hist=None)#

Bases: BaseNode

colour = '#f0ad4e'#
class ford.graphs.FortranGraph(root, data, ident=None)#

Bases: object

Graph of some relationship for a given entity

Parameters:
  • root (Union[FortranContainer, Iterable[FortranContainer]]) – Top-level entity or entities in graph

  • data (GraphData) – Collection of nodes and graph customisation options

  • ident (Optional[str]) – Alternative identification for graph, and used as base name for saved files. If there are multiple entities in root, and ident isn’t given, it is set from the first entity in root

hop_nodes#

Nodes of the hop which exceed the maximum

hop_edges#

Edges of the hop which exceed the maximum

added#

Set of nodes in graph

max_nesting#

Maximum number of hops allowed. Set from maximum value of graph_maxdepth in root.meta

max_nodes#

Maximum number of nodes allowed. Set from maximum value of graph_maxnodes in root.meta

warn#

If true, show warnings if graphs exceed max_nesting or max_nodes

truncated#

Nesting level where the graph was truncated

RANKDIR = 'RL'#
add_nodes(nodes, nesting=1)#

Add nodes and edges to this graph, based on the collection nodes

Subclasses should implement _add_node, and optionally _extra_attributes

add_to_graph(nodes, edges, nesting)#

Adds nodes and edges to the graph as long as the maximum number of nodes is not exceeded. All edges are expected to have a reference to an entry in nodes. If the list of nodes is not added in the first hop due to graph size limitations, they are stored in hop_nodes. If the graph was extended the function returns True, otherwise the result will be False.

create_svg(out_location)#
class ford.graphs.GraphData(parent_dir, coloured_edges, show_proc_parent)#

Bases: object

Stores graph nodes representing Fortran entities to be displayed in a graph, as well as some customisation options for graphs

Parameters:
  • parent_dir (str) – Path to top of site

  • coloured_edges (bool) – If true, arrows between nodes are coloured, otherwise they are black

  • show_proc_parent (bool) – If true, the parent of a procedure is shown in the node label

get_module_node(mod)#
Return type:

ModNode

get_node(obj, hist=None)#

Returns the node corresponding to obj. If does not already exist then it will create it.

Parameters:
Return type:

BaseNode

get_procedure_node(procedure, hist)#
Return type:

ProcNode

get_type_node(type_, hist)#
Return type:

TypeNode

register(obj, hist=None)#

Create and store the graph node for obj, if it hasn’t already been registered

Parameters:
Return type:

None

class ford.graphs.GraphManager(graphdir, parentdir, coloured_edges, show_proc_parent, save_graphs=False)#

Bases: object

Collection of graphs of the various relationships between a set of entities

Contains graphs of module use relations, type relations, call trees, etc. It manages these, ensures that everything that is needed is added at the correct time, and produces the plots for the list pages.

Parameters:
  • graphdir (PathLike) – The location of the graphs within the output tree.

  • parentdir (str) – Location of top-level directory

  • coloured_edges (bool) – If true, arrows in graphs use different colours to help distinguish them

  • show_proc_parent (bool) – If true, show the parent of a procedure in the call graph as part of the label

  • save_graphs (bool) – If true, save graphs as separate files, as well as embedding them in the HTML

graph_all()#

Create all graphs

output_graphs(njobs=0)#

Save graphs to file

register(obj)#

Register obj as a node to be used in graphs

class ford.graphs.InheritedByGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs types that inherit this type

added: Set[BaseNode]#
hop_edges: List[BaseNode]#
hop_nodes: List[BaseNode]#
class ford.graphs.InheritsGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs types that this type inherits from

added: Set[BaseNode]#
hop_edges: List[BaseNode]#
hop_nodes: List[BaseNode]#
class ford.graphs.ModNode(obj, gd, hist=None)#

Bases: BaseNode

colour = '#337AB7'#
class ford.graphs.ModuleGraph(root, data, ident=None)#

Bases: FortranGraph

Shows the relationship between modules and submodules

added: Set[BaseNode]#
hop_edges: List[BaseNode]#
hop_nodes: List[BaseNode]#
class ford.graphs.ProcNode(obj, gd, hist=None)#

Bases: BaseNode

COLOURS = {'boundproc': '#A7506F', 'function': '#d94e8f', 'interface': '#A7506F', 'subroutine': '#d9534f'}#
property colour#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

class ford.graphs.ProgNode(obj, gd, hist=None)#

Bases: BaseNode

colour = '#f0ad4e'#
class ford.graphs.SubmodNode(obj, gd, hist=None)#

Bases: ModNode

colour = '#5bc0de'#
class ford.graphs.TypeGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs inheritance and composition relationships between derived types

added: Set[BaseNode]#
hop_edges: List[BaseNode]#
hop_nodes: List[BaseNode]#
class ford.graphs.TypeNode(obj, gd, hist=None)#

Bases: BaseNode

colour = '#5cb85c'#
class ford.graphs.UsedByGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs how modules are used by other modules

added: Set[BaseNode]#
hop_edges: List[BaseNode]#
hop_nodes: List[BaseNode]#
class ford.graphs.UsesGraph(root, data, ident=None)#

Bases: FortranGraph

Graphs how modules use other modules, including ancestor (sub)modules

added: Set[BaseNode]#
hop_edges: List[BaseNode]#
hop_nodes: List[BaseNode]#
ford.graphs.get_call_nodes(calls, visited=None, result=None)#

takes a list of calls, and returns a set of all the calls that should be nodes in the graph

not all calls are a node, some are not visible, and some are simple procedure bindings (bindings that bind one visible procedure to one label)

these should be skipped, and show a call to their descendant instead

Return type:

Set[Union[str, FortranContainer, FortranBoundProcedure]]

ford.graphs.is_blockdata(obj)#
ford.graphs.is_module(obj)#
ford.graphs.is_proc(obj)#
ford.graphs.is_program(obj)#
ford.graphs.is_sourcefile(obj)#
ford.graphs.is_submodule(obj)#
ford.graphs.is_type(obj)#
ford.graphs.newdict(old, key, val)#
ford.graphs.outputFuncWrap(args)#

Wrapper function for output graphs – needed to allow multiprocessing to pickle the function (must be at top level)