f2pyf90wrap error`未定义的符号:u test_mod_mod p`

2024-05-08 20:15:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用f90wrap来包装一些Fortran,它是基于f2py构建的。(我可以使用f2py,但我想扩展一些代码来使用派生类型)。在

下面是一个简单的.f90测试代码,我已经尝试包装:

module test_mod

   integer::p

end module

我用以下命令编译和包装:

^{pr2}$

当我跑步时:

python test.py

在生成的test.py文件上:

import _test
import f90wrap.runtime
import logging

class Test_Mod(f90wrap.runtime.FortranModule):
    """
    Module test_mod


    Defined at test.f90 lines 1-3

    """
    @property
    def p(self):
        """
        Element p ftype=integer pytype=int


        Defined at test.f90 line 3

        """
        return _test.f90wrap_test_mod__get__p()

    @p.setter
    def p(self, p):
        _test.f90wrap_test_mod__set__p(p)

    def __str__(self):
        ret = ['<test_mod>{\n']
        ret.append('    p : ')
        ret.append(repr(self.p))
        ret.append('}')
        return ''.join(ret)

    _dt_array_initialisers = []


test_mod = Test_Mod()

我得到以下错误:

  File "test.py", line 1, in <module>
    import _test
ImportError: _test.cpython-35m-x86_64-linux-gnu.so: undefined symbol: __test_mod_MOD_p

在研究了f90 wrap repo并查看了makefile中的一些测试之后,我发现下面的.f90文件上的相同过程不会产生相同的问题:

module testextends_mod


PUBLIC

    ! -----------------------------------------------
    type Superclass
        ! IN: Ask subroutine to stop in the middle.
        integer :: stop_at = -1     ! -1 --> don't stop
    end type Superclass

    type, extends(Superclass) :: Subclass1
        integer :: nl
    end type

    type, extends(Superclass) :: Subclass2
        integer :: nl
    end type

end module

有人知道我到底做错了什么吗?在


Tags: pytestimportselfmoddeftypeinteger