mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-09-02 01:33:42 +02: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['o'] = [ 'checkopt' , 'Show where optimization may be required', 0 ]
|
||||
options['p'] = [ 'preprocess' , 'Preprocess file', 1 ]
|
||||
options['m'] = [ 'memory' , 'Debug memory info', 0 ]
|
||||
|
||||
|
||||
class CommandLine(object):
|
||||
|
||||
|
@ -55,6 +55,15 @@ subroutine irp_enter(irp_where)
|
||||
ithread = 0
|
||||
nthread = 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
|
||||
end subroutine
|
||||
|
||||
|
@ -252,35 +252,30 @@ def move_variables():
|
||||
varlist = []
|
||||
result.append( ([],line) )
|
||||
elif type(line) in [ Endif, End_select ]:
|
||||
old_ifvars.append(ifvars)
|
||||
old_elsevars.append(elsevars)
|
||||
old_varlist.append(varlist)
|
||||
old_ifvars.append( list(ifvars) )
|
||||
old_elsevars.append( list(elsevars) )
|
||||
old_varlist.append( list(varlist) )
|
||||
varlist = []
|
||||
result.append( ([],line) )
|
||||
elif type(line) == Else:
|
||||
elsevars += list(varlist)
|
||||
result.append( (varlist,line) )
|
||||
elsevars = list(varlist)
|
||||
if vars != []:
|
||||
varlist = old_varlist.pop()
|
||||
varlist += vars
|
||||
old_varlist.append(varlist)
|
||||
varlist = []
|
||||
elif type(line) in [ Elseif, Case ]:
|
||||
ifvars += varlist
|
||||
ifvars += list(varlist)
|
||||
result.append( (varlist,line) )
|
||||
if vars != []:
|
||||
varlist = old_varlist.pop()
|
||||
varlist += vars
|
||||
old_varlist.append(varlist)
|
||||
old_varlist.append( list(varlist) )
|
||||
varlist = []
|
||||
elif type(line) in [ If, Select ]:
|
||||
ifvars += varlist
|
||||
ifvars += list(varlist)
|
||||
result.append( (varlist,line) )
|
||||
vars += filter(lambda x: x in elsevars, ifvars)
|
||||
ifvars = old_ifvars.pop()
|
||||
elsevars = old_elsevars.pop()
|
||||
varlist = old_varlist.pop()
|
||||
varlist += vars
|
||||
varlist = old_varlist.pop() + vars
|
||||
elif type(line) in [ Begin_provider, Subroutine, Function ]:
|
||||
varlist += vars
|
||||
result.append( (varlist,line) )
|
||||
@ -295,6 +290,7 @@ def move_variables():
|
||||
varlist += vars
|
||||
result.append( ([],line) )
|
||||
result.reverse()
|
||||
|
||||
# 2nd pass
|
||||
text = result
|
||||
result = []
|
||||
@ -448,7 +444,7 @@ check_opt()
|
||||
######################################################################
|
||||
if __name__ == '__main__':
|
||||
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])
|
||||
for line in parsed_text[i][1]:
|
||||
print line[1]
|
||||
|
@ -351,6 +351,13 @@ class Variable(object):
|
||||
result = [ "!","! >>> FREE %s"%(self.name),
|
||||
" %s_is_built = .False."%(self.same_as) ]
|
||||
if self.dim != []:
|
||||
if command_line.do_memory:
|
||||
result += [ \
|
||||
" if (allocated(%s)) then"%(name),
|
||||
" deallocate (%s)"%(name),
|
||||
" print *, 'Deallocating %s'"%(name),
|
||||
" endif" ]
|
||||
else:
|
||||
result += [ \
|
||||
" if (allocated(%s)) then"%(name),
|
||||
" deallocate (%s)"%(name),
|
||||
@ -397,13 +404,27 @@ class Variable(object):
|
||||
def do_allocate():
|
||||
result = " allocate(%s(%s),stat=irp_err)"
|
||||
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
|
||||
|
||||
result = [ " if (allocated (%s) ) then"%(name) ]
|
||||
result += dimensions_OK()
|
||||
result += [\
|
||||
" 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(do_allocate())
|
||||
result += [\
|
||||
|
@ -1 +1 @@
|
||||
version = "1.1.42"
|
||||
version = "1.1.43"
|
||||
|
Loading…
Reference in New Issue
Block a user