mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-21 20:03:33 +01:00
Provide dimensions in subroutines
Version:1.2.5
This commit is contained in:
parent
4a16a6398b
commit
6763923a94
@ -1,4 +1,5 @@
|
|||||||
program irp_example1
|
program irp_example1
|
||||||
|
integer :: x(w)
|
||||||
BEGIN_SHELL [ /bin/bash ]
|
BEGIN_SHELL [ /bin/bash ]
|
||||||
echo print *, \'Compiled by `whoami` on `date`\'
|
echo print *, \'Compiled by `whoami` on `date`\'
|
||||||
echo print *, \'$FC $FCFLAGS\'
|
echo print *, \'$FC $FCFLAGS\'
|
||||||
|
@ -151,7 +151,7 @@ class Fmodule(object):
|
|||||||
dec = []
|
dec = []
|
||||||
use = []
|
use = []
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if type(line) in [ Subroutine, Function]:
|
if type(line) in [ Subroutine, Function, Program]:
|
||||||
inside = True
|
inside = True
|
||||||
if inside:
|
if inside:
|
||||||
result.append( (vars,line) )
|
result.append( (vars,line) )
|
||||||
@ -182,22 +182,6 @@ class Fmodule(object):
|
|||||||
result = move_to_top(result,Use)
|
result = move_to_top(result,Use)
|
||||||
result = map(lambda x: x[1], result)
|
result = map(lambda x: x[1], result)
|
||||||
result = map(lambda x: x.text, result)
|
result = map(lambda x: x.text, result)
|
||||||
if self.is_main:
|
|
||||||
temp = [ "program irp_program" ]
|
|
||||||
if command_line.do_profile:
|
|
||||||
temp += [ "call irp_init_timer()" ]
|
|
||||||
if command_line.do_openmp:
|
|
||||||
temp += [ "!$OMP PARALLEL" ]
|
|
||||||
temp += [ "!$OMP MASTER" ]
|
|
||||||
temp += [ " call %s"%(self.prog_name) ]
|
|
||||||
if command_line.do_openmp:
|
|
||||||
temp += [ "!$OMP END MASTER" ]
|
|
||||||
temp += [ "!$OMP END PARALLEL" ]
|
|
||||||
if command_line.do_profile:
|
|
||||||
temp += [ "call irp_print_timer()" ]
|
|
||||||
temp += [ " call irp_finalize_%s()"%(irp_id) ]
|
|
||||||
temp += [ "end program" ]
|
|
||||||
result = temp + result
|
|
||||||
self._residual_text = result
|
self._residual_text = result
|
||||||
return self._residual_text
|
return self._residual_text
|
||||||
residual_text = property(residual_text)
|
residual_text = property(residual_text)
|
||||||
|
@ -257,7 +257,7 @@ def move_to_top(text,t):
|
|||||||
inside = False
|
inside = False
|
||||||
for i in range(len(text)):
|
for i in range(len(text)):
|
||||||
vars, line = text[i]
|
vars, line = text[i]
|
||||||
if type(line) in [ Begin_provider, Subroutine, Function ]:
|
if type(line) in [ Begin_provider, Program, Subroutine, Function ]:
|
||||||
begin = i
|
begin = i
|
||||||
inside = True
|
inside = True
|
||||||
elif type(line) in [ End_provider, End ]:
|
elif type(line) in [ End_provider, End ]:
|
||||||
@ -286,17 +286,25 @@ def build_sub_needs():
|
|||||||
# Needs
|
# Needs
|
||||||
for filename, text in parsed_text:
|
for filename, text in parsed_text:
|
||||||
sub = None
|
sub = None
|
||||||
|
in_program = False
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if type(line) in [ Subroutine, Function ]:
|
if type(line) in [ Subroutine, Function ]:
|
||||||
subname = find_subname(line)
|
subname = find_subname(line)
|
||||||
sub = subroutines[subname]
|
sub = subroutines[subname]
|
||||||
sub.needs = []
|
sub._needs = []
|
||||||
sub.to_provide = vars
|
sub._to_provide = []
|
||||||
elif type(line) == End:
|
elif type(line) == End:
|
||||||
sub.needs = make_single(sub.needs)
|
if not in_program:
|
||||||
sub = None
|
sub._needs = make_single(sub._needs)
|
||||||
|
sub._to_provide = make_single(sub._to_provide)
|
||||||
|
sub = None
|
||||||
|
elif type(line) == Program:
|
||||||
|
in_program = True
|
||||||
if sub is not None:
|
if sub is not None:
|
||||||
sub.needs += vars
|
if type(line) == Declaration:
|
||||||
|
sub._to_provide += vars
|
||||||
|
else:
|
||||||
|
sub._needs += vars
|
||||||
|
|
||||||
build_sub_needs()
|
build_sub_needs()
|
||||||
|
|
||||||
@ -361,7 +369,7 @@ def move_variables():
|
|||||||
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, Program, Subroutine, Function ]:
|
||||||
varlist += vars
|
varlist += vars
|
||||||
append( (varlist,line) )
|
append( (varlist,line) )
|
||||||
if old_varlist != [] \
|
if old_varlist != [] \
|
||||||
@ -385,7 +393,7 @@ def move_variables():
|
|||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if vars != []:
|
if vars != []:
|
||||||
vars = make_single(vars)
|
vars = make_single(vars)
|
||||||
if type(line) in [ Begin_provider, Subroutine, Function ]:
|
if type(line) in [ Begin_provider, Program, Subroutine, Function ]:
|
||||||
varlist = list(vars)
|
varlist = list(vars)
|
||||||
elif type(line) in [ If, Select ]:
|
elif type(line) in [ If, Select ]:
|
||||||
old_varlist.append(varlist)
|
old_varlist.append(varlist)
|
||||||
|
@ -605,7 +605,21 @@ def irp_simple_statements(text):
|
|||||||
def process_program(line):
|
def process_program(line):
|
||||||
assert type(line) == Program
|
assert type(line) == Program
|
||||||
program_name = line.lower.split()[1]
|
program_name = line.lower.split()[1]
|
||||||
result = [ Program(0,"",program_name) ] + \
|
temp = [ Program(0,"program irp_program",program_name) ]
|
||||||
|
if command_line.do_profile:
|
||||||
|
temp += [ Simple_line(0,"call irp_init_timer()",line.filename) ]
|
||||||
|
if command_line.do_openmp:
|
||||||
|
temp += [ Openmp(0,"!$OMP PARALLEL",line.filename) ]
|
||||||
|
temp += [ Openmp(0,"!$OMP MASTER",line.filename) ]
|
||||||
|
temp += [ Call(0," call %s"%(program_name),line.filename) ]
|
||||||
|
if command_line.do_openmp:
|
||||||
|
temp += [ Openmp(0,"!$OMP END MASTER",line.filename) ]
|
||||||
|
temp += [ Openmp(0,"!$OMP END PARALLEL",line.filename) ]
|
||||||
|
if command_line.do_profile:
|
||||||
|
temp += [ Simple_line(0,"call irp_print_timer()",line.filename) ]
|
||||||
|
temp += [ Simple_line(0," call irp_finalize_%s()"%(irp_id),line.filename) ]
|
||||||
|
temp += [ End(0,"end program",line.filename) ]
|
||||||
|
result = temp + \
|
||||||
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
|
||||||
|
|
||||||
@ -739,7 +753,7 @@ def check_begin_end(text):
|
|||||||
'''Checks x...endx consistence'''
|
'''Checks x...endx consistence'''
|
||||||
|
|
||||||
filter_line = lambda line: type(line) in [ Do, Enddo, If, Endif, \
|
filter_line = lambda line: type(line) in [ Do, Enddo, If, Endif, \
|
||||||
Begin_provider, End_provider, \
|
Program, Begin_provider, End_provider, \
|
||||||
Subroutine, Function, End, Begin_doc, End_doc ]
|
Subroutine, Function, End, Begin_doc, End_doc ]
|
||||||
text = filter(filter_line, text)
|
text = filter(filter_line, text)
|
||||||
|
|
||||||
@ -767,9 +781,9 @@ def check_begin_end(text):
|
|||||||
line = text[i]
|
line = text[i]
|
||||||
if type(line) == x:
|
if type(line) == x:
|
||||||
return
|
return
|
||||||
if type(line) in [ Subroutine, Function, Begin_provider ]:
|
if type(line) in [ Subroutine, Function, Program, Begin_provider ]:
|
||||||
error.fail(text[begin],"Subroutine/Function/Provider is not closed")
|
error.fail(text[begin],type(line)+" is not closed")
|
||||||
error.fail(text[begin],"Subroutine/Function/Provider is not closed")
|
error.fail(text[begin],type(line) + " is not closed")
|
||||||
|
|
||||||
|
|
||||||
level = 0
|
level = 0
|
||||||
@ -781,10 +795,7 @@ def check_begin_end(text):
|
|||||||
find_matching_end_ifdo(i,'do')
|
find_matching_end_ifdo(i,'do')
|
||||||
elif type(line) == If:
|
elif type(line) == If:
|
||||||
find_matching_end_ifdo(i,'if')
|
find_matching_end_ifdo(i,'if')
|
||||||
elif type(line) == Subroutine:
|
elif type(line) in [Subroutine, Function, Program]:
|
||||||
level += 1
|
|
||||||
find_matching_end_subfunpro(i,End)
|
|
||||||
elif type(line) == Function:
|
|
||||||
level += 1
|
level += 1
|
||||||
find_matching_end_subfunpro(i,End)
|
find_matching_end_subfunpro(i,End)
|
||||||
elif type(line) == Begin_provider:
|
elif type(line) == Begin_provider:
|
||||||
|
@ -85,6 +85,20 @@ class Sub(object):
|
|||||||
return self._touches
|
return self._touches
|
||||||
touches = property(touches)
|
touches = property(touches)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
def needs(self):
|
||||||
|
if '_needs' not in self.__dict__:
|
||||||
|
import parsed_text
|
||||||
|
return self._needs
|
||||||
|
needs = property(needs)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
def to_provide(self):
|
||||||
|
if '_to_provide' not in self.__dict__:
|
||||||
|
import parsed_text
|
||||||
|
return self._to_provide
|
||||||
|
to_provide = property(to_provide)
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
def regexp(self):
|
def regexp(self):
|
||||||
if '_regexp' not in self.__dict__:
|
if '_regexp' not in self.__dict__:
|
||||||
@ -110,4 +124,5 @@ class Sub(object):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from preprocessed_text import preprocessed_text
|
from preprocessed_text import preprocessed_text
|
||||||
from subroutines import subroutines
|
from subroutines import subroutines
|
||||||
print subroutines['brownian_step'].touches
|
print subroutines['run'].needs
|
||||||
|
print subroutines['run'].to_provide
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.2.4"
|
version = "1.2.5"
|
||||||
|
Loading…
Reference in New Issue
Block a user