Skip to content

Commit c2db64d

Browse files
committed
Cleanup: replace var_dicts with cldicts in write_debug_checks in suite_objects.py; remove pointer attribute in metavar.py and fortran_tools/parse_fortran.py; import Fortran conditional regex statements from parse_tools
1 parent 7256311 commit c2db64d

4 files changed

Lines changed: 19 additions & 30 deletions

File tree

scripts/fortran_tools/parse_fortran.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,6 @@ def parse_fortran_var_decl(line, source, run_env):
800800
if 'allocatable' in varprops:
801801
prop_dict['allocatable'] = 'True'
802802
# end if
803-
if 'pointer' in varprops:
804-
prop_dict['pointer'] = 'True'
805-
# end if
806803
if intent is not None:
807804
prop_dict['intent'] = intent
808805
# end if

scripts/metavar.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from parse_tools import check_default_value, check_valid_values
2323
from parse_tools import ParseContext, ParseSource, type_name
2424
from parse_tools import ParseInternalError, ParseSyntaxError, CCPPError
25+
from parse_tools import FORTRAN_CONDITIONAL_REGEX_WORDS, FORTRAN_CONDITIONAL_REGEX
2526
from var_props import CCPP_LOOP_DIM_SUBSTS, VariableProperty, VarCompatObj
2627
from var_props import find_horizontal_dimension, find_vertical_dimension
2728
from var_props import standard_name_to_long_name, default_kind_val
@@ -85,12 +86,6 @@
8586
'horizontal_loop_begin', 'horizontal_loop_end',
8687
'vertical_layer_index', 'vertical_interface_index']
8788

88-
# DH* Is there a better place for these definitions?
89-
FORTRAN_CONDITIONAL_REGEX_WORDS = [' ', '(', ')', '==', '/=', '<=', '>=', '<', '>', '.eqv.', '.neqv.',
90-
'.true.', '.false.', '.lt.', '.le.', '.eq.', '.ge.', '.gt.', '.ne.',
91-
'.not.', '.and.', '.or.', '.xor.']
92-
FORTRAN_CONDITIONAL_REGEX = re.compile(r"[\w']+|" + "|".join([word.replace('(','\(').replace(')', '\)') for word in FORTRAN_CONDITIONAL_REGEX_WORDS]))
93-
9489
###############################################################################
9590
# Used for creating template variables
9691
_MVAR_DUMMY_RUN_ENV = CCPPFrameworkEnv(None, ndict={'host_files':'',
@@ -193,8 +188,6 @@ class Var:
193188
optional_in=True, default_in=False),
194189
VariableProperty('allocatable', bool,
195190
optional_in=True, default_in=False),
196-
VariableProperty('pointer', bool,
197-
optional_in=True, default_in=False),
198191
VariableProperty('diagnostic_name', str,
199192
optional_in=True, default_in='',
200193
check_fn_in=check_diagnostic_id),

scripts/parse_tools/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from xml_tools import find_schema_file, find_schema_version
3131
from xml_tools import read_xml_file, validate_xml_file
3232
from xml_tools import PrettyElementTree
33+
from fortran_conditional import FORTRAN_CONDITIONAL_REGEX_WORDS, FORTRAN_CONDITIONAL_REGEX
3334
# pylint: enable=wrong-import-position
3435

3536
__all__ = [
@@ -73,5 +74,7 @@
7374
'set_log_to_stdout',
7475
'type_name',
7576
'unique_standard_name',
76-
'validate_xml_file'
77+
'validate_xml_file',
78+
'FORTRAN_CONDITIONAL_REGEX_WORDS',
79+
'FORTRAN_CONDITIONAL_REGEX'
7780
]

scripts/suite_objects.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,11 +1289,7 @@ def write_var_debug_check(self, var, dummy, cldicts, outfile, errcode, errmsg, i
12891289
standard_name = var.get_prop_value('standard_name')
12901290
dimensions = var.get_dimensions()
12911291
active = var.get_prop_value('active')
1292-
pointer = var.get_prop_value('pointer')
12931292
allocatable = var.get_prop_value('allocatable')
1294-
# The order is important to get the correct local name - DH* not sure ...
1295-
#var_dicts = [ self.__group.call_list ] + self.__group.suite_dicts()
1296-
var_dicts = cldicts
12971293

12981294
# Need the local name as it comes from the group call list
12991295
# or from the suite, not how it is called in the scheme (var)
@@ -1307,21 +1303,21 @@ def write_var_debug_check(self, var, dummy, cldicts, outfile, errcode, errmsg, i
13071303
if dvar:
13081304
break
13091305
if not dvar:
1310-
raise Exception(f"No variable with standard name '{standard_name}' in var_dicts")
1306+
raise Exception(f"No variable with standard name '{standard_name}' in cldicts")
13111307
local_name = dvar.get_prop_value('local_name')
13121308

1313-
# If the variable is allocatable or a pointer and the intent for the
1314-
# scheme is 'out', then we can't test anything because the scheme is
1315-
# going to allocate the variable or associate the pointer. We don't have
1316-
# this information earlier in add_var_debug_check, therefore need to back
1317-
# out here, using the information from the scheme variable (call list).
1309+
# If the variable is allocatable and the intent for the scheme is 'out',
1310+
# then we can't test anything because the scheme is going to allocate
1311+
# the variable. We don't have this information earlier in
1312+
# add_var_debug_check, therefore need to back out here,
1313+
# using the information from the scheme variable (call list).
13181314
svar = self.call_list.find_variable(standard_name=standard_name)
13191315
intent = svar.get_prop_value('intent')
1320-
if intent == 'out' and (allocatable or pointer):
1316+
if intent == 'out' and allocatable:
13211317
return
13221318

13231319
# Get the condition on which the variable is active
1324-
(conditional, _) = var.conditional(var_dicts)
1320+
(conditional, _) = var.conditional(cldicts)
13251321

13261322
# For scalars, assign to dummy variable if the variable intent is in/inout
13271323
if not dimensions:
@@ -1342,12 +1338,12 @@ def write_var_debug_check(self, var, dummy, cldicts, outfile, errcode, errmsg, i
13421338
if not ':' in dim:
13431339
# In capgen, any true dimension (that is not a single index) does
13441340
# have a colon (:) in the dimension, therefore this is an index
1345-
for var_dict in var_dicts:
1341+
for var_dict in cldicts:
13461342
dvar = var_dict.find_variable(standard_name=dim, any_scope=False)
13471343
if dvar is not None:
13481344
break
13491345
if not dvar:
1350-
raise Exception(f"No variable with standard name '{dim}' in var_dicts")
1346+
raise Exception(f"No variable with standard name '{dim}' in cldicts")
13511347
dim_lname = dvar.get_prop_value('local_name')
13521348
dim_length = 1
13531349
dim_strings.append(dim_lname)
@@ -1374,20 +1370,20 @@ def write_var_debug_check(self, var, dummy, cldicts, outfile, errcode, errmsg, i
13741370
else:
13751371
(ldim, udim) = dim.split(":")
13761372
# Get dimension for lower bound
1377-
for var_dict in var_dicts:
1373+
for var_dict in cldicts:
13781374
dvar = var_dict.find_variable(standard_name=ldim, any_scope=False)
13791375
if dvar is not None:
13801376
break
13811377
if not dvar:
1382-
raise Exception(f"No variable with standard name '{ldim}' in var_dicts")
1378+
raise Exception(f"No variable with standard name '{ldim}' in cldicts")
13831379
ldim_lname = dvar.get_prop_value('local_name')
13841380
# Get dimension for upper bound
1385-
for var_dict in var_dicts:
1381+
for var_dict in cldicts:
13861382
dvar = var_dict.find_variable(standard_name=udim, any_scope=False)
13871383
if dvar is not None:
13881384
break
13891385
if not dvar:
1390-
raise Exception(f"No variable with standard name '{udim}' in var_dicts")
1386+
raise Exception(f"No variable with standard name '{udim}' in cldicts")
13911387
udim_lname = dvar.get_prop_value('local_name')
13921388
# Assemble dimensions and bounds for size checking
13931389
dim_length = f'{udim_lname}-{ldim_lname}+1'

0 commit comments

Comments
 (0)