-
Notifications
You must be signed in to change notification settings - Fork 584
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
Modern Fortran Interface #437
Comments
There are Fortran bindings based on However, the nlopt include file for Fortran could still be improved by including explicit interface definitions to provide at least type-safety, see #401 (comment). One would have to do some more elaborate transformation from the nlopt.h header, but this could be challenging to implement in pure CMake. |
Just to elaborate more, the existing Fortran API does not provide any interface definitions for procedures. It does provides access to the return values for successful termination and error codes. Also the algorithm identifier codes are available. The consumer can include these in his program, using the line include 'nlopt.f' The file As @awvwgk has mentioned, it would be difficult to do the same thing for procedures. It is sad that C compilers don't have an option to export Fortran interfaces... |
Here's a related 2017 thread from the Intel Community Forum: https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-solve-using-different-types-of-name-mangling/m-p/1081325 A small fix would also be needed in the NLopt documentation (NLopt_Fortran_Reference.md). As Steve Lionel commented towards the end of that thread:
@xecej4 also commented with:
|
Looks like the fortran interfaces uses Fortran 77. From the fortran side, the compiler doesn't know the function and subroutine interfaces. So, it is really easy to call a function incorrectly, receive no compiler warning, and get a buggy result.
But a much more reliable fortran-c interface could be made with
iso_c_binding
, and interfaces.The text was updated successfully, but these errors were encountered: