Skip to content

Add implicit interfaces for function hooks in Fortran module#2809

Open
joewallwork wants to merge 5 commits into
2805_fortran-modfrom
2808_fortran-implicit-interfaces
Open

Add implicit interfaces for function hooks in Fortran module#2809
joewallwork wants to merge 5 commits into
2805_fortran-modfrom
2808_fortran-implicit-interfaces

Conversation

@joewallwork
Copy link
Copy Markdown
Collaborator

@joewallwork joewallwork commented May 7, 2026

Closes #2808.
Merges into #2807.

As mentioned in the issue, it turns out that the interfacing to the special Enzyme function hooks can be done using implicit interfaces in Fortran. That is, you can get away without providing an explicit interface block like is done in the examples so long as you declare

external :: __enzyme_autodiff

for example.

Checklist

  • Add to Fortran enzyme module
  • Use in square example

Hooking up in the allocatableArraySimple example will require fixing #2820.

@joewallwork joewallwork self-assigned this May 7, 2026
@joewallwork joewallwork added enhancement New feature or request fortran Related to Enzyme's Fortran bindings labels May 7, 2026
@joewallwork
Copy link
Copy Markdown
Collaborator Author

Huh, looks like ifx doesn't like externals with leading underscores. I hadn't tested this with that compiler yet (just flang).

@joewallwork joewallwork force-pushed the 2808_fortran-implicit-interfaces branch from d249dc7 to 3c11497 Compare May 7, 2026 14:38
@joewallwork joewallwork changed the base branch from main to 2805_fortran-mod May 7, 2026 14:38
@joewallwork
Copy link
Copy Markdown
Collaborator Author

Huh, looks like ifx doesn't like externals with leading underscores. I hadn't tested this with that compiler yet (just flang).

Fixed in 237ebc6 by prepending with f for the Fortran versions of the function hooks.

@joewallwork joewallwork marked this pull request as ready for review May 11, 2026 16:17
@joewallwork joewallwork requested review from vchuravy and wsmoses May 11, 2026 16:18
@joewallwork joewallwork changed the title Use implicit interfaces in Fortran examples Add implicit interfaces for function hooks in Fortran module May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fortran Related to Enzyme's Fortran bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use implicit interfaces in the Fortran examples

1 participant