Reference Guide  2.5.0
psyclone.f2pygen.AllocateGen Class Reference
Inheritance diagram for psyclone.f2pygen.AllocateGen:
Collaboration diagram for psyclone.f2pygen.AllocateGen:

Public Member Functions

def __init__ (self, parent, content, mold=None)
 
- Public Member Functions inherited from psyclone.f2pygen.BaseGen
def __init__ (self, parent, root)
 
def parent (self)
 
def children (self)
 
def root (self)
 
def add (self, new_object, position=None)
 
def previous_loop (self)
 
def last_declaration (self)
 
def start_parent_loop (self, debug=False)
 

Detailed Description

 Generates a Fortran allocate statement 

Definition at line 833 of file f2pygen.py.

Constructor & Destructor Documentation

◆ __init__()

def psyclone.f2pygen.AllocateGen.__init__ (   self,
  parent,
  content,
  mold = None 
)
:param parent: node to which to add this ALLOCATE as a child
:type parent: :py:class:`psyclone.f2pygen.BaseGen`
:param content: string or list of variables to allocate
:type content: list of strings or a single string
:param mold: A string to be used as the 'mold' parameter of ALLOCATE.
:type mold: str or None.

:raises RuntimeError: if `content` is not of correct type

Definition at line 835 of file f2pygen.py.

835  def __init__(self, parent, content, mold=None):
836  '''
837  :param parent: node to which to add this ALLOCATE as a child
838  :type parent: :py:class:`psyclone.f2pygen.BaseGen`
839  :param content: string or list of variables to allocate
840  :type content: list of strings or a single string
841  :param mold: A string to be used as the 'mold' parameter of ALLOCATE.
842  :type mold: str or None.
843 
844  :raises RuntimeError: if `content` is not of correct type
845  '''
846  reader = FortranStringReader("allocate(dummy)")
847  reader.set_format(FortranFormat(True, False)) # free form, strict
848  myline = reader.next()
849  self._decl = fparser1.statements.Allocate(parent.root, myline)
850  if isinstance(content, str):
851  self._decl.items = [content]
852  elif isinstance(content, list):
853  self._decl.items = content
854  else:
855  raise RuntimeError(
856  f"AllocateGen expected the content argument to be a str or"
857  f" a list, but found {type(content)}")
858  if mold:
859  self._decl.items.append(f"mold={mold}")
860  BaseGen.__init__(self, parent, self._decl)
861 
862 

References psyclone.f2pygen.AllocateGen._decl, psyclone.f2pygen.DeallocateGen._decl, psyclone.f2pygen.BaseDeclGen._decl, psyclone.f2pygen.DeclGen._decl, psyclone.f2pygen.CharDeclGen._decl, and psyclone.f2pygen.TypeDeclGen._decl.


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