2016-07-08 27 views
15

Ho alcuni file Fortran che vorrei usare nei file Python. Ho usato il comando C: \ Python27 \ python.exe setup.py build_ext --inplace --fcompiler = g95. Il mio file setup.py contiene il seguente codice:Errore di impostazione di Numpy: argomento formale extra

import sys, os 
extra_link_args = [] 
extra_link_args = ['-framework', 'accelerate'] 
from numpy.distutils.core import setup, Extension 
opt_flags = ['-g', '-fbounds-check', '-I/usr/include/'] 
files1 = ['particle_solvers/fbsl_sim_fmod.f90', 
      'particle_solvers/fbsl_parts_fmod.f90', 
      'particle_solvers/fbsl_poisson_fmod.f90', 
      'particle_solvers/fbsl_convol_fmod.f90', 
      'particle_solvers/fbsl_lbfr_parts_fmod.f90', 
      'particle_solvers/fbsl_ltp_parts_fmod.f90', 
      'particle_solvers/fbsl_pusher_fmod.f90', 
      ] 
ext1 = Extension(name='_fbsl_f90', 
       sources=files1, 
       extra_compile_args=opt_flags, 
       extra_link_args=extra_link_args) 
setup(name="_fbsl_f90", 
     version='0.1', 
     description="Hidden", 
     author="Hidden", 
     author_email='Hidden', 
     url='', 
     ext_modules=[ext1]) 

Ma mi hanno ottenuto i seguenti errori:

g95.exe:f90: build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:211 
    &ef2pywrap, smooth_heaviside, r) 
            1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_smooth_heaviside' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:13 
    &nf2pywrap, t) 
       1 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:217 
    &nf2pywrap, f_exact_is_known, t) 
       2 
Error: Differing types REAL(8) and LOGICAL(4) in formal arguments at (1) and (2) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:223 
    &inal_is_knownf2pywrap, f_exact_final_is_known) 
          1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_f_exact_final_is_known' 
at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:228 
    &2pywrap, f_exact_initial, eta_0, eta_1) 
             1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_f_exact_initial' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:235 
    &, t, eta_0, eta_1) 
        1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_f_exact' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:243 
    &rap, f_exact_final, eta_0, eta_1) 
           1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_f_exact_final' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:250 
    &_field_is_givenf2pywrap, velocity_field_is_given) 
           1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_velocity_field_is_given' 
at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:255 
    &ine_u0, x0, x1) 
        1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_affine_u0' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:262 
    &ine_u1, x0, x1) 
        1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_affine_u1' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:269 
    &p, quadratic_u0, t, x0, x1) 
           1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_quadratic_u0' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:277 
    &p, quadratic_u1, t, x0, x1) 
           1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_quadratic_u1' at (1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:285 
    &w_0f2pywrap, bwd_affine_flow_0, t, x0, x1) 
              1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_bwd_affine_flow_0' at (1 
) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:293 
    &w_1f2pywrap, bwd_affine_flow_1, t, x0, x1) 
              1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_bwd_affine_flow_1' at (1 
) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:301 
    &ic_flow_0f2pywrap, bwd_quadratic_flow_0, t, x0, x1) 
                 1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_bwd_quadratic_flow_0' at 
(1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:309 
    &ic_flow_1f2pywrap, bwd_quadratic_flow_1, t, x0, x1) 
                 1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_bwd_quadratic_flow_1' at 
(1) 
In file build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90:317 
    &0, x1) 
     1 
Error: Extra formal argument for 'f2pywrap_fbsl_sim_f90_bggk_a' at (1) 
error: Command "C:\Users\QUENTIN\bin\g95.exe -fno-second-underscore -O -Ibuild\s 
rc.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\in 
clude -IC:\Python27\PC -c -c build\src.win32-2.7\_fbsl_f90-f2pywrappers2.f90 -o 
build\temp.win32-2.7\Release\build\src.win32-2.7\_fbsl_f90-f2pywrappers2.o -fmod 
=build\temp.win32-2.7\Release\ -Ibuild\temp.win32-2.7\Release\" failed with exit 
status 1 

non capisco perché devo quegli errori argomento extra formali. Come posso risolverli? Sto lavorando su Windows 7 con Python 2.7 e il compilatore g95.

EDIT: Okay, per semplificare, Ecco un esempio del mio codice Fortran:

module test_f90 

implicit none 

real *8 :: delta 

contains 

real*8 function test_f(r) 
    real*8, intent(in) :: r 
    test_f = 0.5*(1 + erf(r/delta)) 
end function 

end module test_f90 

Quando uso il comando C: \ Python27 \ python.exe setup.py build_ext --inplace --fcompiler = G95 con questo file setup.py:

import sys 

extra_link_args = [] 

from numpy.distutils.core import setup, Extension 

opt_flags = ['-g', '-fbounds-check', '-I/usr/include/'] 


files1 = ['test_fmod.f90', 
      ] 


ext1 = Extension(name='_test_f90', 
       sources=files1, 
       extra_compile_args=opt_flags, 
       extra_link_args=extra_link_args) 


setup(name="_test_f90", 
     version='0.1', 
     description="test module", 
     author="Hidden", 
     author_email='Hidden', 
     url='', 
     ext_modules=[ext1]) 

io ho questo file Fortran generato da f2py:

!  -*- f90 -*- 
!  This file is autogenerated with f2py (version:2) 
!  It contains Fortran 90 wrappers to fortran functions. 

     subroutine f2pywrap_test_f90_test_f (test_ff2pywrap, r) 
     use test_f90, only : test_f 
     real(kind=8) r 
     real(kind=8) test_ff2pywrap 
     test_ff2pywrap = test_f(r) 
     end subroutine f2pywrap_test_f90_test_f 

     subroutine f2pyinittest_f90(f2pysetupfunc) 
     use test_f90, only : delta 
     interface 
     subroutine f2pywrap_test_f90_test_f (test_ff2pywrap, test_f, r) 
     real(kind=8) test_f 
     real(kind=8) r 
     real(kind=8) test_ff2pywrap 
     end subroutine f2pywrap_test_f90_test_f 
     end interface 
     external f2pysetupfunc 
     call f2pysetupfunc(delta,f2pywrap_test_f90_test_f) 
     end subroutine f2pyinittest_f90 

bu t Ho ancora questo errore:

g95.exe:f90: build\src.win32-2.7\_test_f90-f2pywrappers2.f90 
In file build\src.win32-2.7\_test_f90-f2pywrappers2.f90:15 

     subroutine f2pywrap_test_f90_test_f (test_ff2pywrap, test_f, r) 
                    1 
Error: Extra formal argument for 'f2pywrap_test_f90_test_f' at (1) 
error: Command "C:\Users\QUENTIN\bin\g95.exe -fno-second-underscore -O -Ibuild\s 
rc.win32-2.7 -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\in 
clude -IC:\Python27\PC -c -c build\src.win32-2.7\_test_f90-f2pywrappers2.f90 -o 
build\temp.win32-2.7\Release\build\src.win32-2.7\_test_f90-f2pywrappers2.o -fmod 
=build\temp.win32-2.7\Release\ -Ibuild\temp.win32-2.7\Release\" failed with exit 
status 1 
+2

Tali errori sembrano derivare da subroutine Fortran chiamate errate. Certo, è solo un'ipotesi perché non ci hai mostrato il codice. –

+1

Mostraci il codice Fortran che causa questi errori. – Ares

+0

Ho modificato il mio post con un pezzo del mio codice Fortran – Vegeson

risposta

0

Ci dispiace ma appare il supporto f2py involucro è rotto, in cui dichiara una funzione per due volte con le firme contrastanti: prima 2 poi 3 argomenti formali. Non è chiaro che questa versione funzioni per te come desiderato, anche se potresti trovare utile lavorare sugli esempi delle prime voci di f2py ToC.

Problemi correlati