<p><br>
El 27/08/2013 21:21, "Kyle Mandli" <<a href="mailto:kyle.mandli@gmail.com">kyle.mandli@gmail.com</a>> escribió:<br>
><br>
> On Tue, Aug 27, 2013 at 1:26 PM, Juan Luis Cano <<a href="mailto:juanlu001@gmail.com">juanlu001@gmail.com</a>> wrote:<br>
>><br>
>><br>
>> El 27/08/2013 17:27, "Kyle Mandli" <<a href="mailto:kyle.mandli@gmail.com">kyle.mandli@gmail.com</a>> escribió:<br>
>><br>
>><br>
>> ><br>
>> > On Tue, Aug 27, 2013 at 6:46 AM, Juan Luis Cano <<a href="mailto:juanlu001@gmail.com">juanlu001@gmail.com</a>> wrote:<br>
>> >><br>
>> >> I'm having some problems to properly build a module written in Fortran<br>
>> >> 90 using numpy.distutils. It only contains one subroutine, but:<br>
>> >><br>
>> >> * If I write a .f90 file with the single subroutine (no module ..<br>
>> >> contains), then f2py tries to compile it using a f77 compiler, and<br>
>> >> that's not what I want.<br>
>> >> * If I put it inside a module definition, then at the final<br>
>> >> compilation stage modulef2pywrapper.c is missing the corresponding<br>
>> >> .mod file and I have to make the build fail, then copy the .mod from<br>
>> >> the temp directory and rebuild. Weird.<br>
>> >><br>
>> >> On the other hand, with the second approach f2py creates a unnecessary<br>
>> >> level of nesting in the corresponding python module and I don't feel<br>
>> >> quite ok with that.<br>
>> >><br>
>> >> What is the right way to do this? I find the documentation on<br>
>> >> numpy.distutils a bit lacking, I almost always find the solution by<br>
>> >> trial and error. I can push the code, it's a short file (part of the<br>
>> >> rewrite of odeint I'm doing in SciPy).<br>
>> >><br>
>> >> Regards<br>
>> >><br>
>> >> Juan Luis Cano<br>
>> >> _______________________________________________<br>
>> >> NumPy-Discussion mailing list<br>
>> >> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
>> >> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
>> ><br>
>> ><br>
>> > You should be able to specify the compiler when invoking f2py, something like:<br>
>> ><br>
>> > f2py --fcompiler=$COMPILER -m $MODULE_NAME -c $SOURCE_FILE<br>
>><br>
>> That won't work since gfortran is used for both F77 and F90. If you look on rules.py in f2py F77 wrappers are generated if the subroutine is not inside a module, and then the compilation fails because it contains invalid statements for F77. Bug?<br>

>><br>
>> Any other suggestions?<br>
>><br>
>> > Kyle<br>
>><br>
>><br>
>> ><br>
>> > _______________________________________________<br>
>> > NumPy-Discussion mailing list<br>
>> > <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
>> > <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
>> ><br>
>><br>
>><br>
>> _______________________________________________<br>
>> NumPy-Discussion mailing list<br>
>> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
>> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
>><br>
><br>
> Can you post your fortran source code?  The other key would be see what f2py thinks it's doing, for instance in the output of f2py there two lines that read:<br>
><br>
> ```<br>
> Reading fortran codes...<br>
> Reading file 'test_file.f90' (format:free)<br>
> ```<br>
><br>
> For the following source code:<br>
><br>
> ```<br>
> subroutine my_func(a, b)<br>
>     <br>
>     implicit none<br>
><br>
>     integer, intent(in) :: a<br>
>     real(kind=8), intent(out) :: b<br>
>     <br>
>     b = real(a, kind=8) * 5.d0<br>
>     <br>
> end subroutine my_func<br>
> ```<br>
><br>
> compiled with `f2py -c test_file.f90 -m my_module`<br>
></p>
<p>Solved! It was as easy as adding both the .pyf and the .f90 to sources, I was having a silly name conflict. I will push the source next week. Thanks!</p>
<p>> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
><br>
</p>