stfc / PSyclone

Domain-specific compiler and code transformation system for Finite Difference/Volume/Element Earth-system models in Fortran
BSD 3-Clause "New" or "Revised" License
107 stars 29 forks source link

[PSyData] Kernel Extraction: Function with generic interfaces cause crash #2617

Closed hiker closed 3 months ago

hiker commented 5 months ago

The following LFRic code causes the driver creation to crash:

  USE coordinate_jacobian_mod, ONLY: pointwise_coordinate_jacobian, pointwise_coordinate_jacobian_inverse
...
          jac_inv = pointwise_coordinate_jacobian_inverse(jac, dj)
...
{
      File "/home/joerg/fab-workspace/skeleton-mpif90/source/optimisation/nci-gadi/global.py", line 38, in trans
    extract.apply(kern,{"create_driver": True} )
      File "/home/joerg/work/psyclone/src/psyclone/domain/lfric/transformations/lfric_extract_trans.py", line 152, in apply
    ctu.get_in_out_parameters(nodes, collect_non_local_symbols=True)
      File "/home/joerg/work/psyclone/src/psyclone/psyir/tools/call_tree_utils.py", line 272, in get_in_out_parameters
    self.get_non_local_read_write_info(node_list, read_write_info)
      File "/home/joerg/work/psyclone/src/psyclone/psyir/tools/call_tree_utils.py", line 335, in get_non_local_read_write_info
    return self._resolve_calls_and_unknowns(todo, read_write_info)
      File "/home/joerg/work/psyclone/src/psyclone/psyir/tools/call_tree_utils.py", line 455, in _resolve_calls_and_unknowns
    if sym.is_constant:
    AttributeError: 'GenericInterfaceSymbol' object has no attribute 'is_constant'
}
please check your script

Reason is that at line 455 a generic interface is not detected. A generic interface in case of a call is handled way earlier at the caller-side of things (since in case of a call we have a RoutineSymbol), but in case of a function we can't distinguish between an array access and a function call (without looking into the used module).

hiker commented 4 months ago

See branch 2617_generic_function_driver_creation