mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-22 04:13:33 +01:00
Merge branch 'master' of ssh://irpf90.git.sourceforge.net/gitroot/irpf90/irpf90
Conflicts: src/makefile.py src/parsed_text.py src/util.py Version:1.1.51
This commit is contained in:
commit
969e31490b
@ -32,5 +32,11 @@ wd = os.path.abspath(os.path.dirname(__file__))
|
|||||||
sys.path.insert(0,(wd+"/../src/"))
|
sys.path.insert(0,(wd+"/../src/"))
|
||||||
sys.path.insert(0,(wd+"/../share/irpf90/src/"))
|
sys.path.insert(0,(wd+"/../share/irpf90/src/"))
|
||||||
|
|
||||||
|
debug = int(os.getenv("IRP_DEBUG",0))
|
||||||
|
if debug == 0:
|
||||||
import irpf90
|
import irpf90
|
||||||
irpf90.main()
|
irpf90.main()
|
||||||
|
else:
|
||||||
|
import profile
|
||||||
|
print "Profiling irpf90"
|
||||||
|
profile.run('import irpf90 ; irpf90.main()')
|
||||||
|
@ -54,9 +54,11 @@ subroutine irp_enter(irp_where)
|
|||||||
integer :: nthread
|
integer :: nthread
|
||||||
character*(*) :: irp_where
|
character*(*) :: irp_where
|
||||||
$OMP_DECL
|
$OMP_DECL
|
||||||
|
!$OMP CRITICAL
|
||||||
ithread = $OMP_GET_THREAD_NUM
|
ithread = $OMP_GET_THREAD_NUM
|
||||||
nthread = $OMP_GET_NUM_THREADS
|
nthread = $OMP_GET_NUM_THREADS
|
||||||
$1
|
$1
|
||||||
|
!$OMP END CRITICAL
|
||||||
"""
|
"""
|
||||||
if command_line.do_memory:
|
if command_line.do_memory:
|
||||||
txt+="""
|
txt+="""
|
||||||
@ -75,9 +77,11 @@ subroutine irp_leave (irp_where)
|
|||||||
integer :: ithread
|
integer :: ithread
|
||||||
double precision :: cpu
|
double precision :: cpu
|
||||||
$OMP_DECL
|
$OMP_DECL
|
||||||
|
!$OMP CRITICAL
|
||||||
ithread = $OMP_GET_THREAD_NUM
|
ithread = $OMP_GET_THREAD_NUM
|
||||||
$3
|
$3
|
||||||
$4
|
$4
|
||||||
|
!$OMP END CRITICAL
|
||||||
end subroutine
|
end subroutine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -97,14 +101,12 @@ end subroutine
|
|||||||
# $1
|
# $1
|
||||||
if do_assert or do_debug:
|
if do_assert or do_debug:
|
||||||
txt = txt.replace("$1","""
|
txt = txt.replace("$1","""
|
||||||
!$OMP CRITICAL
|
|
||||||
if (.not.alloc) then
|
if (.not.alloc) then
|
||||||
allocate(irp_stack(STACKMAX,nthread))
|
allocate(irp_stack(STACKMAX,nthread+1))
|
||||||
allocate(irp_cpu(STACKMAX,nthread))
|
allocate(irp_cpu(STACKMAX,nthread+1))
|
||||||
allocate(stack_index(nthread))
|
allocate(stack_index(nthread+1))
|
||||||
alloc = .True.
|
alloc = .True.
|
||||||
endif
|
endif
|
||||||
!$OMP END CRITICAL
|
|
||||||
stack_index(ithread+1) = stack_index(ithread+1)+1
|
stack_index(ithread+1) = stack_index(ithread+1)+1
|
||||||
irp_stack(stack_index(ithread+1),ithread+1) = irp_where""")
|
irp_stack(stack_index(ithread+1),ithread+1) = irp_where""")
|
||||||
if command_line.do_memory:
|
if command_line.do_memory:
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
# 31062 Toulouse Cedex 4
|
# 31062 Toulouse Cedex 4
|
||||||
# scemama@irsamc.ups-tlse.fr
|
# scemama@irsamc.ups-tlse.fr
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.setcheckinterval(1000)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from command_line import command_line
|
from command_line import command_line
|
||||||
|
@ -33,6 +33,7 @@ class Line(object):
|
|||||||
def __init__(self,i,text,filename):
|
def __init__(self,i,text,filename):
|
||||||
self.i = i
|
self.i = i
|
||||||
self.text = text
|
self.text = text
|
||||||
|
self.lower = text.lower()
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self._lower = None
|
self._lower = None
|
||||||
|
|
||||||
|
@ -152,4 +152,3 @@ def run():
|
|||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -38,29 +38,32 @@ stuple = map(lambda s: (s, subroutines[s].regexp), subroutines.keys())
|
|||||||
stuple = filter(lambda s: subroutines[s[0]].is_function, stuple)
|
stuple = filter(lambda s: subroutines[s[0]].is_function, stuple)
|
||||||
re_string_sub = regexps.re_string.sub
|
re_string_sub = regexps.re_string.sub
|
||||||
|
|
||||||
|
regexps_re_string_sub = regexps.re_string.sub
|
||||||
def find_variables_in_line(line):
|
def find_variables_in_line(line):
|
||||||
assert isinstance(line,Line)
|
assert isinstance(line,Line)
|
||||||
result = []
|
result = []
|
||||||
sub_done = False
|
sub_done = False
|
||||||
buffer = line.text_lower
|
buffer = line.text_lower
|
||||||
|
ap = result.append
|
||||||
for v,same_as,regexp in vtuple:
|
for v,same_as,regexp in vtuple:
|
||||||
if v in buffer:
|
if v in buffer:
|
||||||
if not sub_done:
|
if not sub_done:
|
||||||
buffer = re_string_sub('',buffer)
|
buffer = regexps_re_string_sub('',buffer)
|
||||||
sub_done = True
|
sub_done = True
|
||||||
if regexp.search(buffer) is not None:
|
if regexp.search(buffer) is not None:
|
||||||
result.append(same_as)
|
ap(same_as)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def find_funcs_in_line(line):
|
def find_funcs_in_line(line):
|
||||||
assert isinstance(line,Line)
|
assert isinstance(line,Line)
|
||||||
result = []
|
result = []
|
||||||
|
append = result.append
|
||||||
sub_done = False
|
sub_done = False
|
||||||
buffer = line.text_lower
|
buffer = line.text_lower
|
||||||
for s,regexp in stuple:
|
for s,regexp in stuple:
|
||||||
if s in buffer:
|
if s in buffer:
|
||||||
if regexp.search(buffer) is not None:
|
if regexp.search(buffer) is not None:
|
||||||
result.append(s)
|
append(s)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@ -90,6 +93,7 @@ def get_parsed_text():
|
|||||||
def func(filename, text):
|
def func(filename, text):
|
||||||
varlist = []
|
varlist = []
|
||||||
result = []
|
result = []
|
||||||
|
append = result.append
|
||||||
for line in filter(
|
for line in filter(
|
||||||
lambda x: type(x) not in [ Doc, Begin_doc, End_doc ],
|
lambda x: type(x) not in [ Doc, Begin_doc, End_doc ],
|
||||||
text):
|
text):
|
||||||
@ -110,28 +114,28 @@ def get_parsed_text():
|
|||||||
Function,
|
Function,
|
||||||
End,
|
End,
|
||||||
]:
|
]:
|
||||||
result.append( ([],line) )
|
append( ([],line) )
|
||||||
elif isinstance(line,End_provider):
|
elif isinstance(line,End_provider):
|
||||||
varlist = []
|
varlist = []
|
||||||
result.append( ([],line) )
|
append( ([],line) )
|
||||||
elif isinstance(line,Provide):
|
elif isinstance(line,Provide):
|
||||||
l = line.text_lower.split()[1:]
|
l = line.text_lower.split()[1:]
|
||||||
l = filter(lambda x: x not in varlist, l)
|
l = filter(lambda x: x not in varlist, l)
|
||||||
for v in l:
|
for v in l:
|
||||||
if v not in variables.keys():
|
if v not in variables.keys():
|
||||||
error.fail(line,"Variable %s is unknown"%(v))
|
error.fail(line,"Variable %s is unknown"%(v))
|
||||||
result.append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
elif isinstance(line,Call):
|
elif isinstance(line,Call):
|
||||||
l = find_variables_in_line(line)
|
l = find_variables_in_line(line)
|
||||||
l = filter(lambda x: x not in varlist, l)
|
l = filter(lambda x: x not in varlist, l)
|
||||||
sub = find_subroutine_in_line(line)
|
sub = find_subroutine_in_line(line)
|
||||||
if sub not in subroutines:
|
if sub not in subroutines:
|
||||||
t = Simple_line
|
t = Simple_line
|
||||||
result.append( (l,Simple_line(line.i,line.text,line.filename)) )
|
append( (l,Simple_line(line.i,line.text,line.filename)) )
|
||||||
else:
|
else:
|
||||||
result.append( (l,line) )
|
append( (l,line) )
|
||||||
if subroutines[sub].touches != []:
|
if subroutines[sub].touches != []:
|
||||||
result.append( ([],Provide_all(line.i,"",line.filename)) )
|
append( ([],Provide_all(line.i,"",line.filename)) )
|
||||||
elif isinstance(line,Free):
|
elif isinstance(line,Free):
|
||||||
vars = line.text_lower.split()
|
vars = line.text_lower.split()
|
||||||
if len(vars) < 2:
|
if len(vars) < 2:
|
||||||
@ -139,7 +143,7 @@ def get_parsed_text():
|
|||||||
vars = vars[1:]
|
vars = vars[1:]
|
||||||
for v in vars:
|
for v in vars:
|
||||||
variables[v].is_freed = True
|
variables[v].is_freed = True
|
||||||
result.append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
use = map(lambda x: " use %s"%(variables[x].fmodule),vars)
|
use = map(lambda x: " use %s"%(variables[x].fmodule),vars)
|
||||||
for var in vars:
|
for var in vars:
|
||||||
result += map(lambda x: ([],Use(line.i,x,line.filename)),
|
result += map(lambda x: ([],Use(line.i,x,line.filename)),
|
||||||
@ -148,10 +152,10 @@ def get_parsed_text():
|
|||||||
variables[var].free)
|
variables[var].free)
|
||||||
elif isinstance(line,Irp_read):
|
elif isinstance(line,Irp_read):
|
||||||
variables[line.filename]._is_read = True
|
variables[line.filename]._is_read = True
|
||||||
result.append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
elif isinstance(line,Irp_write):
|
elif isinstance(line,Irp_write):
|
||||||
variables[line.filename]._is_written = True
|
variables[line.filename]._is_written = True
|
||||||
result.append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
elif isinstance(line,Touch):
|
elif isinstance(line,Touch):
|
||||||
vars = line.text_lower.split()
|
vars = line.text_lower.split()
|
||||||
if len(vars) < 2:
|
if len(vars) < 2:
|
||||||
@ -197,7 +201,7 @@ def get_parsed_text():
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
print v, variables[v].same_as
|
print v, variables[v].same_as
|
||||||
raise
|
raise
|
||||||
result.append( (variable_list,line) )
|
append( (variable_list,line) )
|
||||||
else:
|
else:
|
||||||
l = find_variables_in_line(line)
|
l = find_variables_in_line(line)
|
||||||
l = filter(lambda x: x not in varlist, l)
|
l = filter(lambda x: x not in varlist, l)
|
||||||
@ -210,7 +214,6 @@ def get_parsed_text():
|
|||||||
#return main_result
|
#return main_result
|
||||||
return parallel_loop(func,preprocessed_text)
|
return parallel_loop(func,preprocessed_text)
|
||||||
|
|
||||||
|
|
||||||
parsed_text = get_parsed_text()
|
parsed_text = get_parsed_text()
|
||||||
|
|
||||||
|
|
||||||
@ -252,6 +255,7 @@ def move_variables():
|
|||||||
|
|
||||||
def func(filename, text):
|
def func(filename, text):
|
||||||
result = []
|
result = []
|
||||||
|
append = result.append
|
||||||
# 1st pass
|
# 1st pass
|
||||||
varlist = []
|
varlist = []
|
||||||
ifvars = []
|
ifvars = []
|
||||||
@ -264,20 +268,20 @@ def move_variables():
|
|||||||
for vars,line in revtext:
|
for vars,line in revtext:
|
||||||
if type(line) in [ End_provider,End ]:
|
if type(line) in [ End_provider,End ]:
|
||||||
varlist = []
|
varlist = []
|
||||||
result.append( ([],line) )
|
append( ([],line) )
|
||||||
elif type(line) in [ Endif, End_select ]:
|
elif type(line) in [ Endif, End_select ]:
|
||||||
old_ifvars.append( list(ifvars) )
|
old_ifvars.append( list(ifvars) )
|
||||||
old_elsevars.append( list(elsevars) )
|
old_elsevars.append( list(elsevars) )
|
||||||
old_varlist.append( list(varlist) )
|
old_varlist.append( list(varlist) )
|
||||||
varlist = []
|
varlist = []
|
||||||
result.append( ([],line) )
|
append( ([],line) )
|
||||||
elif type(line) == Else:
|
elif type(line) == Else:
|
||||||
elsevars += list(varlist)
|
elsevars += list(varlist)
|
||||||
result.append( (varlist,line) )
|
append( (varlist,line) )
|
||||||
varlist = []
|
varlist = []
|
||||||
elif type(line) in [ Elseif, Case ]:
|
elif type(line) in [ Elseif, Case ]:
|
||||||
ifvars += list(varlist)
|
ifvars += list(varlist)
|
||||||
result.append( (varlist,line) )
|
append( (varlist,line) )
|
||||||
if vars != []:
|
if vars != []:
|
||||||
varlist = old_varlist.pop()
|
varlist = old_varlist.pop()
|
||||||
varlist += vars
|
varlist += vars
|
||||||
@ -285,29 +289,30 @@ def move_variables():
|
|||||||
varlist = []
|
varlist = []
|
||||||
elif type(line) in [ If, Select ]:
|
elif type(line) in [ If, Select ]:
|
||||||
ifvars += list(varlist)
|
ifvars += list(varlist)
|
||||||
result.append( (varlist,line) )
|
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() + vars
|
varlist = old_varlist.pop() + 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) )
|
append( (varlist,line) )
|
||||||
if old_varlist != [] \
|
if old_varlist != [] \
|
||||||
or old_ifvars != [] \
|
or old_ifvars != [] \
|
||||||
or old_elsevars != []:
|
or old_elsevars != []:
|
||||||
error.fail(line,"End if missing")
|
error.fail(line,"End if missing")
|
||||||
varlist = []
|
varlist = []
|
||||||
elif isinstance(line,Provide_all):
|
elif isinstance(line,Provide_all):
|
||||||
result.append( (vars,line) )
|
append( (vars,line) )
|
||||||
else:
|
else:
|
||||||
varlist += vars
|
varlist += vars
|
||||||
result.append( ([],line) )
|
append( ([],line) )
|
||||||
result.reverse()
|
result.reverse()
|
||||||
|
|
||||||
# 2nd pass
|
# 2nd pass
|
||||||
text = result
|
text = result
|
||||||
result = []
|
result = []
|
||||||
|
append = result.append
|
||||||
old_varlist = []
|
old_varlist = []
|
||||||
varlist = []
|
varlist = []
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
@ -368,11 +373,12 @@ def add_subroutine_needs():
|
|||||||
main_result = []
|
main_result = []
|
||||||
for filename, text in parsed_text:
|
for filename, text in parsed_text:
|
||||||
result = []
|
result = []
|
||||||
|
append = result.append
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if isinstance(line,Call):
|
if isinstance(line,Call):
|
||||||
subname = find_subname(line)
|
subname = find_subname(line)
|
||||||
vars = subroutines[subname].to_provide
|
vars = subroutines[subname].to_provide
|
||||||
result.append( (vars,line) )
|
append( (vars,line) )
|
||||||
main_result.append( (filename, result) )
|
main_result.append( (filename, result) )
|
||||||
return main_result
|
return main_result
|
||||||
|
|
||||||
|
@ -538,12 +538,12 @@ def irp_simple_statements(text):
|
|||||||
|
|
||||||
def process_begin_provider(line):
|
def process_begin_provider(line):
|
||||||
assert isinstance(line,Begin_provider)
|
assert isinstance(line,Begin_provider)
|
||||||
buffer = line.text.replace('['," ")
|
buffer = line.lower.replace('['," ")
|
||||||
buffer = buffer.replace(']',"")
|
buffer = buffer.replace(']',"")
|
||||||
buffer = buffer.split(',')
|
buffer = buffer.split(',')
|
||||||
if len(buffer) < 2:
|
if len(buffer) < 2:
|
||||||
error.fail(line,"Error in Begin_provider statement")
|
error.fail(line,"Error in Begin_provider statement")
|
||||||
varname = buffer[1].strip().lower()
|
varname = buffer[1].strip()
|
||||||
length = len(varname)
|
length = len(varname)
|
||||||
i = line.i
|
i = line.i
|
||||||
f = line.filename
|
f = line.filename
|
||||||
@ -557,12 +557,12 @@ def irp_simple_statements(text):
|
|||||||
|
|
||||||
def process_cont_provider(line):
|
def process_cont_provider(line):
|
||||||
assert isinstance(line,Cont_provider)
|
assert isinstance(line,Cont_provider)
|
||||||
buffer = line.text.replace('['," ")
|
buffer = line.lower.replace('['," ")
|
||||||
buffer = buffer.replace(']',"")
|
buffer = buffer.replace(']',"")
|
||||||
buffer = buffer.split(',')
|
buffer = buffer.split(',')
|
||||||
if len(buffer) < 2:
|
if len(buffer) < 2:
|
||||||
error.fail(line,"Error in Cont_provider statement")
|
error.fail(line,"Error in Cont_provider statement")
|
||||||
varname = buffer[1].strip().lower()
|
varname = buffer[1].strip()
|
||||||
i = line.i
|
i = line.i
|
||||||
f = line.filename
|
f = line.filename
|
||||||
return [ Cont_provider(i,line.text,(f,varname)) ]
|
return [ Cont_provider(i,line.text,(f,varname)) ]
|
||||||
@ -599,7 +599,7 @@ def irp_simple_statements(text):
|
|||||||
|
|
||||||
def process_program(line):
|
def process_program(line):
|
||||||
assert isinstance(line,Program)
|
assert isinstance(line,Program)
|
||||||
program_name = line.text.split()[1].lower()
|
program_name = line.lower.split()[1]
|
||||||
result = [ Program(0,"",program_name) ] + \
|
result = [ Program(0,"",program_name) ] + \
|
||||||
process_subroutine( Subroutine(line.i,"subroutine %s"%(program_name,),line.filename) )
|
process_subroutine( Subroutine(line.i,"subroutine %s"%(program_name,),line.filename) )
|
||||||
return result
|
return result
|
||||||
@ -691,7 +691,7 @@ endif'''
|
|||||||
result = []
|
result = []
|
||||||
for line in text:
|
for line in text:
|
||||||
if isinstance(line,If):
|
if isinstance(line,If):
|
||||||
if line.text.lower().endswith("then"):
|
if line.lower.endswith("then"):
|
||||||
result.append(line)
|
result.append(line)
|
||||||
else:
|
else:
|
||||||
buffer = line.text
|
buffer = line.text
|
||||||
|
@ -49,7 +49,7 @@ class Sub(object):
|
|||||||
############################################################
|
############################################################
|
||||||
def is_function(self):
|
def is_function(self):
|
||||||
if '_is_function' not in self.__dict__:
|
if '_is_function' not in self.__dict__:
|
||||||
self._is_function = "function" in self.line.text.lower()
|
self._is_function = "function" in self.line.lower
|
||||||
return self._is_function
|
return self._is_function
|
||||||
is_function = property(is_function)
|
is_function = property(is_function)
|
||||||
|
|
||||||
|
@ -121,10 +121,11 @@ class Variable(object):
|
|||||||
def others(self):
|
def others(self):
|
||||||
if '_others' not in self.__dict__:
|
if '_others' not in self.__dict__:
|
||||||
result = []
|
result = []
|
||||||
|
append = result.append
|
||||||
f = lambda l: type(l) in [Begin_provider, Cont_provider]
|
f = lambda l: type(l) in [Begin_provider, Cont_provider]
|
||||||
lines = filter(f, self.text)
|
lines = filter(f, self.text)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
result.append(line.filename[1])
|
append(line.filename[1])
|
||||||
result.remove(self.name)
|
result.remove(self.name)
|
||||||
self._others = result
|
self._others = result
|
||||||
return self._others
|
return self._others
|
||||||
|
@ -66,13 +66,14 @@ def call_provides(vars,opt=False):
|
|||||||
all_children = flatten( map(lambda x: variables[x].children, vars ))
|
all_children = flatten( map(lambda x: variables[x].children, vars ))
|
||||||
vars = filter(lambda x: x not in all_children,vars)
|
vars = filter(lambda x: x not in all_children,vars)
|
||||||
def fun(x):
|
def fun(x):
|
||||||
if command_line.do_openmp:
|
|
||||||
result = [ "!$OMP TASK" ]
|
|
||||||
else:
|
|
||||||
result = []
|
result = []
|
||||||
|
if command_line.do_openmp:
|
||||||
|
result += [ "!$OMP TASK" ]
|
||||||
|
result += [ \
|
||||||
|
" if (.not.%s_is_built) then"%(x) ]
|
||||||
|
result += [ \
|
||||||
|
" call provide_%s"%(x) ]
|
||||||
result += [ \
|
result += [ \
|
||||||
" if (.not.%s_is_built) then"%(x),
|
|
||||||
" call provide_%s"%(x),
|
|
||||||
" endif" ]
|
" endif" ]
|
||||||
if command_line.do_openmp:
|
if command_line.do_openmp:
|
||||||
result += [ "!$OMP END TASK" ]
|
result += [ "!$OMP END TASK" ]
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.1.50"
|
version = "1.1.51"
|
||||||
|
Loading…
Reference in New Issue
Block a user