Commit f399b289 authored by erodrigu's avatar erodrigu
Browse files

return when finding the first ALLOCATE

parent 7445e7c3
......@@ -154,35 +154,25 @@ def insert_variable_precision_specification(variable, module, insertion_line, co
module.rebuild_text()
def search_allocate_line(variable, module, counter_object):
found = False
for line_index, line in enumerate(module.lines):
if re.search(r"\ballocate\b\s*\(.*\b" + variable.name + r"\b.*", line, re.I):
found = True
if variable.is_member_of:
# Get the arguments from ALLOCATE, avoiding any possible extra call or IF stament inline
arguments = CallManager.find_call_arguments(BasicFunctions.remove_if_condition(line))
for arg in arguments:
if arg.count(variable.name):
# Remove the possible array arguments and get only the member and var (foo%var(2:3) --> foo%var)
var_name = arg.split(variable.name)[0] + variable.name
break
else:
var_name = None
variable.id = counter_object.count
variable.mutable = True
counter_object.up()
insert_variable_precision_specification(variable, module, line_index + 1, var_name=var_name)
return found
def insert_variable_precision_specification_to_allocatable(variable, counter_object):
module_where_var_appears = variable.procedure.module.used_by
if search_allocate_line(variable, variable.module, counter_object):
return
for module in variable.procedure.module.used_by:
search_allocate_line(variable, module, counter_object)
for module in [variable.module] + variable.procedure.module.used_by:
for line_index, line in enumerate(module.lines):
if re.search(r"\ballocate\b\s*\(.*\b" + variable.name + r"\b.*", line, re.I):
if variable.is_member_of:
# Get the arguments from ALLOCATE, avoiding any possible extra call or IF stament inline
arguments = CallManager.find_call_arguments(BasicFunctions.remove_if_condition(line))
for arg in arguments:
if arg.count(variable.name):
# Remove the possible array arguments and get only the member and var (foo%var(2:3) --> foo%var)
var_name = arg.split(variable.name)[0] + variable.name
break
else:
var_name = None
variable.id = counter_object.count
variable.mutable = True
counter_object.up()
insert_variable_precision_specification(variable, module, line_index + 1, var_name=var_name)
return
def insert_variable_precision_specification_to_namelist_parameter(variable, counter_object, vault):
module = vault[variable.appears_in_namelist[0]]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment