Skip to content

Commit dfb4e38

Browse files
committed
#3124 Improve tests and TODOs
1 parent 3de3393 commit dfb4e38

4 files changed

Lines changed: 10 additions & 56 deletions

File tree

src/psyclone/domain/common/transformations/raise_psyir_2_alg_trans.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def apply(self, node: Call, index: int = None, options=None, **kwargs):
174174
arg_info = []
175175
if node.argument_names[idx]:
176176
call_name = f"{call_arg.value}"
177+
continue
177178
else:
178179
# Get the symbols and args to reconstruct it as a
179180
# higher-abstraction AlgorithmInvokeCall node

src/psyclone/psyir/backend/fortran.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,15 +1076,19 @@ def filecontainer_node(self, node):
10761076
:rtype: str
10771077
10781078
:raises VisitorError: if the attached symbol table contains
1079-
any non-routine symbols.
1079+
any symbols that can not be declard in a FileContainer.
10801080
:raises VisitorError: if more than one child is a Routine Node
10811081
with is_program set to True.
10821082
10831083
'''
10841084
for symbol in node.symbol_table.symbols:
1085-
# TODO #2201 - ContainerSymbols should be accepted but
1086-
# currently are stored in its containing scope.
1087-
if isinstance(symbol, DataSymbol):
1085+
# Only RoutineSymbols and ContainerSymbol can be declared here
1086+
# pylint: disable=unidiomatic-typecheck
1087+
if type(symbol) is Symbol and symbol.is_unresolved:
1088+
# However we also accept symbols that we don't know where
1089+
# they are declared, so we propagated upwards.
1090+
continue
1091+
if not isinstance(symbol, (RoutineSymbol, ContainerSymbol)):
10881092
raise VisitorError(
10891093
f"In the Fortran backend, a file container should not "
10901094
f"have any data symbols associated with it, "

src/psyclone/tests/psyir/frontend/fparser2_subroutine_handler_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,5 +607,5 @@ def test_module_contains_subroutine_contains_subroutine(
607607
# propagating it are.
608608

609609
if "s" in psyir.children[0].symbol_table:
610-
pytest.xfail("TODO #3361: When support for Routines inside Routines"
610+
pytest.xfail("TODO #2205: When support for Routines inside Routines"
611611
" is added, the symbol will not be propagated")

src/psyclone/tests/psyir/frontend/fparser2_where_handler_test.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,57 +1257,6 @@ def test_nested_where(fortran_reader, fortran_writer, tmp_path):
12571257
" 'UnresolvedType'. Consider adding the name of the file "
12581258
"containing the declaration of this quantity to RESOLVE_IMPORTS.")
12591259

1260-
# If some information is provided, one of the WHEREs can be resolved, but
1261-
# the other still is a CodeBlock
1262-
code = ("module my_mod\n"
1263-
" use some_mod\n"
1264-
"contains\n"
1265-
"subroutine my_sub()\n"
1266-
" type :: mytype\n"
1267-
" real, dimension(10,10,10) :: D11\n"
1268-
" real, dimension(10,10,10) :: D12\n"
1269-
" real, dimension(10,10,10) :: D22\n"
1270-
" end type\n"
1271-
" type(mytype) :: p_dal\n"
1272-
" WHERE ( z_lenp4(:,:) <= 0.0_wp )\n"
1273-
" p_dal%D12(:,:,1) = 0.0_wp\n"
1274-
" z_lenp2(:,:) = SQRT( p_dal%D11(:,:,1) * p_dal%D22(:,:,1) )\n"
1275-
" WHERE ( z_lenp2(:,:) == 0.0_wp )\n"
1276-
" p_dal%D11(:,:,1) = p_ens%D11_min(:,:)\n"
1277-
" p_dal%D22(:,:,1) = p_ens%D22_min(:,:)\n"
1278-
" z_lenp2(:,:) = z_lenp2_min(:,:)\n"
1279-
" END WHERE\n"
1280-
" END WHERE\n"
1281-
"end subroutine my_sub\n"
1282-
"end module my_mod\n")
1283-
psyir = fortran_reader.psyir_from_source(code)
1284-
code = fortran_writer(psyir)
1285-
# FIXME
1286-
return
1287-
assert """
1288-
do widx2 = 1, SIZE(z_lenp4, dim=2), 1
1289-
do widx1 = 1, SIZE(z_lenp4, dim=1), 1
1290-
if (z_lenp4(LBOUND(z_lenp4, dim=1) + widx1 - 1,LBOUND(z_lenp4, dim=2) \
1291-
+ widx2 - 1) <= 0.0_wp) then
1292-
p_dal%D12(widx1,widx2,1) = 0.0_wp
1293-
z_lenp2(LBOUND(z_lenp2, dim=1) + widx1 - 1,LBOUND(z_lenp2, dim=2) + \
1294-
widx2 - 1) = SQRT(p_dal%D11(widx1,widx2,1) * p_dal%D22(widx1,widx2,1))
1295-
1296-
! PSyclone CodeBlock (unsupported code) reason:
1297-
! - WHERE not supported because 'p_ens' cannot be converted to an \
1298-
array due to: Transformation Error: The supplied node should be a Reference \
1299-
to a symbol of known type, but 'p_ens%D11_min(:,:)' is 'UnresolvedType'. \
1300-
Consider adding the name of the file containing the declaration of this \
1301-
quantity to RESOLVE_IMPORTS.
1302-
WHERE (z_lenp2(:, :) == 0.0_wp)
1303-
p_dal % D11(:, :, 1) = p_ens % D11_min(:, :)
1304-
p_dal % D22(:, :, 1) = p_ens % D22_min(:, :)
1305-
z_lenp2(:, :) = z_lenp2_min(:, :)
1306-
END WHERE
1307-
end if
1308-
enddo
1309-
enddo""" == code
1310-
13111260
# If enough information is provided, both WHEREs are resolved and nested
13121261
code = ("module my_mod\n"
13131262
"contains\n"

0 commit comments

Comments
 (0)