call functions from a shared fortran library in python

前端 未结 3 1339
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 15:19

I would like to call some functions from a Fortran shared library in Python. I have found some links on the net and read them, and according what I found, I should do

<
3条回答
  •  猫巷女王i
    2020-12-23 16:03

    For f2py (from NumPy) to work, borrow both the mult.f90 and add.f90 examples from @samplebias. From a shell, compile the Python importable shared libraries:

    f2py -c -m mult mult.f90
    f2py -c -m add add.f90
    

    Now use them in Python:

    >>> import add
    >>> import mult
    >>> add.addtwo(4, 5)
    9
    >>> mult.multiply(4, 5)
    20
    

提交回复
热议问题