10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-21 11:53:32 +01:00

toucher OK

Version:1.1.5
This commit is contained in:
Anthony Scemama 2009-09-07 18:02:06 +02:00
parent 3be940cc9b
commit ffbcc750e8
4 changed files with 82 additions and 26 deletions

View File

@ -33,8 +33,7 @@ def process_deps(file,l):
######################################################################
def process_types(file,var):
assert isinstance(var,Variable)
vars = var.others
vars.insert(0,var.name)
vars = [var.name] + var.others
for var in vars:
name = var
var = variables[var]
@ -49,7 +48,7 @@ def do_print(var):
name = var.name
file = open("%s%s.l"%(mandir,var.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
if var.same_as is not None:
if var.same_as != var.name:
var = variables[var.same_as]
print >>file, ".SH Declaration"
print >>file, ".nf"
@ -71,6 +70,7 @@ def do_print(var):
######################################################################
def run():
import parsed_text
file = open("irpf90_entities","w")
for v in variables.keys():
do_print_short(file,variables[v])

View File

@ -101,8 +101,6 @@ def get_parsed_text():
if x not in variables:
error.fail(line,"Variable %s unknown"%(x,))
main = variables[x].same_as
if main is None:
main = x
return main
main_vars = make_single( map(fun, vars) )
check_touch(line,vars,main_vars)
@ -204,11 +202,7 @@ def move_variables():
result = []
old_varlist = []
varlist = []
if len(text) > 0:
lenmax = 80 - len(text[0][1].filename)
format = "%"+str(lenmax)+"s ! %s:%4s"
for vars,line in text:
line.text = format%(line.text.ljust(lenmax),line.filename,str(line.i))
if vars != []:
vars = make_single(vars)
if type(line) in [ Begin_provider, Subroutine, Function ]:
@ -240,11 +234,58 @@ parsed_text = move_variables()
######################################################################
def build_needs():
pass
# Needs
for filename, text in parsed_text:
for vars,line in text:
if isinstance(line,Begin_provider):
buffer = map(strip,line.text.replace(']',',').split(','))
var = variables[buffer[1].lower()]
var.needs = []
var.to_provide = vars
elif isinstance(line,End_provider):
var.needs = make_single(var.needs)
var.to_provide = make_single(var.to_provide)
var = None
if var is not None:
var.needs += vars
for v in variables.keys():
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():
variables[v].needed_by = []
for v in variables.keys():
main = variables[v].same_as
if main != v:
variables[v].needed_by = variables[main].needed_by
for v in variables.keys():
var = variables[v]
for x in var.needs:
variables[x].needed_by.append(var.same_as)
for v in variables.keys():
var = variables[v]
var.needed_by = make_single(var.needed_by)
build_needs()
######################################################################
def put_info():
for filename, text in parsed_text:
if len(text) > 0:
lenmax = 80 - len(text[0][1].filename)
format = "%"+str(lenmax)+"s ! %s:%4s"
for vars,line in text:
line.text = format%(line.text.ljust(lenmax),line.filename,str(line.i))
######################################################################
if __name__ == '__main__':
for i in range(len(parsed_text)):
print '!-------- %s -----------'%(parsed_text[i][0])
for line in parsed_text[i][1]:
print line[1]
print line[0]

View File

@ -3,6 +3,7 @@
from irpf90_t import *
from util import *
import error
from command_line import command_line
class Variable(object):
@ -63,7 +64,7 @@ class Variable(object):
def same_as(self):
if '_same_as' not in self.__dict__:
if isinstance(self.line,Begin_provider):
result = None
result = self.name
else:
buffer = self.text[0].text.replace(']',',').split(',')
if len(buffer) < 3:
@ -141,20 +142,6 @@ class Variable(object):
return self._line
line = property(line)
############################################################
def needs(self):
if '_needs' not in self.__dict__:
self._needs = []
return self._needs
needs = property(needs)
############################################################
def needed_by(self):
if '_needed_by' not in self.__dict__:
self._needed_by = []
return self._needed_by
needed_by = property(needed_by)
############################################################
def header(self):
if '_header' not in self.__dict__:
@ -166,9 +153,37 @@ class Variable(object):
return self._header
header = property(header)
############################################################
def toucher(self):
if '_toucher' not in self.__dict__:
if self.same_as != self.name:
self._toucher = ""
else:
if '_needed_by' not in self.__dict__:
import parsed_text
name = self.name
result = [ "subroutine touch_%s"%(name) ,
" use %s"%(self.fmodule),
" implicit none" ]
if command_line.do_debug:
length = str(len("touch_%s"%(name)))
result += [ " character*(%s), parameter :: irp_here = 'touch_%s'"%(length,name),
" call irp_enter(irp_here)" ]
result += [ " %s_is_built = .False."%(name) ]
result += map( lambda x: "!DEC$ ATTRIBUTES FORCEINLINE :: touch_%s"%(x), self.needed_by )
result += map( lambda x: " call touch_%s"%(x), self.needed_by )
if command_line.do_debug:
result += [ " call irp_leave(irp_here)" ]
result += [ "end subroutine touch_%s"%(name) , "" ]
self._toucher = result
return self._toucher
toucher = property(toucher)
######################################################################
if __name__ == '__main__':
from preprocessed_text import preprocessed_text
from variables import variables
for v in variables.keys():
print v
for line in variables['elec_coord'].toucher:
print line

View File

@ -1 +1 @@
version = "1.1.4"
version = "1.1.5"