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:
commit
ddf7ddc4d0
@ -102,7 +102,7 @@ Options:
|
||||
def opts(self):
|
||||
if self._opts is None:
|
||||
optlist = ["",[]]
|
||||
for o in options.keys():
|
||||
for o in options:
|
||||
b = [o]+options[o]
|
||||
if b[3] == 1:
|
||||
b[0] = b[0]+":"
|
||||
@ -132,7 +132,7 @@ def do_$LONG(self):
|
||||
return self._do_$LONG
|
||||
do_$LONG = property(fget=do_$LONG)
|
||||
"""
|
||||
for short in options.keys():
|
||||
for short in options:
|
||||
long = options[short][0]
|
||||
exec t.replace("$LONG",long).replace("$SHORT",short)
|
||||
|
||||
|
@ -97,13 +97,13 @@ def do_print(var):
|
||||
def run():
|
||||
import parsed_text
|
||||
import os,sys
|
||||
l = variables.keys()
|
||||
if os.fork() == 0:
|
||||
for v in l:
|
||||
do_print(variables[v])
|
||||
for v in variables.values():
|
||||
do_print(v)
|
||||
sys.exit(0)
|
||||
|
||||
if os.fork() == 0:
|
||||
l = variables.keys()
|
||||
file = open("irpf90_entities","w")
|
||||
l.sort()
|
||||
for v in l:
|
||||
|
@ -284,6 +284,12 @@ class Provide(Line):
|
||||
def __repr__(self):
|
||||
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):
|
||||
def __init__(self,i,text,filename):
|
||||
Line.__init__(self,i,text,filename)
|
||||
|
@ -63,8 +63,8 @@ def run():
|
||||
from modules import modules
|
||||
if os.fork() == 0:
|
||||
mod = []
|
||||
for m in modules.keys():
|
||||
mod.append(modules[m])
|
||||
for m in modules.values():
|
||||
mod.append(m)
|
||||
|
||||
file = open('irpf90.make','w')
|
||||
|
||||
|
@ -63,6 +63,6 @@ def write_module(m):
|
||||
|
||||
######################################################################
|
||||
if __name__ == '__main__':
|
||||
write_module(modules['electrons.irp.f'])
|
||||
write_module(modules['psi.irp.f'])
|
||||
|
||||
|
||||
|
@ -166,9 +166,16 @@ def get_parsed_text():
|
||||
l = line.lower.split()[1:]
|
||||
l = filter(lambda x: x not in varlist, l)
|
||||
for v in l:
|
||||
if v not in variables.keys():
|
||||
if v not in variables:
|
||||
error.fail(line,"Variable %s is unknown"%(v))
|
||||
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 ]:
|
||||
vars = line.lower.split()
|
||||
if len(vars) < 2:
|
||||
@ -244,7 +251,7 @@ parsed_text = get_parsed_text()
|
||||
|
||||
def move_to_top(text,t):
|
||||
assert type(text) == list
|
||||
assert t in [ Declaration, Implicit, Use, Cont_provider ]
|
||||
assert t in [ NoDep, Declaration, Implicit, Use, Cont_provider ]
|
||||
|
||||
inside = False
|
||||
for i in range(len(text)):
|
||||
@ -264,6 +271,7 @@ def move_to_top(text,t):
|
||||
|
||||
result = []
|
||||
for filename,text in parsed_text:
|
||||
text = move_to_top(text,NoDep)
|
||||
text = move_to_top(text,Declaration)
|
||||
text = move_to_top(text,Implicit)
|
||||
text = move_to_top(text,Use)
|
||||
@ -396,6 +404,10 @@ def move_variables():
|
||||
elif type(line) in [ End_provider, End ]:
|
||||
assert old_varlist == []
|
||||
varlist = []
|
||||
for v in vars[:]:
|
||||
if v[0] == '-':
|
||||
vars.remove(v)
|
||||
vars.remove(v[1:])
|
||||
result.append( (vars,line) )
|
||||
return result
|
||||
|
||||
@ -435,25 +447,25 @@ def build_needs():
|
||||
funcs = find_funcs_in_line(line)
|
||||
for f in funcs:
|
||||
var.needs += subroutines[f].needs
|
||||
for v in variables.keys():
|
||||
for v in variables:
|
||||
main = variables[v].same_as
|
||||
if main != v:
|
||||
variables[v].needs = variables[main].needs
|
||||
variables[v].to_provide = variables[main].to_provide
|
||||
|
||||
# Needed_by
|
||||
for v in variables.keys():
|
||||
for v in variables:
|
||||
variables[v].needed_by = []
|
||||
for v in variables.keys():
|
||||
for v in variables:
|
||||
main = variables[v].same_as
|
||||
if main != v:
|
||||
variables[v].needed_by = variables[main].needed_by
|
||||
for v in variables.keys():
|
||||
for v in variables:
|
||||
var = variables[v]
|
||||
if var.is_main:
|
||||
for x in var.needs:
|
||||
variables[x].needed_by.append(var.same_as)
|
||||
for v in variables.keys():
|
||||
for v in variables:
|
||||
var = variables[v]
|
||||
var.needed_by = make_single(var.needed_by)
|
||||
|
||||
@ -462,6 +474,7 @@ build_needs()
|
||||
|
||||
result = []
|
||||
for filename,text in parsed_text:
|
||||
text = move_to_top(text,NoDep)
|
||||
text = move_to_top(text,Declaration)
|
||||
text = move_to_top(text,Implicit)
|
||||
text = move_to_top(text,Use)
|
||||
@ -494,7 +507,7 @@ check_opt()
|
||||
######################################################################
|
||||
if __name__ == '__main__':
|
||||
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])
|
||||
for line in parsed_text[i][1]:
|
||||
print line[1]
|
||||
|
@ -59,6 +59,7 @@ simple_dict = {
|
||||
"touch": Touch ,
|
||||
"soft_touch": SoftTouch ,
|
||||
"provide": Provide ,
|
||||
"no_dep": NoDep ,
|
||||
"free": Free ,
|
||||
"irp_if": Irp_If ,
|
||||
"irp_else": Irp_Else ,
|
||||
@ -84,7 +85,6 @@ simple_dict = {
|
||||
"function": Function ,
|
||||
"recursive": Function ,
|
||||
}
|
||||
simple_dict_keys = simple_dict.keys()
|
||||
|
||||
def get_type (i, filename, line, is_doc):
|
||||
'''Find the type of a text line'''
|
||||
@ -125,7 +125,7 @@ def get_type (i, filename, line, is_doc):
|
||||
if 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
|
||||
|
||||
if firstword in [ "select", "selectcase" ]:
|
||||
@ -620,7 +620,7 @@ def irp_simple_statements(text):
|
||||
result = []
|
||||
for line in text:
|
||||
buffer = [ line ]
|
||||
for t in d.keys():
|
||||
for t in d:
|
||||
if type(line) == t:
|
||||
buffer = d[t](line)
|
||||
break
|
||||
|
@ -40,7 +40,13 @@ def create():
|
||||
if var.is_touched:
|
||||
out += var.toucher
|
||||
|
||||
if out != []:
|
||||
out = map(lambda x: "%s\n"%(x),out)
|
||||
else:
|
||||
out = """
|
||||
subroutine irpf90_dummy_touch()
|
||||
end
|
||||
""".splitlines()
|
||||
if not same_file(FILENAME,out):
|
||||
file = open(FILENAME,'w')
|
||||
file.writelines(out)
|
||||
|
36
src/util.py
36
src/util.py
@ -25,7 +25,7 @@
|
||||
# scemama@irsamc.ups-tlse.fr
|
||||
|
||||
import os
|
||||
NTHREADS=int(os.getenv('OMP_NUM_THREADS',4))
|
||||
NTHREADS=int(os.getenv('OMP_NUM_THREADS',2))
|
||||
|
||||
def strip(x):
|
||||
return x.strip()
|
||||
@ -135,6 +135,12 @@ def parallel_loop(f,source):
|
||||
|
||||
src = [ [] for i in xrange(NTHREADS) ]
|
||||
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:
|
||||
index += 1
|
||||
if index == NTHREADS:
|
||||
@ -143,34 +149,36 @@ def parallel_loop(f,source):
|
||||
|
||||
thread_id = 0
|
||||
fork = 1
|
||||
r = range(0,NTHREADS)
|
||||
for thread_id in xrange(1,NTHREADS):
|
||||
r[thread_id], w = os.pipe()
|
||||
fork = os.fork()
|
||||
if fork == 0:
|
||||
os.close(r[thread_id])
|
||||
w = os.fdopen(w,'w')
|
||||
break
|
||||
else:
|
||||
os.close(w)
|
||||
r[thread_id] = os.fdopen(r[thread_id],'r')
|
||||
pidlist[thread_id] = fork
|
||||
thread_id = 0
|
||||
|
||||
result = []
|
||||
for filename, text in src[thread_id]:
|
||||
result = f(filename,text)
|
||||
file = open('%s.pickle'%filename,'w')
|
||||
pickle.dump(result,file,-1)
|
||||
file.close()
|
||||
result.append( (filename, f(filename,text)) )
|
||||
|
||||
result.sort()
|
||||
|
||||
if fork == 0:
|
||||
pickle.dump(result,w,-1)
|
||||
w.close()
|
||||
os._exit(0)
|
||||
|
||||
for i in xrange(1,NTHREADS):
|
||||
result += pickle.load(r[i])
|
||||
r[i].close()
|
||||
if os.waitpid(pidlist[i],0)[1] != 0:
|
||||
os._exit(0)
|
||||
|
||||
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) )
|
||||
raise OSError
|
||||
|
||||
return result
|
||||
|
||||
|
@ -1 +1 @@
|
||||
version = "1.1.63"
|
||||
version = "1.1.70"
|
||||
|
Loading…
Reference in New Issue
Block a user