fparser Reference Guide  0.0.14
fparser.one.statements.Allocate Class Reference
Inheritance diagram for fparser.one.statements.Allocate:
Collaboration diagram for fparser.one.statements.Allocate:

Public Member Functions

def process_item (self)
 
def tofortran (self, isfix=None)
 
def analyze (self)
 
- Public Member Functions inherited from fparser.common.base_classes.Statement
def __init__ (self, parent, item)
 
def __repr__ (self)
 
def torepr (self, depth=-1, incrtab="")
 
def get_indent_tab (self, deindent=False, isfix=None)
 
def __str__ (self)
 
def asfix (self)
 
def format_message (self, kind, message)
 
def error (self, message)
 
def warning (self, message)
 
def info (self, message)
 
def analyze (self)
 
def get_variable (self, name)
 
def get_type (self, name)
 
def get_type_decl (self, kind)
 
def get_provides (self)
 
- Public Member Functions inherited from fparser.common.utils.classes
def __new__ (metacls, name, bases, dict)
 
- Public Member Functions inherited from fparser.common.utils.meta_classes
def __getattr__ (self, name)
 

Public Attributes

 spec
 
 items
 
- Public Attributes inherited from fparser.common.base_classes.Statement
 parent
 
 reader
 
 top
 
 item
 
 programblock
 
 isvalid
 
 ignore
 
 a
 

Static Public Attributes

 match
 
- Static Public Attributes inherited from fparser.common.base_classes.Statement
list modes = ["free", "fix", "f77", "pyf"]
 

Detailed Description

ALLOCATE ( [ <type-spec> :: ] <allocation-list> [ , <alloc-opt-list> ] )
<alloc-opt> = STAT = <stat-variable>
            | ERRMSG = <errmsg-variable>
            | SOURCE = <source-expr>
<allocation> = <allocate-object> [ ( <allocate-shape-spec-list> ) ]

Definition at line 727 of file statements.py.

Member Function Documentation

◆ process_item()

def fparser.one.statements.Allocate.process_item (   self)
Process the ALLOCATE statement and store the various entities being
allocated in self.items. Any type-specification is stored in
self.spec.

:raises ParseError: if an invalid type-specification is used

Definition at line 738 of file statements.py.

References fparser.common.base_classes.Statement.item, fparser.one.statements.StatementWithNamelist.items, fparser.one.statements.Assign.items, fparser.one.statements.Call.items, fparser.one.statements.ComputedGoto.items, fparser.one.statements.AssignedGoto.items, fparser.one.statements.Print.items, fparser.one.statements.Read0.items, fparser.one.statements.Read1.items, fparser.one.statements.Write.items, fparser.one.statements.Allocate.items, fparser.one.statements.GeneralAssignment.match, fparser.one.statements.Assign.match, fparser.one.statements.Call.match, fparser.one.block_statements.EndSource.match, fparser.one.block_statements.BeginSource.match, fparser.one.statements.Goto.match, fparser.one.statements.ComputedGoto.match, fparser.one.block_statements.EndModule.match, fparser.one.block_statements.Module.match, fparser.one.statements.AssignedGoto.match, fparser.one.statements.Continue.match, fparser.one.statements.Return.match, fparser.one.statements.Stop.match, fparser.one.block_statements.EndPythonModule.match, fparser.one.statements.Print.match, fparser.one.block_statements.PythonModule.match, fparser.one.block_statements.EndProgram.match, fparser.one.statements.Read.match, fparser.one.block_statements.EndBlockData.match, fparser.one.block_statements.BlockData.match, fparser.one.block_statements.EndInterface.match, fparser.one.statements.Write.match, fparser.one.block_statements.Interface.match, fparser.one.statements.Flush.match, fparser.one.statements.Wait.match, fparser.one.statements.Contains.match, fparser.one.statements.Allocate.match, fparser.one.block_statements.EndSubroutine.match, fparser.one.block_statements.Subroutine.match, fparser.one.block_statements.EndFunction.match, fparser.one.block_statements.Function.match, fparser.one.block_statements.SubprogramPrefix.match, fparser.one.block_statements.EndSelect.match, fparser.one.block_statements.SelectCase.match, fparser.one.block_statements.SelectType.match, fparser.one.block_statements.EndWhere.match, fparser.one.block_statements.Where.match, fparser.one.block_statements.EndForall.match, fparser.one.block_statements.Forall.match, fparser.one.block_statements.EndIfThen.match, fparser.one.block_statements.IfThen.match, fparser.one.block_statements.If.match, fparser.one.block_statements.EndDo.match, fparser.one.block_statements.Do.match, fparser.one.block_statements.EndAssociate.match, fparser.one.block_statements.Associate.match, fparser.one.block_statements.EndType.match, fparser.one.block_statements.Type.match, fparser.one.block_statements.EndEnum.match, fparser.one.block_statements.Enum.match, and fparser.one.statements.Allocate.spec.

738  def process_item(self):
739  """
740  Process the ALLOCATE statement and store the various entities being
741  allocated in self.items. Any type-specification is stored in
742  self.spec.
743 
744  :raises ParseError: if an invalid type-specification is used
745  """
746  line = self.item.get_line()[8:].lstrip()[1:-1].strip()
747  item2 = self.item.copy(line, True)
748  line2 = item2.get_line()
749  i = line2.find("::")
750  if i != -1:
751  spec = item2.apply_map(line2[:i].rstrip())
752  from .block_statements import type_spec
753 
754  stmt = None
755  for cls in type_spec:
756  if cls.match(spec):
757  stmt = cls(self, item2.copy(spec))
758  if stmt.isvalid:
759  break
760  if stmt is not None and stmt.isvalid:
761  spec = stmt
762  elif is_name(spec):
763  # Type spec is the name of a derived type
764  pass
765  else:
766  raise ParseError(
767  "Unrecognised type-specification in ALLOCATE statement: "
768  "{0}".format(self.item.line)
769  )
770  line2 = line2[i + 2 :].lstrip()
771  else:
772  spec = None
773  self.spec = spec
774  self.items = specs_split_comma(line2, item2)
775  return
776 

◆ tofortran()

def fparser.one.statements.Allocate.tofortran (   self,
  isfix = None 
)
Create the Fortran code for this ALLOCATE statement

:param bool isfix: whether or not to generate fixed-format code
:return: Fortran code
:rtype: str

Definition at line 777 of file statements.py.

References fparser.common.base_classes.Statement.get_indent_tab(), fparser.one.statements.StatementWithNamelist.items, fparser.one.statements.Assign.items, fparser.one.statements.Call.items, fparser.one.statements.ComputedGoto.items, fparser.one.statements.AssignedGoto.items, fparser.one.statements.Print.items, fparser.one.statements.Read0.items, fparser.one.statements.Read1.items, fparser.one.statements.Write.items, fparser.one.statements.Allocate.items, and fparser.one.statements.Allocate.spec.

777  def tofortran(self, isfix=None):
778  """
779  Create the Fortran code for this ALLOCATE statement
780 
781  :param bool isfix: whether or not to generate fixed-format code
782  :return: Fortran code
783  :rtype: str
784  """
785  type_spec = ""
786  if self.spec:
787  if isinstance(self.spec, str):
788  type_spec = self.spec
789  else:
790  type_spec = self.spec.tostr()
791  type_spec += " :: "
792  return self.get_indent_tab(isfix=isfix) + "ALLOCATE (%s%s)" % (
793  type_spec,
794  ", ".join(self.items),
795  )
796 
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: