Skip to content

Commit

Permalink
Cosmetics to pass the flake8 test
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienRietteMTO committed Dec 19, 2024
1 parent ea01408 commit 1ba3e6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
39 changes: 21 additions & 18 deletions src/pyfortool/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,12 @@ def addMPPDB_CHECKS(self, printsMode=False):
"""
def addPrints_statement(var, typeofPrints='minmax'):
ifBeg, ifEnd = '', ''
if var['as']: # If array
if typeofPrints=='minmax':
strMSG = 'MINMAX ' + var['n'] + ' = \"' + ',MINVAL('+var['n']+'), MAXVAL('+var['n']+')'
elif typeofPrints=='shape':
strMSG = 'SHAPE ' + var['n'] + ' = \"' + ',SHAPE('+var['n']+')'
if var['as']: # If array
varName = var['n']
if typeofPrints == 'minmax':
strMSG = f'MINMAX {varName} = \",MINVAL({varName}), MAXVAL({varName})'
elif typeofPrints == 'shape':
strMSG = f'SHAPE {varName} = \",SHAPE({varName})'
else:
raise PYFTError('typeofPrints is either minmax or shape in addPrints_statement')
else:
Expand All @@ -352,7 +353,7 @@ def addPrints_statement(var, typeofPrints='minmax'):
ifBeg = ifBeg + 'IF (PRESENT(' + var['n'] + ')) THEN\n '
ifEnd = ifEnd + '\nEND IF'
return createExpr(ifBeg + "print*,\"" + strMSG + ifEnd)[0]

def addMPPDB_CHECK_statement(var, subRoutineName, strMSG='beg:'):
ifBeg, ifEnd, addD, addLastDim, addSecondDimType = '', '', '', '', ''
# Test if the variable is declared with the PHYEX D% structure,
Expand Down Expand Up @@ -442,10 +443,12 @@ def addMPPDB_CHECK_statement(var, subRoutineName, strMSG='beg:'):
for i, var in enumerate(arraysIn):
if not printsMode:
ifMPPDB.insert(2 + i, addMPPDB_CHECK_statement(var, subRoutineName,
strMSG='beg:'))
strMSG='beg:'))
else:
ifMPPDB.insert(2 + i, addPrints_statement(var, typeofPrints='minmax'))
ifMPPDB.insert(3 + i, addPrints_statement(var, typeofPrints='shape'))
ifMPPDB.insert(2 + i, addPrints_statement(var,
typeofPrints='minmax'))
ifMPPDB.insert(3 + i, addPrints_statement(var,
typeofPrints='shape'))

# Variables INOUT
if len(arraysInOut) > 0:
Expand All @@ -458,12 +461,11 @@ def addMPPDB_CHECK_statement(var, subRoutineName, strMSG='beg:'):
for i, var in enumerate(arraysInOut):
if not printsMode:
ifMPPDB.insert(len(arraysIn) + shiftLineNumber + 1 + i,
addMPPDB_CHECK_statement(var, subRoutineName,
strMSG='beg:'))
addMPPDB_CHECK_statement(var, subRoutineName,
strMSG='beg:'))
else:
ifMPPDB.insert(len(arraysIn) + shiftLineNumber + 1 + i,
addPrints_statement(var, typeofPrints='minmax'))

addPrints_statement(var, typeofPrints='minmax'))

# Add the new IN and INOUT block
scope.insertStatement(scope.indent(ifMPPDBinit), first=True)
Expand All @@ -482,9 +484,10 @@ def addMPPDB_CHECK_statement(var, subRoutineName, strMSG='beg:'):
for i, var in enumerate(arraysInOut):
if not printsMode:
ifMPPDB.insert(2 + i, addMPPDB_CHECK_statement(var, subRoutineName,
strMSG='end:'))
strMSG='end:'))
else:
ifMPPDB.insert(2 + i, addPrints_statement(var, typeofPrints='minmax'))
ifMPPDB.insert(2 + i, addPrints_statement(var,
typeofPrints='minmax'))

# Variables OUT
if len(arraysOut) > 0:
Expand All @@ -496,11 +499,11 @@ def addMPPDB_CHECK_statement(var, subRoutineName, strMSG='beg:'):
for i, var in enumerate(arraysOut):
if not printsMode:
ifMPPDB.insert(len(arraysInOut) + shiftLineNumber + 1 + i,
addMPPDB_CHECK_statement(var, subRoutineName,
strMSG='end:'))
addMPPDB_CHECK_statement(var, subRoutineName,
strMSG='end:'))
else:
ifMPPDB.insert(len(arraysInOut) + shiftLineNumber + 1 + i,
addPrints_statement(var, typeofPrints='minmax'))
addPrints_statement(var, typeofPrints='minmax'))

# Add the new INOUT and OUT block
scope.insertStatement(scope.indent(ifMPPDBend), first=False)
Expand Down
3 changes: 2 additions & 1 deletion src/pyfortool/scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ def updateParserApplications(parser):
help='Add MPPDB_CHEKS bit-repro checking routines of MesoNH for ' +
'all in and inout arrays in subroutines')
gApplications.add_argument('--addPrints', default=False, action='store_true',
help='Add Prints of min/maxval and shape of all in, out, inout arguments of all scopes')
help='Add Prints of min/maxval and shape of all in, out, inout ' +
'arguments of all scopes')
gApplications.add_argument('--shumanFUNCtoCALL', default=False, action='store_true',
help='Transform shuman functions to call statements')
gApplications.add_argument('--mathFunctoBRFunc', default=False, action='store_true',
Expand Down

0 comments on commit 1ba3e6b

Please sign in to comment.