Skip to content

Commit

Permalink
Merge pull request #464 from ecmwf-ifs/naml-fortran-c-adjustments
Browse files Browse the repository at this point in the history
Transpile: Split C-kernel generation from ISO-C wrapper generation
  • Loading branch information
reuterbal authored Jan 9, 2025
2 parents 1a09ea9 + 9d07cfc commit b0a2344
Show file tree
Hide file tree
Showing 7 changed files with 965 additions and 650 deletions.
11 changes: 9 additions & 2 deletions loki/transformations/tests/test_array_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
LowerConstantArrayIndices, remove_explicit_array_dimensions,
add_explicit_array_dimensions
)
from loki.transformations.transpile import FortranCTransformation
from loki.transformations.transpile import (
FortranCTransformation, FortranISOCWrapperTransformation
)


@pytest.fixture(scope='function', name='builder')
Expand Down Expand Up @@ -546,8 +548,13 @@ def validate_routine(routine):
f2c_routine = Subroutine.from_source(fcode, frontend=frontend)
f2c = FortranCTransformation()
f2c.apply(source=f2c_routine, path=tmp_path)
f2cwrap = FortranISOCWrapperTransformation()
f2cwrap.apply(source=f2c_routine, path=tmp_path)
libname = f'fc_{f2c_routine.name}_{start_index}_{frontend}'
c_kernel = jit_compile_lib([f2c.wrapperpath, f2c.c_path], path=tmp_path, name=libname, builder=builder)
c_kernel = jit_compile_lib(
[tmp_path/f'{f2c_routine.name}_fc.F90', tmp_path/f'{f2c_routine.name}_c.c'],
path=tmp_path, name=libname, builder=builder
)
fc_function = c_kernel.transf_flatten_arr_fc_mod.transf_flatten_arr_fc
f2c_x1, f2c_x2, f2c_x3, f2c_x4 = init_arguments(l1, l2, l3, l4, flattened=True)
fc_function(f2c_x1, f2c_x2, f2c_x3, f2c_x4, l1, l2, l3, l4)
Expand Down
1 change: 1 addition & 0 deletions loki/transformations/transpile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
# nor does it submit to any jurisdiction.

from loki.transformations.transpile.fortran_c import * # noqa
from loki.transformations.transpile.fortran_iso_c_wrapper import * # noqa
from loki.transformations.transpile.fortran_python import * # noqa
389 changes: 24 additions & 365 deletions loki/transformations/transpile/fortran_c.py

Large diffs are not rendered by default.

Loading

0 comments on commit b0a2344

Please sign in to comment.