10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-22 04:13:33 +01:00

Added -p item

Version:1.1.15
This commit is contained in:
Anthony Scemama 2009-09-16 15:59:13 +02:00
parent 8d36c357ae
commit 448e566dc4
9 changed files with 44 additions and 17 deletions

View File

@ -6,7 +6,5 @@ import sys
wd = os.path.abspath(os.path.dirname(__file__)) wd = os.path.abspath(os.path.dirname(__file__))
wd += "/../src/" wd += "/../src/"
sys.path.append(wd) sys.path.append(wd)
for p in sys.path:
print p
import irpf90 import irpf90

View File

@ -7,4 +7,11 @@ wd = os.path.abspath(os.path.dirname(__file__))
wd += "/../src/" wd += "/../src/"
sys.path.append(wd) sys.path.append(wd)
import irpman if len(sys.argv) != 2:
print "Usage:"
print sys.argv[0]+" <irp_variable>"
sys.exit(1)
from irpf90_t import mandir
os.system("man ./"+mandir+sys.argv[1].lower()+".l")

View File

@ -13,6 +13,7 @@ options['o'] = [ 'openmp' , 'Activate openMP', 0 ]
options['c'] = [ 'check_cycles' , 'Check cycles in dependencies', 0 ] options['c'] = [ 'check_cycles' , 'Check cycles in dependencies', 0 ]
options['i'] = [ 'init' , 'Initialize current directory', 0 ] options['i'] = [ 'init' , 'Initialize current directory', 0 ]
options['D'] = [ 'define' , 'Define variable', 1 ] options['D'] = [ 'define' , 'Define variable', 1 ]
options['p'] = [ 'preprocess' , 'Preprocess file', 1 ]
class CommandLine(object): class CommandLine(object):
@ -31,6 +32,15 @@ class CommandLine(object):
return self._defined return self._defined
defined = property(fget=defined) defined = property(fget=defined)
def preprocessed(self):
if '_preprocessed' not in self.__dict__:
self._preprocessed = []
for o,a in self.opts:
if o in [ "-p", options['p'][0] ]:
self._preprocessed.append(a)
return self._preprocessed
preprocessed = property(fget=preprocessed)
def usage(self): def usage(self):
t = """ t = """
$EXE - $DESCR $EXE - $DESCR

View File

@ -9,7 +9,7 @@ from util import *
def do_print_short(file,var): def do_print_short(file,var):
assert isinstance(var,Variable) assert isinstance(var,Variable)
print >>file, "%s : %s :: %s %s"%( \ print >>file, "%s : %s :: %s %s"%( \
var.line.filename, var.line.filename[0],
var.type, var.type,
var.name, var.name,
build_dim(var.dim) ) build_dim(var.dim) )
@ -42,7 +42,7 @@ def process_types(file,var):
###################################################################### ######################################################################
def do_print(var): def do_print(var):
assert isinstance(var,Variable) assert isinstance(var,Variable)
filename = var.line.filename filename = var.line.filename[0]
name = var.name name = var.name
file = open("%s%s.l"%(mandir,var.name), "w") file = open("%s%s.l"%(mandir,var.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name) print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
@ -59,9 +59,11 @@ def do_print(var):
print >>file, ".SH File\n.P" print >>file, ".SH File\n.P"
print >>file, filename print >>file, filename
if var.needs != []: if var.needs != []:
var.needs.sort()
print >>file, ".SH Needs" print >>file, ".SH Needs"
process_deps(file,var.needs) process_deps(file,var.needs)
if var.needed_by != []: if var.needed_by != []:
var.needed_by.sort()
print >>file, ".SH Needed by" print >>file, ".SH Needed by"
process_deps(file,var.needed_by) process_deps(file,var.needed_by)
file.close() file.close()

View File

@ -11,6 +11,14 @@ def main():
print version print version
return return
if command_line.do_preprocess:
from preprocessed_text import preprocessed_text
for filename,text in preprocessed_text:
if filename in command_line.preprocessed:
for line in text:
print line.text
return
from init import init from init import init
if command_line.do_init: if command_line.do_init:
init() init()

View File

@ -115,17 +115,17 @@ def get_parsed_text():
error.fail(line,"Syntax error") error.fail(line,"Syntax error")
vars = map(lower,vars[1:]) vars = map(lower,vars[1:])
for v in vars: for v in vars:
if v not in variables:
error.fail(line,"Variable %s unknown"%(v,))
variables[v]._is_touched = True variables[v]._is_touched = True
def fun(x): def fun(x):
if x not in variables:
error.fail(line,"Variable %s unknown"%(x,))
main = variables[x].same_as main = variables[x].same_as
return main return main
main_vars = make_single( map(fun, vars) ) main_vars = make_single( map(fun, vars) )
check_touch(line,vars,main_vars) check_touch(line,vars,main_vars)
txt = " ".join(vars) txt = " ".join(vars)
result += [ ([],Simple_line(line.i,"!",line.filename)), result += [ (vars,Simple_line(line.i,"!",line.filename)),
(vars,Simple_line(line.i,"! >>> TOUCH %s"%(txt,),line.filename)) ] ([],Simple_line(line.i,"! >>> TOUCH %s"%(txt,),line.filename)) ]
def fun(x): def fun(x):
if x not in variables: if x not in variables:
error.fail(line,"Variable %s unknown"%(x,)) error.fail(line,"Variable %s unknown"%(x,))
@ -212,6 +212,8 @@ def move_variables():
assert old_ifvars == [] assert old_ifvars == []
assert old_elsevars == [] assert old_elsevars == []
varlist = [] varlist = []
elif isinstance(line,Provide_all):
result.append( (vars,line) )
else: else:
varlist += vars varlist += vars
result.append( ([],line) ) result.append( ([],line) )

View File

@ -412,7 +412,7 @@ def irp_simple_statements(text):
i = line.i i = line.i
f = line.filename f = line.filename
result = [ Begin_provider(i,line.text, (f,varname)), result = [ Begin_provider(i,line.text, (f,varname)),
Declaration(i," character*(%d), parameter :: irp_here = '%s'"%(length,varname), filename) ] Declaration(i," character*(%d) :: irp_here = '%s'"%(length,varname), filename) ]
if command_line.do_assert or command_line.do_debug: if command_line.do_assert or command_line.do_debug:
result += [ result += [
Simple_line(i," call irp_enter(irp_here)", f), Simple_line(i," call irp_enter(irp_here)", f),
@ -438,7 +438,7 @@ def irp_simple_statements(text):
i = line.i i = line.i
f = line.filename f = line.filename
result = [ line, result = [ line,
Declaration(i," character*(%d), parameter :: irp_here = '%s'"%(length,subname), f) ] Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
if command_line.do_assert or command_line.do_debug: if command_line.do_assert or command_line.do_debug:
result += [ result += [
Simple_line(i," call irp_enter(irp_here)", f), Simple_line(i," call irp_enter(irp_here)", f),
@ -453,7 +453,7 @@ def irp_simple_statements(text):
i = line.i i = line.i
f = line.filename f = line.filename
result = [ line, result = [ line,
Declaration(i," character*(%d), parameter :: irp_here = '%s'"%(length,subname), f) ] Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
if command_line.do_assert or command_line.do_debug: if command_line.do_assert or command_line.do_debug:
result += [ result += [
Simple_line(i," call irp_enter(irp_here)", f), Simple_line(i," call irp_enter(irp_here)", f),

View File

@ -199,7 +199,7 @@ class Variable(object):
result.append(" implicit none") result.append(" implicit none")
if command_line.do_debug: if command_line.do_debug:
length = str(len("touch_%s"%(name))) length = str(len("touch_%s"%(name)))
result += [ " character*(%s), parameter :: irp_here = 'touch_%s'"%(length,name), result += [ " character*(%s) :: irp_here = 'touch_%s'"%(length,name),
" call irp_enter(irp_here)" ] " call irp_enter(irp_here)" ]
result += map( lambda x: " %s_is_built = .False."%(x), parents) result += map( lambda x: " %s_is_built = .False."%(x), parents)
result.append(" %s_is_built = .True."%(name)) result.append(" %s_is_built = .True."%(name))
@ -231,7 +231,7 @@ class Variable(object):
if command_line.do_debug: if command_line.do_debug:
length = len("reader_%s"%(self.name)) length = len("reader_%s"%(self.name))
result += [\ result += [\
" character*(%d), parameter :: irp_here = 'reader_%s'"%(length,name), " character*(%d) :: irp_here = 'reader_%s'"%(length,name),
" call irp_enter(irp_here)" ] " call irp_enter(irp_here)" ]
result += map(lambda x: " call reader_%s(irp_num)"%(x),self.needs) result += map(lambda x: " call reader_%s(irp_num)"%(x),self.needs)
result += [ \ result += [ \
@ -277,7 +277,7 @@ class Variable(object):
if command_line.do_debug: if command_line.do_debug:
length = len("writer_%s"%(self.name)) length = len("writer_%s"%(self.name))
result += [\ result += [\
" character*(%d), parameter :: irp_here = 'writer_%s'"%(length,name), " character*(%d) :: irp_here = 'writer_%s'"%(length,name),
" call irp_enter(irp_here)" ] " call irp_enter(irp_here)" ]
result += [ \ result += [ \
" if (.not.%s_is_built) then"%(self.same_as), " if (.not.%s_is_built) then"%(self.same_as),
@ -390,7 +390,7 @@ class Variable(object):
result.append(" implicit none") result.append(" implicit none")
length = len("provide_%s"%(name)) length = len("provide_%s"%(name))
result += [\ result += [\
" character*(%d), parameter :: irp_here = 'provide_%s'"%(length,name), " character*(%d) :: irp_here = 'provide_%s'"%(length,name),
" integer :: irp_err ", " integer :: irp_err ",
" logical :: irp_dimensions_OK" ] " logical :: irp_dimensions_OK" ]
if command_line.do_assert or command_line.do_debug: if command_line.do_assert or command_line.do_debug:

View File

@ -1 +1 @@
version = "1.1.14" version = "1.1.15"