Skip to content

Commit

Permalink
python3 fixes for flowercase and fdeclarations
Browse files Browse the repository at this point in the history
  • Loading branch information
ylikx committed Feb 7, 2017
1 parent 765e27a commit 0ae8f47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
23 changes: 12 additions & 11 deletions fdeclarations/fdeclarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@
"""

from __future__ import print_function

import re
import sys

TYPEKEYS = ['integer', 'logical', 'real', 'complex',
'double precision', 'double complex']
'double precision', 'double complex', 'character', 'doubleprecision', 'doublecomplex']

#m = re.search(r'(subroutine|function)(.*?)\((.*?)\)', s)

Expand Down Expand Up @@ -98,7 +100,6 @@ def getDeclString(self):
string += " =" + self.initialiser
return string

# TODO
class FortranSubroutineHeader:
def __init__(name, arglist):
self.name = ''
Expand Down Expand Up @@ -298,16 +299,16 @@ def printWrapperCode(subname, arglist, varlist):
#for entry in arglist:
# print "!> @param " + entry
print("subroutine " + subname + "_wrapper(" + ','.join(arglist) + ')')
print
print()
print(" implicit none")
print
print()
# parameters first
print( " ! Parameters")
for entry in varlist:
if not entry.is_argument and entry.is_parameter:
print (" " + entry.getDeclString())
# print scalar arguments
print
print()
print( " ! Arguments")
for entry in varlist:
if entry.is_argument:
Expand All @@ -318,15 +319,15 @@ def printWrapperCode(subname, arglist, varlist):
#for entry in varlist:
# if entry.is_argument and entry.dim:
# print " " + entry.getDeclString()
print
print " ! Former local variables of " + subname
print()
print(" ! Former local variables of " + subname)
for entry in varlist:
if not entry.is_argument:
print " ! " + entry.getDeclString()
print(" ! " + entry.getDeclString())

print
print()
print (" call " + subname + "(" + ','.join(arglist) + ')')
print
print()
print("end subroutine")

if __name__ == "__main__":
Expand All @@ -348,7 +349,7 @@ class NoArgList:
break

if not args:
print "ERROR: no subroutine header found!"
print("ERROR: no subroutine header found!")
raise NoArgList

vardict = {}
Expand Down
6 changes: 4 additions & 2 deletions flowercase/flowercase.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# ylikx.0 at gmail
# https://www.github.com/ylikx/

from __future__ import print_function

import sys

infile = open(sys.argv[1], 'r')
Expand All @@ -48,7 +50,7 @@
stringmode = False

for character in line:
if not character.isalnum() and character<>'_':
if not character.isalnum() and character != '_':

if not stringmode and not commentmode:
if word.isupper(): # means: do not convert mixed case words
Expand All @@ -71,6 +73,6 @@
else:
word += character

print line_new,
print(line_new, end="")

infile.close()

0 comments on commit 0ae8f47

Please sign in to comment.