Re: [f2py] Question about reading fortran codes in Python

Razibul Islam <tamal105-/[email protected]> Sat, 24 Nov 2012 10:10:50 -0800 (PST)
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
--===============2925326727200387526==
Content-Type: multipart/alternative; boundary="-2140344373-2111111887-1353780650=:93730"

---2140344373-2111111887-1353780650=:93730
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hello Hari,=0AThanks for the answer. I am also a new user of f2py. I have a=
 little bit similar problem. I have a code which consists of several file a=
nd function. I have tried to compile single function with f2py and it works=
. But could you please tell me how to compile a complete program with sever=
al files and subroutines?=0AThanks in Advance =0A=0A=0ARazib=0A=0A=0A=0A___=
_____________________________=0A From: Hariprasath Ganesan <hari.dynamics@g=
mail.com>=0ATo: Bahtiyor Zohidov <bahtiyor_zohidov-JGs/[email protected]>; For users of t=
he f2py program <f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]> =0ASent: Tuesday, November 20, 201=
2 3:24 PM=0ASubject: Re: [f2py] Question about reading fortran codes in Pyt=
hon=0A =0A=0AHi Bahithyor,=0A=0ALet we assume you have an executable Fortra=
n file say name.f90 ( I assumed Fortran 90)....Then if you are using Linux =
and I assumed that you have Python,numpy and f2py installed readily...=0A=
=0AOpen your command terminal....type f2py...=0AYou will see an usage messa=
ge on Terminal with version & license detail at the end....=0A=0Athen type =
the command as follows on terminal=0A(eg: My Fortran file - Hello.f90)=0A=
=0A$ f2py -c -m tom Hello.f90=0A=0A--------------------------------------=
=0AIf your Fortran file is bug free then you would see=A0 a file named 'tom=
.so' which is basically a shared object file readable by python will get ge=
nerated....=0A=0AFor more insight I would give you an example...which I tri=
ed first.....=0A=0AMy Fortran code:=0A-------------------------------------=
--------------------------------------=0A=0ASUBROUTINE CHECK (A) INTEGER ::=
 A PRINT*, "YOUR f2py IS WORKING FINE" PRINT*, "ENTERED VALUE IS =3D",A=0AE=
ND SUBROUTINE=0A=0A--------------------------------------------------------=
-----=0A1.) Save the above script as Hello.f90=0A2.) In terminal type " f2p=
y -c -m tom Hello.f90"=0A3.) type ls in terminal=0A4.) you should see "tom.=
so" now=0A5.) type python in terminal=0A6.)you will get into interpreter=0A=
>>> import tom=0A>>> tom.check(2)=0AYOUR f2py IS WORKING  FINE=0AENTERED VA=
LUE IS =3D    2=0A=0A=0A*************** GOOD LUCK *************************=
*=0A=0AREGARDS,=0AHARI.=0A=0A=0A=0AOn Tue, Nov 20, 2012 at 9:59 AM, Bahtiyo=
r Zohidov <bahtiyor_zohidov-JGs/[email protected]> wrote:=0A=0ADear Python users=0A>=0A>I=
 would like to know how to import Fortran codes to Python(Because I have fo=
rtran codes which I should use them in Python) .. I tried to setup f2py. I =
couldn't figure out the steps of setup and what to do. I am beginner in f2p=
y. Please, help me!!!=0A>_______________________________________________=0A=
>f2py-users mailing list=0A>f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]=0A>http://cens.ioc.ee/ma=
ilman/listinfo/f2py-users=0A>=0A>=0A=0A____________________________________=
___________=0Af2py-users mailing list=0Af2py-users-Y4l6ocDipWCuvFJfX82//[email protected]=0Ahttp://cen=
s.ioc.ee/mailman/listinfo/f2py-users
---2140344373-2111111887-1353780650=:93730
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<html><body><div style=3D"color:#000; background-color:#fff; font-family:ti=
mes new roman, new york, times, serif;font-size:12pt">Hello Hari,<br>Thanks=
 for the answer. I am also a new user of f2py. I have a little bit similar =
problem. I have a code which consists of several file and function. I have =
tried to compile single function with f2py and it works. But could you plea=
se tell me how to compile a complete program with several files and subrout=
ines?<br>Thanks in Advance <br><div><br></div><div>Razib<br></div><div></di=
v><div><br></div>  <div style=3D"font-family: times new roman, new york, ti=
mes, serif; font-size: 12pt;"> <div style=3D"font-family: times new roman, =
new york, times, serif; font-size: 12pt;"> <div dir=3D"ltr"> <font face=3D"=
Arial" size=3D"2"> <hr size=3D"1">  <b><span style=3D"font-weight:bold;">Fr=
om:</span></b> Hariprasath Ganesan &lt;[email protected]&gt;<br> <b><=
span style=3D"font-weight: bold;">To:</span></b> Bahtiyor Zohidov
 &lt;bahtiyor_zohidov-JGs/[email protected]&gt;; For users of the f2py program &lt;f2py-u=
sers-Y4l6ocDipWCuvFJfX82//[email protected]&gt; <br> <b><span style=3D"font-weight: bold;">Sent:</span=
></b> Tuesday, November 20, 2012 3:24 PM<br> <b><span style=3D"font-weight:=
 bold;">Subject:</span></b> Re: [f2py] Question about reading fortran codes=
 in Python<br> </font> </div> <br>=0A<div id=3D"yiv1379010275">Hi Bahithyor=
,<br><br>Let we assume you have an executable Fortran file say name.f90 ( I=
 assumed Fortran 90)....Then if you are using Linux and I assumed that you =
have Python,numpy and f2py installed readily...<br><br>Open your command te=
rminal....type f2py...<br>=0AYou will see an usage message on Terminal with=
 version &amp; license detail at the end....<br><br>then type the command a=
s follows on terminal<br>(eg: My Fortran file - Hello.f90)<br><br>$ f2py -c=
 -m tom Hello.f90<br><br>=0A--------------------------------------<br>If yo=
ur Fortran file is bug free then you would see&nbsp; a file named 'tom.so' =
which is basically a shared object file readable by python will get generat=
ed....<br><br>For more insight I would give you an example...which I tried =
first.....<br>=0A<br>My Fortran code:<br>----------------------------------=
-----------------------------------------<br><pre class=3D"yiv1379010275lit=
eral-block">SUBROUTINE CHECK (A)=0A   INTEGER :: A=0A   PRINT*, "YOUR f2py =
IS WORKING FINE"=0A   PRINT*, "ENTERED VALUE IS =3D",A=0AEND SUBROUTINE<br>=
<br>-------------------------------------------------------------<br>1.) Sa=
ve the above script as Hello.f90<br>2.) In terminal type " f2py -c -m tom H=
ello.f90"<br>3.) type ls in terminal<br>4.) you should see "tom.so" now<br>=
=0A5.) type python in terminal<br>6.)you will get into interpreter<br>    &=
gt;&gt;&gt; import tom<br>    &gt;&gt;&gt; tom.check(2)<br>    YOUR f2py IS=
 WORKING  FINE<br>    ENTERED VALUE IS =3D    2<br><br><br>*************** =
GOOD LUCK **************************<br>=0A<br>REGARDS,<br>HARI.<br></pre><=
br><br><div class=3D"yiv1379010275gmail_quote">On Tue, Nov 20, 2012 at 9:59=
 AM, Bahtiyor Zohidov <span dir=3D"ltr">&lt;<a rel=3D"nofollow" ymailto=3D"=
mailto:bahtiyor_zohidov-JGs/[email protected]" target=3D"_blank" href=3D"mailto:bahtiyor_=
zohidov-JGs/[email protected]">bahtiyor_zohidov-JGs/[email protected]</a>&gt;</span> wrote:<br>=0A<bloc=
kquote class=3D"yiv1379010275gmail_quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex;">=0A<div>Dear Python users<br><br>I =
would like to know how to import Fortran codes to Python(Because I have for=
tran codes which I should use them in Python) .. I tried to setup f2py. I c=
ouldn't figure out the steps of setup and what to do. I am beginner in f2py=
. Please, help me!!!</div>=0A=0A<br>_______________________________________=
________<br>=0Af2py-users mailing list<br>=0A<a rel=3D"nofollow" ymailto=3D=
"mailto:f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]" target=3D"_blank" href=3D"mailto:f2py-users=
@cens.ioc.ee">f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]</a><br>=0Ahttp://cens.ioc.ee/mailman/l=
istinfo/f2py-users<br>=0A<br></blockquote></div><br>=0A</div><br>__________=
_____________________________________<br>f2py-users mailing list<br><a ymai=
lto=3D"mailto:f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]" href=3D"mailto:f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]=
">f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]</a><br><a href=3D"http://cens.ioc.ee/mailman/listi=
nfo/f2py-users" target=3D"_blank">http://cens.ioc.ee/mailman/listinfo/f2py-=
users</a><br><br><br> </div> </div>  </div></body></html>
---2140344373-2111111887-1353780650=:93730--


--===============2925326727200387526==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users

--===============2925326727200387526==--