Skip to content

Commit

Permalink
Transpile: Remove redundant interface generation for module functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Jan 9, 2025
1 parent 9f9b67a commit 9b3e114
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions loki/transformations/transpile/fortran_iso_c_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,28 +457,6 @@ def generate_iso_c_wrapper_module(module, use_c_ptr=False, language='c'):
wrappers += [getter]
wrapper_module.contains = ir.Section(body=(ir.Intrinsic('CONTAINS'), *wrappers))

# Create function interface definitions for module functions
intfs = []
for fct in module.subroutines:
if fct.is_function:
intf_fct = fct.clone(bind=f'{fct.name.lower()}')
intf_fct.body = ir.Section(body=())

intf_args = []
for arg in intf_fct.arguments:
# Only scalar, intent(in) arguments are pass by value
# Pass by reference for array types
value = isinstance(arg, sym.Scalar) and arg.type.intent and arg.type.intent.lower() == 'in'
kind = iso_c_intrinsic_kind(arg.type, intf_fct, use_c_ptr=use_c_ptr)
ctype = SymbolAttributes(arg.type.dtype, value=value, kind=kind)
dimensions = arg.dimensions if isinstance(arg, sym.Array) else None
var = sym.Variable(name=arg.name, dimensions=dimensions, type=ctype, scope=intf_fct)
intf_args += (var,)
intf_fct.arguments = intf_args
sanitise_imports(intf_fct)
intfs.append(intf_fct)
spec.append(ir.Interface(body=(as_tuple(intfs),)))

# Remove any unused imports
sanitise_imports(wrapper_module)
return wrapper_module
Expand Down

0 comments on commit 9b3e114

Please sign in to comment.