10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-11-09 07:33:43 +01:00

Merge branch 'master' of ssh://irpf90.git.sourceforge.net/gitroot/irpf90/irpf90

This commit is contained in:
Anthony Scemama 2011-05-20 18:16:28 +02:00
commit ddf7ddc4d0
10 changed files with 69 additions and 36 deletions

View File

@ -102,7 +102,7 @@ Options:
def opts(self): def opts(self):
if self._opts is None: if self._opts is None:
optlist = ["",[]] optlist = ["",[]]
for o in options.keys(): for o in options:
b = [o]+options[o] b = [o]+options[o]
if b[3] == 1: if b[3] == 1:
b[0] = b[0]+":" b[0] = b[0]+":"
@ -132,7 +132,7 @@ def do_$LONG(self):
return self._do_$LONG return self._do_$LONG
do_$LONG = property(fget=do_$LONG) do_$LONG = property(fget=do_$LONG)
""" """
for short in options.keys(): for short in options:
long = options[short][0] long = options[short][0]
exec t.replace("$LONG",long).replace("$SHORT",short) exec t.replace("$LONG",long).replace("$SHORT",short)

View File

@ -97,13 +97,13 @@ def do_print(var):
def run(): def run():
import parsed_text import parsed_text
import os,sys import os,sys
l = variables.keys()
if os.fork() == 0: if os.fork() == 0:
for v in l: for v in variables.values():
do_print(variables[v]) do_print(v)
sys.exit(0) sys.exit(0)
if os.fork() == 0: if os.fork() == 0:
l = variables.keys()
file = open("irpf90_entities","w") file = open("irpf90_entities","w")
l.sort() l.sort()
for v in l: for v in l:

View File

@ -284,6 +284,12 @@ class Provide(Line):
def __repr__(self): def __repr__(self):
return "%20s:%5d : %s"%("Provide",self.i,self.text) return "%20s:%5d : %s"%("Provide",self.i,self.text)
class NoDep(Line):
def __init__(self,i,text,filename):
Line.__init__(self,i,text,filename)
def __repr__(self):
return "%20s:%5d : %s"%("NoDep",self.i,self.text)
class Return (Line): class Return (Line):
def __init__(self,i,text,filename): def __init__(self,i,text,filename):
Line.__init__(self,i,text,filename) Line.__init__(self,i,text,filename)

View File

@ -63,8 +63,8 @@ def run():
from modules import modules from modules import modules
if os.fork() == 0: if os.fork() == 0:
mod = [] mod = []
for m in modules.keys(): for m in modules.values():
mod.append(modules[m]) mod.append(m)
file = open('irpf90.make','w') file = open('irpf90.make','w')

View File

@ -63,6 +63,6 @@ def write_module(m):
###################################################################### ######################################################################
if __name__ == '__main__': if __name__ == '__main__':
write_module(modules['electrons.irp.f']) write_module(modules['psi.irp.f'])

View File

@ -166,9 +166,16 @@ def get_parsed_text():
l = line.lower.split()[1:] l = line.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:
error.fail(line,"Variable %s is unknown"%(v)) error.fail(line,"Variable %s is unknown"%(v))
append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) ) append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif type(line) == NoDep:
l = line.lower.split()[1:]
for v in l:
if v not in variables:
error.fail(line,"Variable %s is unknown"%(v))
l = map(lambda x: "-%s"%(x), l)
append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif type(line) in [ Touch, SoftTouch ]: elif type(line) in [ Touch, SoftTouch ]:
vars = line.lower.split() vars = line.lower.split()
if len(vars) < 2: if len(vars) < 2:
@ -244,7 +251,7 @@ parsed_text = get_parsed_text()
def move_to_top(text,t): def move_to_top(text,t):
assert type(text) == list assert type(text) == list
assert t in [ Declaration, Implicit, Use, Cont_provider ] assert t in [ NoDep, Declaration, Implicit, Use, Cont_provider ]
inside = False inside = False
for i in range(len(text)): for i in range(len(text)):
@ -264,6 +271,7 @@ def move_to_top(text,t):
result = [] result = []
for filename,text in parsed_text: for filename,text in parsed_text:
text = move_to_top(text,NoDep)
text = move_to_top(text,Declaration) text = move_to_top(text,Declaration)
text = move_to_top(text,Implicit) text = move_to_top(text,Implicit)
text = move_to_top(text,Use) text = move_to_top(text,Use)
@ -396,6 +404,10 @@ def move_variables():
elif type(line) in [ End_provider, End ]: elif type(line) in [ End_provider, End ]:
assert old_varlist == [] assert old_varlist == []
varlist = [] varlist = []
for v in vars[:]:
if v[0] == '-':
vars.remove(v)
vars.remove(v[1:])
result.append( (vars,line) ) result.append( (vars,line) )
return result return result
@ -435,25 +447,25 @@ def build_needs():
funcs = find_funcs_in_line(line) funcs = find_funcs_in_line(line)
for f in funcs: for f in funcs:
var.needs += subroutines[f].needs var.needs += subroutines[f].needs
for v in variables.keys(): for v in variables:
main = variables[v].same_as main = variables[v].same_as
if main != v: if main != v:
variables[v].needs = variables[main].needs variables[v].needs = variables[main].needs
variables[v].to_provide = variables[main].to_provide variables[v].to_provide = variables[main].to_provide
# Needed_by # Needed_by
for v in variables.keys(): for v in variables:
variables[v].needed_by = [] variables[v].needed_by = []
for v in variables.keys(): for v in variables:
main = variables[v].same_as main = variables[v].same_as
if main != v: if main != v:
variables[v].needed_by = variables[main].needed_by variables[v].needed_by = variables[main].needed_by
for v in variables.keys(): for v in variables:
var = variables[v] var = variables[v]
if var.is_main: if var.is_main:
for x in var.needs: for x in var.needs:
variables[x].needed_by.append(var.same_as) variables[x].needed_by.append(var.same_as)
for v in variables.keys(): for v in variables:
var = variables[v] var = variables[v]
var.needed_by = make_single(var.needed_by) var.needed_by = make_single(var.needed_by)
@ -462,6 +474,7 @@ build_needs()
result = [] result = []
for filename,text in parsed_text: for filename,text in parsed_text:
text = move_to_top(text,NoDep)
text = move_to_top(text,Declaration) text = move_to_top(text,Declaration)
text = move_to_top(text,Implicit) text = move_to_top(text,Implicit)
text = move_to_top(text,Use) text = move_to_top(text,Use)
@ -494,7 +507,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] == 'eplf_function.irp.f': if parsed_text[i][0] == 'psi.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]

View File

@ -59,6 +59,7 @@ simple_dict = {
"touch": Touch , "touch": Touch ,
"soft_touch": SoftTouch , "soft_touch": SoftTouch ,
"provide": Provide , "provide": Provide ,
"no_dep": NoDep ,
"free": Free , "free": Free ,
"irp_if": Irp_If , "irp_if": Irp_If ,
"irp_else": Irp_Else , "irp_else": Irp_Else ,
@ -84,7 +85,6 @@ simple_dict = {
"function": Function , "function": Function ,
"recursive": Function , "recursive": Function ,
} }
simple_dict_keys = simple_dict.keys()
def get_type (i, filename, line, is_doc): def get_type (i, filename, line, is_doc):
'''Find the type of a text line''' '''Find the type of a text line'''
@ -125,7 +125,7 @@ def get_type (i, filename, line, is_doc):
if is_doc: if is_doc:
return [ Doc (i,line,filename) ], is_doc return [ Doc (i,line,filename) ], is_doc
if firstword in simple_dict_keys: if firstword in simple_dict:
return [ simple_dict[firstword](i,line,filename) ], is_doc return [ simple_dict[firstword](i,line,filename) ], is_doc
if firstword in [ "select", "selectcase" ]: if firstword in [ "select", "selectcase" ]:
@ -620,7 +620,7 @@ def irp_simple_statements(text):
result = [] result = []
for line in text: for line in text:
buffer = [ line ] buffer = [ line ]
for t in d.keys(): for t in d:
if type(line) == t: if type(line) == t:
buffer = d[t](line) buffer = d[t](line)
break break

View File

@ -40,7 +40,13 @@ def create():
if var.is_touched: if var.is_touched:
out += var.toucher out += var.toucher
if out != []:
out = map(lambda x: "%s\n"%(x),out) out = map(lambda x: "%s\n"%(x),out)
else:
out = """
subroutine irpf90_dummy_touch()
end
""".splitlines()
if not same_file(FILENAME,out): if not same_file(FILENAME,out):
file = open(FILENAME,'w') file = open(FILENAME,'w')
file.writelines(out) file.writelines(out)

View File

@ -25,7 +25,7 @@
# scemama@irsamc.ups-tlse.fr # scemama@irsamc.ups-tlse.fr
import os import os
NTHREADS=int(os.getenv('OMP_NUM_THREADS',4)) NTHREADS=int(os.getenv('OMP_NUM_THREADS',2))
def strip(x): def strip(x):
return x.strip() return x.strip()
@ -135,6 +135,12 @@ def parallel_loop(f,source):
src = [ [] for i in xrange(NTHREADS) ] src = [ [] for i in xrange(NTHREADS) ]
index = 0 index = 0
try:
source = map( lambda x: (len(x[1]),(x[0], x[1])), source )
source.sort()
source = map( lambda x: x[1], source )
except:
pass
for i in source: for i in source:
index += 1 index += 1
if index == NTHREADS: if index == NTHREADS:
@ -143,34 +149,36 @@ def parallel_loop(f,source):
thread_id = 0 thread_id = 0
fork = 1 fork = 1
r = range(0,NTHREADS)
for thread_id in xrange(1,NTHREADS): for thread_id in xrange(1,NTHREADS):
r[thread_id], w = os.pipe()
fork = os.fork() fork = os.fork()
if fork == 0: if fork == 0:
os.close(r[thread_id])
w = os.fdopen(w,'w')
break break
else: else:
os.close(w)
r[thread_id] = os.fdopen(r[thread_id],'r')
pidlist[thread_id] = fork pidlist[thread_id] = fork
thread_id = 0 thread_id = 0
result = []
for filename, text in src[thread_id]: for filename, text in src[thread_id]:
result = f(filename,text) result.append( (filename, f(filename,text)) )
file = open('%s.pickle'%filename,'w')
pickle.dump(result,file,-1) result.sort()
file.close()
if fork == 0: if fork == 0:
pickle.dump(result,w,-1)
w.close()
os._exit(0) os._exit(0)
for i in xrange(1,NTHREADS): for i in xrange(1,NTHREADS):
result += pickle.load(r[i])
r[i].close()
if os.waitpid(pidlist[i],0)[1] != 0: if os.waitpid(pidlist[i],0)[1] != 0:
os._exit(0) raise OSError
result = []
for filename,text in source:
file = open('%s.pickle'%filename,'r')
data = pickle.load(file)
file.close()
os.remove('%s.pickle'%filename)
result.append( (filename, data) )
return result return result

View File

@ -1 +1 @@
version = "1.1.63" version = "1.1.70"