Skip to content

Commit

Permalink
op2-translator: Add intrinsic type spec parameter support
Browse files Browse the repository at this point in the history
  • Loading branch information
bozbez committed Dec 11, 2024
1 parent 16f79a5 commit 892563a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 1 addition & 3 deletions op2/include/op_f2c_prelude.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Span {
return Ptr{&elem, m_data.stride};
}

constexpr Slice<T, N> splice(auto... es) const {
constexpr Slice<T, N> slice(auto... es) const {
static_assert(sizeof...(es) == N);
return Slice(*this, es...);
}
Expand All @@ -105,8 +105,6 @@ class Span {
return *this;
}

constexpr Slice<T, N> slice(auto... es) const { return Slice(*this, es...); }

template<typename S>
constexpr operator Ptr<S>() const { return m_data; }
};
Expand Down
32 changes: 31 additions & 1 deletion translator/op2-translator/fortran/translator/kernels_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,13 @@ def parseTypes(spec_part: f2003.Specification_Part, ctx: Context) -> Dict[str, F
attr_array_spec = None

if attr_spec_list is not None:
dimension_attr_spec = fpu.get_child(attr_spec_list, f2003.Dimension_Attr_Spec)
for attr_spec in attr_spec_list.items:
if isinstance(attr_spec, f2003.Dimension_Attr_Spec):
dimension_attr_spec = attr_spec
elif attr_spec.string == "PARAMETER" or isinstance(attr_spec, f2003.Intent_Attr_Spec):
continue
else:
ctx.error("Unexpected attr spec", attr_spec)

if dimension_attr_spec is not None:
attr_array_spec = parseArraySpec(dimension_attr_spec.items[1], ctx)
Expand Down Expand Up @@ -638,6 +644,30 @@ def translateSpecificationPart(spec_part: f2003.Specification_Part, ctx: Context
continue

if isinstance(node, f2003.Type_Declaration_Stmt):
attr_spec_list = node.items[1]

is_parameter = False
if attr_spec_list is not None:
for attr_spec in attr_spec_list.items:
if attr_spec.string == "PARAMETER":
is_parameter = True

if not is_parameter:
continue

for entity_decl in node.items[2].items:
name = translateGeneric(entity_decl.items[0], ctx)

initialization = entity_decl.items[3]
if initialization is None:
ctx.error("Parameter has no initialization", entity_decl)

if initialization.items[0] != "=":
ctx.error("Unsupported parameter initialization", initialization)

val = translateGeneric(initialization.items[1], ctx)
parameters[name] = val

continue

if isinstance(node, f2003.Data_Stmt):
Expand Down

0 comments on commit 892563a

Please sign in to comment.