Компиляция модуля Fortran с помощью f2py

У меня есть модуль Fortran, который я пытаюсь скомпилировать с помощью f2py (см. ниже). Когда я удаляю объявление модуля и оставляю подпрограмму в файле саму по себе, все работает нормально. Однако если модуль объявлен так, как показано ниже, я получаю следующие результаты:

> f2py.py -c -m its --compiler=mingw itimes-s2.f
...
Reading fortran codes...
    Reading file 'itimes-s2.f' (format:fix,strict)
crackline: groupcounter=1 groupname={0: '', 1: 'module', 2: 'interface', 3: 'subroutine'}
crackline: Mismatch of blocks encountered. Trying to fix it by assuming "end" statement.
...
c:\users\astay13\appdata\local\temp\tmpgh5ag8\Release\users\astay13\appdata\local\temp\tmpgh5ag8\src.win32-3.2\itsmodule.o:itsmodule.c:(.data+0xec): undefined reference to `itimes_'
collect2: ld returned 1 exit status

Чем отличается компиляция модуля или подпрограммы в f2py? Может быть, я забыл что-то важное в модуле, что вызывает проблемы у f2py? Обратите внимание, что модуль компилируется нормально, когда я использую только gfortran.

Программное обеспечение: Windows 7; gcc, gfortran 4.6.1 (MinGW); python 3.2.2; f2py v2

itimes-s2.f:

  module its

  contains

  subroutine itimes(infile,outfile)

    implicit none

    ! Constants
    integer, parameter :: dp = selected_real_kind(15)

    ! Subroutine Inputs
    character(*), intent(in) :: infile
    character(*), intent(in) :: outfile

    ! Internal variables
    real(dp) :: num
    integer :: inu
    integer :: outu
    integer :: ios

    inu = 11
    outu = 22

    open(inu,file=infile,action='read')
    open(outu,file=outfile,action='write',access='append')

    do
      read(inu,*,IOSTAT=ios) num
      if (ios < 0) exit

      write(outu,*) num**2
    end do

  end subroutine itimes

  end module its
6
задан astay13 19 December 2011 в 17:02
поделиться