Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling AST from Fortran 90 #22

Open
jvo203 opened this issue Jun 4, 2024 · 3 comments
Open

calling AST from Fortran 90 #22

jvo203 opened this issue Jun 4, 2024 · 3 comments

Comments

@jvo203
Copy link

jvo203 commented Jun 4, 2024

It seems the Fortran bindings in AST are terribly, terribly outdated and cannot be used together with, for example, Fortran 90 or newer.

The 'AST_PAR' file uses old fixed-form FORTRAN 77. Even after converting it to newer free-form Fortran 90 and including it in a new Modern Fortran 2018 project, the AST functions cannot be called from within Fortran.

Frankly, the entire Fortran interface to AST needs a complete overhaul to make use of modern C <--> Fortran 2018 interoperability, each AST function should have a proper interface to C with all the function arguments listed explicitly etc., instead of being plain INTEGER types, and the Fortran interface file should be made a Fortran module.

It is a lot of work for the AST team but, as things stand at the moment, it is impossible to use Starlink AST in Fortran right now. I've been trying to switch from WCSLIB to AST in my Fortran 2018 code but had to give up.

Is Fortran not loved anymore? Surely this is not the case.

@jvo203
Copy link
Author

jvo203 commented Jun 4, 2024

FYI, Fortran 2003 defines ISO C Binding: https://fortranwiki.org/fortran/show/iso_c_binding
An example: https://fortranwiki.org/fortran/show/c_interface_module

Just as you did with the F77 interface file, it should be possible to programmatically generate a Modern Fortran interface module file ast.f90 from a C header file (there are just too many functions to convert manually). One needs to be careful about passing function arguments by value or reference as and when required.

Then for legacy F77 systems one would use the existing INCLUDE 'AST_PAR', and for Fortran 2003 and newer (there is already Fortran 2023) simply use the new ast module defined in ast.f90, i.e. USE ast .

@timj
Copy link
Member

timj commented Jun 4, 2024

This seems like a great idea. Unfortunately I'm not sure if there is any effort available to do any of it. I don't think EAO have any use of or experience of Fortran 90 that would motivate them to do this. I don't think any Starlink contributor knows any of the new Fortran dialects either.

@jvo203
Copy link
Author

jvo203 commented Jun 4, 2024

Yeah, that's the problem! Insufficient resources and a general decline in the use of Fortran these days. Younger people are not inclined to learn Fortran anymore...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants