mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-21 11:53:32 +01:00
Bug in if/else/endif
Version:1.1.43
This commit is contained in:
parent
9b03305f3b
commit
9d35e52984
@ -38,6 +38,8 @@ options['i'] = [ 'init' , 'Initialize current directory', 0 ]
|
|||||||
options['D'] = [ 'define' , 'Define variable', 1 ]
|
options['D'] = [ 'define' , 'Define variable', 1 ]
|
||||||
options['o'] = [ 'checkopt' , 'Show where optimization may be required', 0 ]
|
options['o'] = [ 'checkopt' , 'Show where optimization may be required', 0 ]
|
||||||
options['p'] = [ 'preprocess' , 'Preprocess file', 1 ]
|
options['p'] = [ 'preprocess' , 'Preprocess file', 1 ]
|
||||||
|
options['m'] = [ 'memory' , 'Debug memory info', 0 ]
|
||||||
|
|
||||||
|
|
||||||
class CommandLine(object):
|
class CommandLine(object):
|
||||||
|
|
||||||
|
@ -55,6 +55,15 @@ subroutine irp_enter(irp_where)
|
|||||||
ithread = 0
|
ithread = 0
|
||||||
nthread = 1
|
nthread = 1
|
||||||
$1
|
$1
|
||||||
|
"""
|
||||||
|
if command_line.do_memory:
|
||||||
|
txt+="""
|
||||||
|
if (.not.alloc) then
|
||||||
|
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')'
|
||||||
|
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')'
|
||||||
|
print *, 'Allocating stack_index(',nthread,')'
|
||||||
|
endif"""
|
||||||
|
txt +="""
|
||||||
$2
|
$2
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
@ -252,35 +252,30 @@ def move_variables():
|
|||||||
varlist = []
|
varlist = []
|
||||||
result.append( ([],line) )
|
result.append( ([],line) )
|
||||||
elif type(line) in [ Endif, End_select ]:
|
elif type(line) in [ Endif, End_select ]:
|
||||||
old_ifvars.append(ifvars)
|
old_ifvars.append( list(ifvars) )
|
||||||
old_elsevars.append(elsevars)
|
old_elsevars.append( list(elsevars) )
|
||||||
old_varlist.append(varlist)
|
old_varlist.append( list(varlist) )
|
||||||
varlist = []
|
varlist = []
|
||||||
result.append( ([],line) )
|
result.append( ([],line) )
|
||||||
elif type(line) == Else:
|
elif type(line) == Else:
|
||||||
|
elsevars += list(varlist)
|
||||||
result.append( (varlist,line) )
|
result.append( (varlist,line) )
|
||||||
elsevars = list(varlist)
|
|
||||||
if vars != []:
|
|
||||||
varlist = old_varlist.pop()
|
|
||||||
varlist += vars
|
|
||||||
old_varlist.append(varlist)
|
|
||||||
varlist = []
|
varlist = []
|
||||||
elif type(line) in [ Elseif, Case ]:
|
elif type(line) in [ Elseif, Case ]:
|
||||||
ifvars += varlist
|
ifvars += list(varlist)
|
||||||
result.append( (varlist,line) )
|
result.append( (varlist,line) )
|
||||||
if vars != []:
|
if vars != []:
|
||||||
varlist = old_varlist.pop()
|
varlist = old_varlist.pop()
|
||||||
varlist += vars
|
varlist += vars
|
||||||
old_varlist.append(varlist)
|
old_varlist.append( list(varlist) )
|
||||||
varlist = []
|
varlist = []
|
||||||
elif type(line) in [ If, Select ]:
|
elif type(line) in [ If, Select ]:
|
||||||
ifvars += varlist
|
ifvars += list(varlist)
|
||||||
result.append( (varlist,line) )
|
result.append( (varlist,line) )
|
||||||
vars += filter(lambda x: x in elsevars, ifvars)
|
vars += filter(lambda x: x in elsevars, ifvars)
|
||||||
ifvars = old_ifvars.pop()
|
ifvars = old_ifvars.pop()
|
||||||
elsevars = old_elsevars.pop()
|
elsevars = old_elsevars.pop()
|
||||||
varlist = old_varlist.pop()
|
varlist = old_varlist.pop() + vars
|
||||||
varlist += vars
|
|
||||||
elif type(line) in [ Begin_provider, Subroutine, Function ]:
|
elif type(line) in [ Begin_provider, Subroutine, Function ]:
|
||||||
varlist += vars
|
varlist += vars
|
||||||
result.append( (varlist,line) )
|
result.append( (varlist,line) )
|
||||||
@ -295,6 +290,7 @@ def move_variables():
|
|||||||
varlist += vars
|
varlist += vars
|
||||||
result.append( ([],line) )
|
result.append( ([],line) )
|
||||||
result.reverse()
|
result.reverse()
|
||||||
|
|
||||||
# 2nd pass
|
# 2nd pass
|
||||||
text = result
|
text = result
|
||||||
result = []
|
result = []
|
||||||
@ -448,7 +444,7 @@ check_opt()
|
|||||||
######################################################################
|
######################################################################
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for i in range(len(parsed_text)):
|
for i in range(len(parsed_text)):
|
||||||
if parsed_text[i][0] == 'orbitalJastrow.irp.f':
|
if parsed_text[i][0] == 'properties.irp.f':
|
||||||
print '!-------- %s -----------'%(parsed_text[i][0])
|
print '!-------- %s -----------'%(parsed_text[i][0])
|
||||||
for line in parsed_text[i][1]:
|
for line in parsed_text[i][1]:
|
||||||
print line[1]
|
print line[1]
|
||||||
|
@ -351,10 +351,17 @@ class Variable(object):
|
|||||||
result = [ "!","! >>> FREE %s"%(self.name),
|
result = [ "!","! >>> FREE %s"%(self.name),
|
||||||
" %s_is_built = .False."%(self.same_as) ]
|
" %s_is_built = .False."%(self.same_as) ]
|
||||||
if self.dim != []:
|
if self.dim != []:
|
||||||
result += [ \
|
if command_line.do_memory:
|
||||||
" if (allocated(%s)) then"%(name),
|
result += [ \
|
||||||
" deallocate (%s)"%(name),
|
" if (allocated(%s)) then"%(name),
|
||||||
" endif" ]
|
" deallocate (%s)"%(name),
|
||||||
|
" print *, 'Deallocating %s'"%(name),
|
||||||
|
" endif" ]
|
||||||
|
else:
|
||||||
|
result += [ \
|
||||||
|
" if (allocated(%s)) then"%(name),
|
||||||
|
" deallocate (%s)"%(name),
|
||||||
|
" endif" ]
|
||||||
result.append("! <<< END FREE")
|
result.append("! <<< END FREE")
|
||||||
self._free = result
|
self._free = result
|
||||||
return self._free
|
return self._free
|
||||||
@ -397,13 +404,27 @@ class Variable(object):
|
|||||||
def do_allocate():
|
def do_allocate():
|
||||||
result = " allocate(%s(%s),stat=irp_err)"
|
result = " allocate(%s(%s),stat=irp_err)"
|
||||||
result = result%(name,','.join(self.dim))
|
result = result%(name,','.join(self.dim))
|
||||||
|
if command_line.do_memory:
|
||||||
|
tmp = "\n print *, 'Allocating %s(%s), (',%s,')'"
|
||||||
|
d = ','.join(self.dim)
|
||||||
|
if ":" in d:
|
||||||
|
result += tmp%(name,d,"''")
|
||||||
|
else:
|
||||||
|
result += tmp%(name,d,d)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = [ " if (allocated (%s) ) then"%(name) ]
|
result = [ " if (allocated (%s) ) then"%(name) ]
|
||||||
result += dimensions_OK()
|
result += dimensions_OK()
|
||||||
result += [\
|
result += [\
|
||||||
" if (.not.irp_dimensions_OK) then",
|
" if (.not.irp_dimensions_OK) then",
|
||||||
" deallocate(%s)"%(name) ]
|
" deallocate(%s,stat=irp_err)"%(name),
|
||||||
|
" if (irp_err /= 0) then",
|
||||||
|
" print *, irp_here//': Deallocation failed: %s'"%(name),
|
||||||
|
do_size(),
|
||||||
|
" endif"]
|
||||||
|
if command_line.do_memory:
|
||||||
|
result += [\
|
||||||
|
" print *, 'Deallocating %s'"%(name) ]
|
||||||
result.append(check_dimensions())
|
result.append(check_dimensions())
|
||||||
result.append(do_allocate())
|
result.append(do_allocate())
|
||||||
result += [\
|
result += [\
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.1.42"
|
version = "1.1.43"
|
||||||
|
Loading…
Reference in New Issue
Block a user