|
| isNodeInProcedure (self, node, procList) |
|
| isNodeInCall (self, node) |
|
| removeCall (self, callName, simplify=False) |
|
| removePrints (self, simplify=False) |
|
| removeArraySyntax (self, concurrent=False, useMnhExpand=True, everywhere=True, loopVar=None, reuseLoop=True, funcList=None, updateMemSet=False, updateCopy=False, addAccIndependentCollapse=True) |
|
| inlineContainedSubroutines (self, simplify=False, loopVar=None) |
|
| inline (self, subContained, callStmt, mainScope, simplify=False, loopVar=None) |
|
| setFalseIfStmt (self, flags, simplify=False) |
|
| evalFalseIfStmt (self, nodes, simplify=False) |
|
| checkOpInCall (self, mustRaise=False) |
|
| insertStatement (self, stmt, first) |
|
| removeStmtNode (self, nodes, simplifyVar, simplifyStruct) |
|
| removeConstructNode (self, node, simplifyVar, simplifyStruct) |
|
| removeFromList (self, item, itemPar) |
|
Methods to act on statements
Definition at line 68 of file statements.py.
◆ checkOpInCall()
pyfortool.statements.Statements.checkOpInCall |
( |
|
self, |
|
|
|
mustRaise = False |
|
) |
| |
:param mustRaise: True to raise
Issue a logging.warning if some call arguments are operations
If mustRaise is True, issue a logging.error instead and raise an error
Definition at line 1173 of file statements.py.
◆ createDoConstruct()
pyfortool.statements.Statements.createDoConstruct |
( |
|
loopVariables, |
|
|
|
indent = 0 , |
|
|
|
concurrent = False |
|
) |
| |
|
static |
:param loopVariables: ordered dictionnary with loop variables as key and bounds as values.
Bounds are expressed with a 2-tuple.
Keys must be in the same order as the order used when addressing an
element: if loopVariables.keys is [JI, JK], arrays are
addressed with (JI, JK)
:param indent: current indentation
:param concurrent: if False, output is made of nested 'DO' loops
if True, output is made of a single 'DO CONCURRENT' loop
:return: (inner, outer, extraindent) with
- inner the inner do-construct where statements must be added
- outer the outer do-construct to be inserted somewhere
- extraindent the number of added indentation
(2 if concurrent else 2*len(loopVariables))
Definition at line 1418 of file statements.py.
◆ evalFalseIfStmt()
pyfortool.statements.Statements.evalFalseIfStmt |
( |
|
self, |
|
|
|
nodes, |
|
|
|
simplify = False |
|
) |
| |
Evaluate if-stmt with multiple op-E and remove the nodes if only .FALSE. are present
:param nodes: list of nodes of type op-E to evaluate (containing .FALSE.)
:param simplify: try to simplify code (if if-block is removed, variables used in the
if condition are also checked)
Definition at line 1151 of file statements.py.
◆ inline()
pyfortool.statements.Statements.inline |
( |
|
self, |
|
|
|
subContained, |
|
|
|
callStmt, |
|
|
|
mainScope, |
|
|
|
simplify = False , |
|
|
|
loopVar = None |
|
) |
| |
Inline a subContainted subroutine
Steps :
- update the main code if needed (if statement and/or elemental)
- copy the subContained node
- remove everything before the declarations variables and the variables declarations
- deal with optional argument
- from the callStmt, replace all the arguments by their names
- inline in the main code
- add local variables and use statements to the main code
:param subContained: xml fragment corresponding to the sub: to inline
:param callStmt: the call-stmt to replace
:param mainScope: scope of the main (calling) subroutine
:param simplify: try to simplify code (construct or variables becoming useless)
:param loopVar: None to create new variable for each added DO loop (around ELEMENTAL
subroutine calls)
or a function that return the name of the variable to use for the
loop control.
This function returns a string (name of the variable), or True to create
a new variable, or False to not transform this statement
The functions takes as arguments:
- lower and upper bounds as defined in the declaration statement
- lower and upper bounds as given in the statement
- name of the array
- index of the rank
Definition at line 662 of file statements.py.
◆ inlineContainedSubroutines()
pyfortool.statements.Statements.inlineContainedSubroutines |
( |
|
self, |
|
|
|
simplify = False , |
|
|
|
loopVar = None |
|
) |
| |
Inline all contained subroutines in the main subroutine
Steps :
- Identify contained subroutines
- Look for all CALL statements, check if it is a containted routines; if yes, inline
- Delete the containted routines
:param simplify: try to simplify code (construct or variables becoming useless)
:param loopVar: None to create new variable for each added DO loop (around ELEMENTAL
subroutine calls)
or a function that return the name of the variable to use for the
loop control.
This function returns a string (name of the variable), or True to create
a new variable, or False to not transform this statement
The functions takes as arguments:
- lower and upper bounds as defined in the declaration statement
- lower and upper bounds as given in the statement
- name of the array
- index of the rank
Definition at line 598 of file statements.py.
◆ insertInList()
pyfortool.statements.Statements.insertInList |
( |
|
pos, |
|
|
|
item, |
|
|
|
parent |
|
) |
| |
|
static |
:param pos: insertion position
:param item: item to add to the list
:param parent: the parent of item (the list)
Definition at line 1523 of file statements.py.
◆ insertStatement()
pyfortool.statements.Statements.insertStatement |
( |
|
self, |
|
|
|
stmt, |
|
|
|
first |
|
) |
| |
Insert a statement to be executed first (or last)
:param stmt: statement to insert
:param first: True to insert it in first position, False to insert it in last position
:return: the index of the stmt inserted in scope
Definition at line 1190 of file statements.py.
◆ isNodeInCall()
pyfortool.statements.Statements.isNodeInCall |
( |
|
self, |
|
|
|
node |
|
) |
| |
Return True if node (named-E) is an argument of a called procedure
:param node: node to test
Definition at line 104 of file statements.py.
◆ isNodeInProcedure()
pyfortool.statements.Statements.isNodeInProcedure |
( |
|
self, |
|
|
|
node, |
|
|
|
procList |
|
) |
| |
Return True if node (named-E) is an argument of a procedure listed in procList
:param node: node to test
:param procList: list of procedure names
Definition at line 74 of file statements.py.
◆ removeArraySyntax()
pyfortool.statements.Statements.removeArraySyntax |
( |
|
self, |
|
|
|
concurrent = False , |
|
|
|
useMnhExpand = True , |
|
|
|
everywhere = True , |
|
|
|
loopVar = None , |
|
|
|
reuseLoop = True , |
|
|
|
funcList = None , |
|
|
|
updateMemSet = False , |
|
|
|
updateCopy = False , |
|
|
|
addAccIndependentCollapse = True |
|
) |
| |
Transform array syntax into DO loops
:param concurrent: use 'DO CONCURRENT' instead of simple 'DO' loops
:param useMnhExpand: use the mnh directives to transform the entire bloc in a single loop
:param everywhere: transform all array syntax in DO loops
:param loopVar: None to create new variable for each added DO loop, or
a function that return the name of the variable to use for the loop control.
This function returns a string (name of the variable), or True to create
a new variable, or False to not transform this statement
The functions takes as arguments:
- lower and upper bounds as defined in the declaration statement
- lower and upper bounds as given in the statement
- name of the array
- index of the rank
:param reuseLoop: if True, try to reuse loop created whith everywhere=True
:param funcList: list of entity names that must be recognized as array functions
(in addition to the intrisic ones) to discard from transformation
statements that make use of them. None is equivalent to an empty list.
:param updateMemSet: True to put affectation to constante in DO loops
:param updateCopy: True to put array copy in DO loops
:param addAccIndependentCollapse: True to add !$acc loop independent collapse(X) before
the DO construct
Notes: * With useMnhExpand, the function checks if the coding is conform to what is needed
for the filepp/mnh_expand tool (to not breack compatibility with this tool)
* Arrays are transformed only if ':' are used.
A=A(:) is not transformed at all (or raises an exception if found in a WHERE block)
A(:)=A is wrongly transformed into "DO...; A(J1)=A; ENDDO" and will produce a
compilation error
WHERE(L) X(:)=0. is not transformed at all (unknown behaviour in case
of nested WHERE)
* This function is not compatible with functions that return arrays:
X(1:5)=FUNC(1) will be transformed into "DO J1=1,5; X(J1)=FUNC(1); ENDDO"
x(1:5)=FUNC(X(1:5)) will be transformed into "DO J1=1,5; X(J1)=FUNC(X(J1)); ENDDO"
But intrinsic functions (COUNT, ANY...) are recognised and corresponding statements
are not transformed.
The list of intrinsic array functions can be extended by user functions with the
funcList argument.
Definition at line 153 of file statements.py.
◆ removeCall()
pyfortool.statements.Statements.removeCall |
( |
|
self, |
|
|
|
callName, |
|
|
|
simplify = False |
|
) |
| |
:param callName: name of the subprogram calls to remove.
:param simplify: try to simplify code (if we delete "CALL FOO(X)" and if X not
used else where, we also delete it; or if the call was alone inside
a if-then-endif construct, the construct is also removed, and
variables used in the if condition are also checked...)
:return: number of calls suppressed
Definition at line 126 of file statements.py.
◆ removeConstructNode()
pyfortool.statements.Statements.removeConstructNode |
( |
|
self, |
|
|
|
node, |
|
|
|
simplifyVar, |
|
|
|
simplifyStruct |
|
) |
| |
This function removes a construct node and:
- suppress variable that became useless (if simplifyVar is True)
- suppress outer loop/if if useless (if simplifyStruct is True)
:param node: node representing the statement to remove
:param simplifyVar: try to simplify code (if we delete "CALL FOO(X)" and if X not used
else where, we also delete it; or if the call was alone inside a
if-then-endif construct, with simplifyStruct=True, the construct is also
removed, and variables used in the if condition are also checked...)
:param simplifyStruct: try to simplify code (if we delete "CALL FOO(X)" and if the call was
alone inside a if-then-endif construct, the construct is also
removed, and variables used in the if condition
(with simplifyVar=True) are also checked...)
If a statement is passed, it is suppressed by removeStmtNode
Definition at line 1367 of file statements.py.
◆ removeFromList()
pyfortool.statements.Statements.removeFromList |
( |
|
self, |
|
|
|
item, |
|
|
|
itemPar |
|
) |
| |
:param item: item to remove from list
:param itemPar: the parent of item (the list)
Definition at line 1542 of file statements.py.
◆ removePrints()
pyfortool.statements.Statements.removePrints |
( |
|
self, |
|
|
|
simplify = False |
|
) |
| |
Removes all print statements
:param simplify: try to simplify code (if we delete "print*, X" and if X is not
used else where, we also delete it; or if the print was alone inside
a if-then-endif construct, the construct is also removed, and
variables used in the if condition are also checked...)
Definition at line 142 of file statements.py.
◆ removeStmtNode()
pyfortool.statements.Statements.removeStmtNode |
( |
|
self, |
|
|
|
nodes, |
|
|
|
simplifyVar, |
|
|
|
simplifyStruct |
|
) |
| |
This function removes a statement node and:
- suppress variable that became useless (if simplifyVar is True)
- suppress outer loop/if if useless (if simplifyStruct is True)
:param nodes: node (or list of nodes) to remove
:param simplifyVar: try to simplify code (if we delete "CALL FOO(X)" and if X not used
else where, we also delete it; or if the call was alone inside a
if-then-endif construct, with simplifyStruct=True, the construct is also
removed, and variables used in the if condition are also checked...)
:param simplifyStruct: try to simplify code (if we delete "CALL FOO(X)" and if the call was
alone inside a if-then-endif construct, the construct is also
removed and variables used in the if condition
(with simplifyVar=True) are also checked...)
Definition at line 1235 of file statements.py.
◆ setFalseIfStmt()
pyfortool.statements.Statements.setFalseIfStmt |
( |
|
self, |
|
|
|
flags, |
|
|
|
simplify = False |
|
) |
| |
Set to .FALSE. a given boolean fortran flag before removing the node if simplify is True
:param flags: list of strings of flags to set to .FALSE.
:param simplify: try to simplify code (if the .FALSE. was alone inside a if-then-endif
construct, the construct is removed, and variables used in the if
condition are also checked)
Definition at line 1108 of file statements.py.
The documentation for this class was generated from the following file:
- /home/runner/work/pyfortool/pyfortool/src/pyfortool/statements.py