No subject
Wed Jun 30 14:15:50 EEST 2010
<br>
=A0$ f2py -m _mymod -h mymod.pyf mymod.f90<br>
<br>
As Pearu mentioned, even the allocatable arrays are then exposed to<br>
python as _mymod.mymod.abc and _mymod.mymod.deg.<br>
<br>
Juergen<br>
<br>
<br>
<br>
Benjamin Kutz wrote (Friday 16 July 2010 14:12:05):<br>
><br>
> Hi,<br>
><br>
> thanks for your fast answer.<br>
> I still didn`t got the point. I just want to share these allocatable<b=
r>
> data arrays between the first and the second subroutine.<br>
> I also knew the example out of the f2py manual, but I couldn`t realise=
<br>
> it in my code, due to my limited knowledge in python and wrapping.<br>
> Do you mean, that I have to write a fortran module for each allocatabl=
e?<br>
> What does this module look like?<br>
> At the moment I allocate in Fortan at the beginning with:<br>
><br>
> =A0 =A0 =A0 =A0subroutine init(abc,deg)<br>
> =A0 =A0 =A0 =A0integer =A0max, max2<br>
> =A0 =A0 =A0 =A0max=3D ...<br>
> =A0 =A0 =A0 =A0max2=3D...<br>
> =A0 =A0 =A0 =A0real =A0 , dimension (:) =A0, allocatable =A0:: abc<br>
> =A0 =A0 =A0 =A0real =A0 , dimension (:,:) =A0, allocatable =A0:: deg<b=
r>
> =A0 =A0 =A0 =A0allocate (abc(max))<br>
> =A0 =A0 =A0 =A0allocate (deg(max,max2))<br>
> =A0 =A0 =A0 =A0call initialxyz (abc,deg)<br>
> =A0 =A0 =A0 =A0end<br>
><br>
> =A0 =A0 =A0 =A0subroutine calc(abc,deg)<br>
> =A0 =A0 =A0 =A0call solve(abc,deg)<br>
> =A0 =A0 =A0 =A0if ( allocated( abc ) ) then<br>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0deallocate (abc)<br>
> =A0 =A0 =A0 =A0...<br>
> =A0 =A0 =A0 =A0endif<br>
><br>
> I wrap both routines and want to call them one after another from pyth=
on.<br>
> Maybe you can help me with a little example? What does the foo.pyf hav=
e<br>
> to look like?<br>
> The problem is, that I have to wrap with f2py -c foo.pyf *.o. I can=
9;t<br>
> wrap it directly from the foo.f90 routine.<br>
><br>
> Greetings<br>
> Ben<br>
><br>
> _______________________________________________<br>
> f2py-users mailing list<br>
> <a href=3D"mailto:f2py-users at cens.ioc.ee">f2py-users at cens.ioc.ee</a><b=
r>
> <a href=3D"http://cens.ioc.ee/mailman/listinfo/f2py-users" target=3D"_=
blank">http://cens.ioc.ee/mailman/listinfo/f2py-users</a><br>
><br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Fri, 16 Jul 2010 17:13:04 +0200<br>
From: Benjamin Kutz <<a href=3D"mailto:kutz at iag.uni-stuttgart.de">kutz at i=
ag.uni-stuttgart.de</a>><br>
Subject: Re: [f2py] Wraping Fortran code with allocatable arrays.<br>
To: <a href=3D"mailto:f2py-users at cens.ioc.ee">f2py-users at cens.ioc.ee</a><br=
>
Message-ID: <<a href=3D"mailto:4C407700.8070004 at iag.uni-stuttgart.de">4C=
407700.8070004 at iag.uni-stuttgart.de</a>><br>
Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed<br>
<br>
Am 16.07.2010 15:30, schrieb J?rgen Wieferink:<br>
> Hi,<br>
><br>
> module mymod<br>
> =A0 =A0implicit none<br>
> =A0 =A0real, dimension(:), allocatable :: abc<br>
> =A0 =A0real, dimension(:,:), allocatable :: deg<br>
> contains<br>
> =A0 =A0subroutine init<br>
> =A0 =A0 =A0implicit none<br>
> =A0 =A0 =A0! do stuff on abc, deg<br>
> =A0 =A0end subroutine init<br>
> =A0 =A0subroutine calc<br>
> =A0 =A0 =A0implicit none<br>
> =A0 =A0 =A0! do stuff on abc, deg<br>
> =A0 =A0end subroutine calc<br>
> end module mymod<br>
><br>
> > From this, you can easily generate the wrapper mymod.pyf from<br>
><br>
> =A0 =A0$ f2py -m _mymod -h mymod.pyf mymod.f90<br>
><br>
> As Pearu mentioned, even the allocatable arrays are then exposed to<br=
>
> python as _mymod.mymod.abc and _mymod.mymod.deg.<br>
><br>
> Juergen<br>
><br>
><br>
><br>
> Benjamin Kutz wrote (Friday 16 July 2010 14:12:05):<br>
><br>
>> Hi,<br>
>><br>
>> thanks for your fast answer.<br>
>> I still didn`t got the point. I just want to share these allocatab=
le<br>
>> data arrays between the first and the second subroutine.<br>
>> I also knew the example out of the f2py manual, but I couldn`t rea=
lise<br>
>> it in my code, due to my limited knowledge in python and wrapping.=
<br>
>> Do you mean, that I have to write a fortran module for each alloca=
table?<br>
>> What does this module look like?<br>
>> At the moment I allocate in Fortan at the beginning with:<br>
>><br>
>> =A0 =A0 =A0 =A0 subroutine init(abc,deg)<br>
>> =A0 =A0 =A0 =A0 integer =A0max, max2<br>
>> =A0 =A0 =A0 =A0 max=3D ...<br>
>> =A0 =A0 =A0 =A0 max2=3D...<br>
>> =A0 =A0 =A0 =A0 real =A0 , dimension (:) =A0, allocatable =A0:: ab=
c<br>
>> =A0 =A0 =A0 =A0 real =A0 , dimension (:,:) =A0, allocatable =A0:: =
deg<br>
>> =A0 =A0 =A0 =A0 allocate (abc(max))<br>
>> =A0 =A0 =A0 =A0 allocate (deg(max,max2))<br>
>> =A0 =A0 =A0 =A0 call initialxyz (abc,deg)<br>
>> =A0 =A0 =A0 =A0 end<br>
>><br>
>> =A0 =A0 =A0 =A0 subroutine calc(abc,deg)<br>
>> =A0 =A0 =A0 =A0 call solve(abc,deg)<br>
>> =A0 =A0 =A0 =A0 if ( allocated( abc ) ) then<br>
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 deallocate (abc)<br>
>> =A0 =A0 =A0 =A0 ...<br>
>> =A0 =A0 =A0 =A0 endif<br>
>><br>
>> I wrap both routines and want to call them one after another from =
python.<br>
>> Maybe you can help me with a little example? What does the foo.pyf=
have<br>
>> to look like?<br>
>> The problem is, that I have to wrap with f2py -c foo.pyf *.o. I ca=
n't<br>
>> wrap it directly from the foo.f90 routine.<br>
>><br>
>> Greetings<br>
>> Ben<br>
>><br>
>> _______________________________________________<br>
>> f2py-users mailing list<br>
>> <a href=3D"mailto:f2py-users at cens.ioc.ee">f2py-users at cens.ioc.ee</=
a><br>
>> <a href=3D"http://cens.ioc.ee/mailman/listinfo/f2py-users" target=
=3D"_blank">http://cens.ioc.ee/mailman/listinfo/f2py-users</a><br>
>><br>
>><br>
><br>
> _______________________________________________<br>
> f2py-users mailing list<br>
> <a href=3D"mailto:f2py-users at cens.ioc.ee">f2py-users at cens.ioc.ee</a><b=
r>
> <a href=3D"http://cens.ioc.ee/mailman/listinfo/f2py-users" target=3D"_=
blank">http://cens.ioc.ee/mailman/listinfo/f2py-users</a><br>
><br>
Hi,<br>
<br>
wonderful! As I can see your example does not differ much from that one<br>
in the manual.<br>
But I don't know why, now I found out how to do it ;)! Maybe it was the=
<br>
heat or the friday afternoon;) or just my "slow" brain :)<br>
Thanks for your quick help and have a nice weekend!<br>
<br>
Greetings<br>
Ben<br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
f2py-users mailing list<br>
<a href=3D"mailto:f2py-users at cens.ioc.ee">f2py-users at cens.ioc.ee</a><br>
<a href=3D"http://cens.ioc.ee/mailman/listinfo/f2py-users" target=3D"_blank=
">http://cens.ioc.ee/mailman/listinfo/f2py-users</a><br>
<br>
<br>
End of f2py-users Digest, Vol 65, Issue 5<br>
*****************************************<br>
</blockquote></div><br></div>
--0016e65aeed6563734048be93138--
More information about the f2py-users
mailing list