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

Export minpack API via bind(c) #29

Merged
merged 8 commits into from
Feb 23, 2022
Merged

Export minpack API via bind(c) #29

merged 8 commits into from
Feb 23, 2022

Conversation

awvwgk
Copy link
Member

@awvwgk awvwgk commented Feb 5, 2022

Define C API of minpack:

  • declare exports to C for procedures used in SciPy:
    • hybrd as minpack_hybrd
    • hybrj as minpack_hybrj
    • lmder as minpack_lmder
    • lmdif as minpack_lmdif
    • lmstr as minpack_lmstr (not used in SciPy)
    • chkder as minpack_chkder
  • wrapper procedures (not used in SciPy) are also exported
    • hybrd1 as minpack_hybrd1
    • hybrj1 as minpack_hybrj1
    • lmder1 as minpack_lmder1
    • lmdif1 as minpack_lmdif1
    • lmstr1 as minpack_lmstr1
  • c-compatible callback prototypes
    • minpack_func callback used by minpack_hybrd / minpack_hybrd1
    • minpack_func2 callback used by minpack_lmdif / minpack_lmdif1
    • minpack_fcn_hybrj callback used by minpack_hybrj / minpack_hybrj1
    • minpack_fcn_lmder callback used by minpack_lmder / minpack_lmder1
    • minpack_fcn_lmstr callback used by minpack_lmstr / minpack_lmstr1
  • utility function minpack_dpmpar to access machine constants
  • use value instead of intent(in) for export if possible
  • all C procedures accept a void* data pointer which is available in the callback

Open for discussion:

  • include keyword names in C prototypes? (currently not included)

Todo:

  • add tests for C API (just port Fortran tests to C?)

    • test minpack_hybrd
    • test minpack_hybrd1
    • test minpack_hybrj
    • test minpack_hybrj1
    • test minpack_lmder
    • test minpack_lmder1
    • test minpack_lmdif
    • test minpack_lmdif1
    • test minpack_lmstr
    • test minpack_lmstr1
    • test minpack_chkder

Closes #15

@awvwgk awvwgk force-pushed the bind-c branch 3 times, most recently from de8c29c to 6fa9287 Compare February 5, 2022 16:40
@awvwgk awvwgk marked this pull request as ready for review February 5, 2022 16:51
@awvwgk awvwgk requested a review from a team February 5, 2022 16:52
@awvwgk awvwgk added the bindings: C Export of C API via bind(c) label Feb 5, 2022
@awvwgk awvwgk force-pushed the bind-c branch 3 times, most recently from 923e47d to 5e2fc7c Compare February 5, 2022 19:13
@ivan-pi
Copy link
Member

ivan-pi commented Feb 15, 2022

Is there a good reason to export dpmpar?

@awvwgk
Copy link
Member Author

awvwgk commented Feb 15, 2022

Needed them to write the tests in C, as there is not really an equivalent available there.

@awvwgk
Copy link
Member Author

awvwgk commented Feb 15, 2022

Has anyone time to contribute a test or two for the C-API? We should at least test the simplified drivers before merging this PR.

@ivan-pi
Copy link
Member

ivan-pi commented Feb 16, 2022

Sure, I'll see if I can make a test or two for hybrj(1) and and lmdif(1).

@awvwgk
Copy link
Member Author

awvwgk commented Feb 21, 2022

This PR is ready to go, we now have full coverage of the C API.

@awvwgk awvwgk merged commit 9965c23 into fortran-lang:main Feb 23, 2022
@awvwgk
Copy link
Member Author

awvwgk commented Feb 23, 2022

I'll go ahead and merge this PR. We can always change things later if there is something missing.

@awvwgk awvwgk deleted the bind-c branch February 23, 2022 21:53
@awvwgk awvwgk added this to the v2.0.0 milestone Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings: C Export of C API via bind(c)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C Interface
3 participants