【问题标题】:f2py-f90wrap error `undefined symbol: __test_mod_MOD_p`f2py-f90wrap 错误`未定义的符号:__test_mod_MOD_p`
【发布时间】:2018-01-26 11:13:17
【问题描述】:

我正在尝试使用基于 f2py 的 f90wrap 包装一些 Fortran。 (我可以使用 f2py,但我想扩展一些代码以使用派生类型)。

这是我尝试包装的简单.f90 测试代码:

module test_mod

   integer::p

end module

我已使用以下命令进行编译和包装:

gfortran -fPIC -c test.f90

f90wrap -m test test.f90

f2py-f90wrap -c -m _test f90wrap_*.f90

当我跑步时:

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 存储库并查看了其中的一些测试的 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

谁能看到我到底做错了什么?

【问题讨论】:

    标签: python fortran f2py


    【解决方案1】:

    以下作品:

      gfortran -c -O3 -fPIC test.f90
      f90wrap -v -m test test.f90
      f2py-f90wrap -c -m _test f90wrap_test.f90 test.o
    

    【讨论】:

      猜你喜欢
      • 2021-07-23
      • 1970-01-01
      • 1970-01-01
      • 2012-06-19
      • 2012-10-10
      • 2013-10-22
      • 2014-06-01
      • 2015-11-13
      • 1970-01-01
      相关资源
      最近更新 更多