How to use the ford.sourceform.FortranSubmodule function in FORD

To help you get started, we’ve selected a few FORD examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
def get_dir(self):
        if ( type(self) in [FortranSubroutine,FortranFunction] and
             type(self.parent) is FortranInterface and
             not self.parent.generic ):
            return 'interface'
        elif type(self) is FortranSubmodule:
            return 'module'
        elif ( type(self) in [FortranSourceFile,FortranProgram,FortranModule,
                              GenericSource,FortranBlockData]
               or ( type(self) in [FortranType,FortranInterface,FortranFunction,
                                   FortranSubroutine, FortranSubmoduleProcedure]
                    and type(self.parent) in [FortranSourceFile,FortranProgram,
                                              FortranModule, FortranSubmodule,
                                              FortranBlockData] ) ):
            return self.obj
        else:
            return None
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
def __init__(self,obj,gd):
        super(SubmodNode,self).__init__(obj,gd)
        del self.used_by
        if not self.fromstr:
            if obj.ancestor:
                self.ancestor = gd.get_node(obj.ancestor,FortranSubmodule)
            else:
                self.ancestor = gd.get_node(obj.ancestor_mod,FortranModule)
            self.ancestor.children.add(self)
            self.efferent += 1
            self.ancestor.afferent += 1
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
def is_submodule(obj,cls):
    return isinstance(obj,FortranSubmodule) or issubclass(cls,FortranSubmodule)
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
self.all_vars = getattr(self.parent,'all_vars',{})
        for var in self.variables:
            self.all_vars[var.name.lower()] = var

        if type(getattr(self,'ancestor','')) not in [str, type(None)]:
            self.ancestor.descendants.append(self)
            self.all_procs.update(self.ancestor.all_procs)
            self.all_absinterfaces.update(self.ancestor.all_absinterfaces)
            self.all_types.update(self.ancestor.all_types)
        elif type(getattr(self,'ancestor_mod','')) not in [str, type(None)]:
            self.ancestor_mod.descendants.append(self)
            self.all_procs.update(self.ancestor_mod.all_procs)
            self.all_absinterfaces.update(self.ancestor_mod.all_absinterfaces)
            self.all_types.update(self.ancestor_mod.all_types)

        if isinstance(self,FortranSubmodule):
            for proc in self.routines:
                if proc.module and proc.name.lower() in self.all_procs:
                    intr = self.all_procs[proc.name.lower()]
                    if intr.proctype.lower() == 'interface' and not intr.generic and not intr.abstract and intr.procedure.module == True:
                        proc.module = intr
                        intr.procedure.module = proc

        if hasattr(self,'modprocedures'):
            for proc in self.modprocedures:
                if proc.name.lower() in self.all_procs:
                    intr = self.all_procs[proc.name.lower()]
                    # Don't think I need these checks...
                    if intr.proctype.lower() =='interface' and not intr.generic and not intr.abstract and intr.procedure.module == True:
                        proc.attribs = intr.procedure.attribs
                        proc.args = intr.procedure.args
                        if hasattr(intr.procedure, 'retvar'):
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
self.all_vars = getattr(self.parent,'all_vars',{})
        for var in self.variables:
            self.all_vars[var.name.lower()] = var

        if type(getattr(self,'ancestor','')) not in [str, type(None)]:
            self.ancestor.descendants.append(self)
            self.all_procs.update(self.ancestor.all_procs)
            self.all_absinterfaces.update(self.ancestor.all_absinterfaces)
            self.all_types.update(self.ancestor.all_types)
        elif type(getattr(self,'ancestor_mod','')) not in [str, type(None)]:
            self.ancestor_mod.descendants.append(self)
            self.all_procs.update(self.ancestor_mod.all_procs)
            self.all_absinterfaces.update(self.ancestor_mod.all_absinterfaces)
            self.all_types.update(self.ancestor_mod.all_types)

        if isinstance(self,FortranSubmodule):
            for proc in self.functions + self.subroutines:
                if proc.module and proc.name.lower() in self.all_procs:
                    intr = self.all_procs[proc.name.lower()]
                    if intr.proctype.lower() == 'interface' and not intr.generic and not intr.abstract and intr.procedure.module == True:
                        proc.module = intr
                        intr.procedure.module = proc

        if hasattr(self,'modprocedures'):
            tmplist = []
            for proc in self.modprocedures:
                if proc.name.lower() in self.all_procs:
                    intr = self.all_procs[proc.name.lower()]
                    # Don't think I need these checks...
                    if intr.proctype.lower() =='interface' and not intr.generic and not intr.abstract and intr.procedure.module == True:
                        proc.attribs = intr.procedure.attribs
                        proc.args = intr.procedure.args
github Fortran-FOSS-Programmers / ford / ford / fortran_project.py View on Github external
uselist.extend(get_deps(proc))
            for proc in getattr(item,'modprocedures',[]):
                uselist.extend(get_deps(proc))
            return uselist
        
        for mod in self.modules:
            uselist = get_deps(mod)
            uselist = [m for m in uselist if type(m) == ford.sourceform.FortranModule]
            deplist[mod] = set(uselist)
            mod.deplist = uselist
        for mod in self.submodules:
            if type(mod.ancestor_mod) is ford.sourceform.FortranModule:
                uselist = get_deps(mod)
                uselist = [m for m in uselist if type(m) == ford.sourceform.FortranModule]
                if mod.ancestor:
                    if type(mod.ancestor) is ford.sourceform.FortranSubmodule:
                        uselist.insert(0,mod.ancestor)
                    elif self.settings['warn'].lower() == 'true':
                        print('Warning: could not identify parent SUBMODULE of SUBMODULE ' + mod.name)
                else:
                    uselist.insert(0,mod.ancestor_mod)
                mod.deplist = uselist
                deplist[mod] = set(uselist)
            elif self.settings['warn'].lower() == 'true':
                print('Warning: could not identify parent MODULE of SUBMODULE ' + mod.name)
        # Get dependencies for programs and top-level procedures as well,
        # if dependency graphs are to be produced
        if self.settings['graph'].lower() == 'true':
            for proc in self.procedures:
                proc.deplist = set([m for m in get_deps(proc) if type(m) == ford.sourceform.FortranModule])
            for prog in self.programs:
                prog.deplist = set([m for m in get_deps(prog) if type(m) == ford.sourceform.FortranModule])
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
def get_dir(self):
        if ( type(self) in [FortranSubroutine,FortranFunction] and
             type(self.parent) is FortranInterface and
             not self.parent.generic ):
            return 'interface'
        elif type(self) is FortranSubmodule:
            return 'module'
        elif ( type(self) in [FortranSourceFile,FortranProgram,FortranModule,
                              GenericSource,FortranBlockData]
               or ( type(self) in [FortranType,FortranInterface,FortranFunction,
                                   FortranSubroutine, FortranSubmoduleProcedure]
                    and type(self.parent) in [FortranSourceFile,FortranProgram,
                                              FortranModule, FortranSubmodule,
                                              FortranBlockData] ) ):
            return self.obj
        else:
            return None
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
else:
                    raise Exception("Found BLOCK DATA in {}".format(type(self).__name__[7:].upper()))
            elif self.BLOCK_RE.match(line):
                blocklevel += 1
            elif self.ASSOCIATE_RE.match(line):
                associatelevel += 1
            elif self.MODULE_RE.match(line):
                if hasattr(self,'modules'):
                    self.modules.append(FortranModule(source,
                                        self.MODULE_RE.match(line),self))
                    self.num_lines += self.modules[-1].num_lines - 1
                else:
                    raise Exception("Found MODULE in {}".format(type(self).__name__[7:].upper()))
            elif self.SUBMODULE_RE.match(line):
                if hasattr(self,'submodules'):
                    self.submodules.append(FortranSubmodule(source,
                                           self.SUBMODULE_RE.match(line),self))
                    self.num_lines += self.submodules[-1].num_lines - 1
                else:
                    raise Exception("Found SUBMODULE in {}".format(type(self).__name__[7:].upper()))
            elif self.PROGRAM_RE.match(line):
                if hasattr(self,'programs'):
                    self.programs.append(FortranProgram(source,
                                         self.PROGRAM_RE.match(line),self))
                    self.num_lines += self.programs[-1].num_lines - 1
                else:
                    raise Exception("Found PROGRAM in {}".format(type(self).__name__[7:].upper()))
                if len(self.programs) > 1:
                    raise Exception("Multiple PROGRAM units in same source file.")
            elif self.SUBROUTINE_RE.match(line):
                if isinstance(self,FortranCodeUnit) and not incontains: continue
                if hasattr(self,'subroutines'):
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
gd = GraphData()
class Proc(object):
    def __init__(self,name,proctype):
        self.name = name
        self.proctype = proctype
        self.ident = ''
    def get_url(self):
        return ''
    def get_dir(self):
        return ''
    
sub = Proc('Subroutine','Subroutine')
func = Proc('Function','Function')
intr = Proc('Interface','Interface')
gd.register('Module',FortranModule)
gd.register('Submodule',FortranSubmodule)
gd.register('Type',FortranType)
gd.register(sub,FortranSubroutine)
gd.register(func,FortranFunction)
gd.register(intr,FortranInterface)
gd.register('Unknown Procedure Type',FortranSubroutine)
gd.register('Program',FortranProgram)
gd.register('Source File',FortranSourceFile)

try:
    # Generate key for module graph
    dot = Digraph('Graph Key',graph_attr={'size':'8.90625,1000.0',
                                          'concentrate':'false'},
                              node_attr={'shape':'box',
                                         'height':'0.0',
                                         'margin':'0.08',
                                         'fontname':'Helvetica',