Re: [f2py] errors in reading fortran codes in python
David Ochoa <[email protected]> Sun, 13 Jan 2013 19:19:19 -0600
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <CADFoYWof9vhNdvdvtfnGQJWk8pMfyreosY9VBhfS9m_yTbHMog@mail.gmail.com> |
--===============2764643030381989946== Content-Type: multipart/alternative; boundary=e89a8ff256446f49cd04d33570f8 --e89a8ff256446f49cd04d33570f8 Content-Type: text/plain; charset=KOI8-R Hi! For newbies (what is f2py? and how it can be easily used?) recommend two sites: From the University of Cambridge: http://www.ucs.cam.ac.uk/docs/course-notes/unix-courses/pythonfortran From the Center for Non Linear Studies: http://cens.ioc.ee/projects/f2py2e/usersguide/index.html I'm not related anyway to those, but i did find them very useful when i started using f2py. David O. On Fri, Jan 11, 2013 at 3:51 AM, Happyman <bahtiyor_zohidov-JGs/[email protected]> wrote: > Dear F2PY users > > I am a newbie in f2py. > > I have the problem with reading fortran code. Let me describe it. I did > the following steps: > 1) I opened python 2.7 > 2) Spererately, in another window I created the following code in notepad: > > > c*************************************************************************** > > SUBROUTINE INDREF (lam,tem,zm) > > c*************************************************************************** > c ce programme calcule l indice de refraction complexe ZM de gouttes > c d eau spheriques pour la longueur d onde LAM et la temperature > c TEM > c > c d apres le modele de PETER S. RAY > c "Broadband complex refractive indexes of ice and water" > c Applied Optics, Vol 11, no 8, August 1972 > > c*************************************************************************** > IMPLICIT DOUBLE PRECISION (A-H,O-Z) > parameter(n1=250,n2=250) > c n1:nombre maximum de donnees, > c n2:nombre maximum de parametres, > > real*8 lam,lams > real*8 num1,num2 > complex*8 zm > data pi/3.14159/ > c coefficients de epss > data cs0,cs1,cs2,cs3,cs4/78.54,25.0,-4.579e-3,1.19e-5,-2.8e-8/ > c coefficients de epsinf > data cinf0,cinf1,cinf2/5.27137,0.0216474,-0.00131198/ > c coefficients de alpha > data cal0,cal1,cal2/-16.8129,273.,0.0609265/ > c coefficients de lams > data cls1,cls2,cls3/0.00033836,2513.98,273./ > c coefficients du terme additif de epsi > data sigma,cad2/12.5664e8,18.8496e10/ > > c calcul des parametres epss,epsinf,alpha,lams > dt=tem-cs1 > epss=cs0*(1.0+cs2*dt+cs3*dt*dt+cs4*dt*dt*dt) > c write(ito,*)'dt,epss ',dt,epss > epsinf=cinf0+cinf1*tem+cinf2*tem*tem > c write(ito,*)'epsinf ',epsinf > alpha=cal2+cal0/(tem+cal1) > c write(ito,*)'alpha ',alpha > lams=cls1*exp(cls2/(tem+cls3)) > c write(ito,*)'lams ',lams > > c calcul des parties reelle (epsr) et imaginaire (epsi) > c de l indice de permittivite > > raplam=lams/lam > c write(ito,*)'raplam ',raplam > arg=alpha*pi/2 > c write(ito,*)'arg ',arg > exp1=1-alpha > exp2=2*exp1 > c write(ito,*)'exp1,exp2 ',exp1,exp2 > > deno=1+2*raplam**exp1*sin(arg)+raplam**exp2 > num1=(epss-epsinf)*(1+raplam**exp1*sin(arg)) > num2=(epss-epsinf)*raplam**exp1*cos(arg) > tad2=sigma*lam/cad2 > c write(ito,*)'deno,num1,num2,tad2 ',deno,num1,num2,tad2 > > epsr=epsinf+num1/deno > epsi=num2/deno+tad2 > > c write(ito,*)' lam,tem,epsr,epsi ', > c + lam,tem,epsr,epsi > > c calcul des parties reelle (nr) et imaginaire (ni) > c de l indice de refraction > > delta=16*(epsr*epsr+epsi) > rac1=(4*epsr+sqrt(delta))/8 > c rac2=(4*epsr-sqrt(delta))/8 > rac1=sqrt(rac1) > rac2=-epsi/(2*rac1) > c write(ito,*)'rac1,rac2 ',rac1,rac2 > zm=cmplx(rac1,rac2) > > return > end > > and I saved it like format *.f > > 3) I tried to read it in python. But it is failed.. Any answers are > appreciated! > > > > > > > > > > > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users > > --e89a8ff256446f49cd04d33570f8 Content-Type: text/html; charset=KOI8-R Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi!<div><br></div><div style>For newbies (what is f2py? an= d how it can be easily used?) recommend two sites:</div><div style>From the= University of Cambridge:</div><div style><a href=3D"http://www.ucs.cam.ac.= uk/docs/course-notes/unix-courses/pythonfortran">http://www.<span class=3D"= " style>ucs</span>.cam.ac.<span class=3D"" style>uk</span>/docs/course-note= s/<span class=3D"" style>unix</span>-courses/<span class=3D"" style>pythonf= ortran</span></a><br> </div><div style>From the Center for Non Linear Studies:</div><div style><a= href=3D"http://cens.ioc.ee/projects/f2py2e/usersguide/index.html">http://<= span class=3D"" style>cens</span>.<span class=3D"" style>ioc</span>.<span c= lass=3D"" style>ee</span>/projects/f2py2e/<span class=3D"" style>usersguide= </span>/index.html</a><br> </div><div style><br></div><div style>I'm not related anyway to those, = but i did find them very useful when i started using f2py.</div><div style>= <br></div><div style>David O.</div></div><div class=3D"gmail_extra"><br> <br> <div class=3D"gmail_quote">On Fri, Jan 11, 2013 at 3:51 AM, Happyman <span = dir=3D"ltr"><<a href=3D"mailto:bahtiyor_zohidov-JGs/[email protected]" target=3D"_blan= k">bahtiyor_zohidov-JGs/[email protected]</a>></span> wrote:<br><blockquote class=3D"g= mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l= eft:1ex"> <div>Dear F2PY users<br><br>I am a newbie in f2py.<br><br>I have the proble= m with reading fortran code. Let me describe it. I did the following steps:= <br>1) I opened python 2.7<br>2) Spererately, in another window I created t= he following code in notepad:<br> <br><p>c*******************************************************************= ********<br> <br> SUBROUTINE INDREF (lam,tem,zm)<br>c**********************= *****************************************************<br>c ce programme cal= cule l indice de refraction complexe ZM de gouttes <br> c d eau spheriques pour la longueur d onde LAM et la temperature <br>c TEM<= br>c<br>c d apres le modele de PETER S. RAY<br>c "Broadband complex re= fractive indexes of ice and water"<br>c Applied Optics, Vol 11, no 8, = August 1972<br> c**************************************************************************= *<br> IMPLICIT DOUBLE PRECISION (A-H,O-Z)<br> parameter(n1=3D250,n2=3D250)<= br>c n1:nombre maximum de donnees,<br>c n2:nombre maximum de parametres,</p= > <p>real*8 lam,lams<br> real*8 num1,num2<br> complex*8 zm<br> data pi/3.1415= 9/<br>c coefficients de epss<br> data cs0,cs1,cs2,cs3,cs4/78.54,25.0,-4.579= e-3,1.19e-5,-2.8e-8/<br>c coefficients de epsinf<br> data cinf0,cinf1,cinf2= /5.27137,0.0216474,-0.00131198/<br> c coefficients de alpha<br> data cal0,cal1,cal2/-16.8129,273.,0.0609265/<br= >c coefficients de lams<br> data cls1,cls2,cls3/0.00033836,2513.98,273./<br= >c coefficients du terme additif de epsi<br> data sigma,cad2/12.5664e8,18.8= 496e10/</p> <p>c calcul des parametres epss,epsinf,alpha,lams<br> dt=3Dtem-cs1<br> epss= =3Dcs0*(1.0+cs2*dt+cs3*dt*dt+cs4*dt*dt*dt) <br>c write(ito,*)'dt,epss &= #39;,dt,epss<br> epsinf=3Dcinf0+cinf1*tem+cinf2*tem*tem <br>c write(ito,*)&= #39;epsinf ',epsinf<br> alpha=3Dcal2+cal0/(tem+cal1) <br>c write(ito,*)'alpha ',alpha<br> = lams=3Dcls1*exp(cls2/(tem+cls3)) <br>c write(ito,*)'lams ',lams</p>= <p>c calcul des parties reelle (epsr) et imaginaire (epsi)<br>c de l indice= de permittivite</p> <p>raplam=3Dlams/lam<br>c write(ito,*)'raplam ',raplam<br> arg=3Dal= pha*pi/2<br>c write(ito,*)'arg ',arg<br> exp1=3D1-alpha<br> exp2=3D= 2*exp1 <br>c write(ito,*)'exp1,exp2 ',exp1,exp2</p><p>deno=3D1+2*ra= plam**exp1*sin(arg)+raplam**exp2 <br> num1=3D(epss-epsinf)*(1+raplam**exp1*sin(arg))<br> num2=3D(epss-epsinf)*ra= plam**exp1*cos(arg)<br> tad2=3Dsigma*lam/cad2<br>c write(ito,*)'deno,nu= m1,num2,tad2 ',deno,num1,num2,tad2</p><p>epsr=3Depsinf+num1/deno<br> ep= si=3Dnum2/deno+tad2</p> <p>c write(ito,*)' lam,tem,epsr,epsi ',<br>c + lam,tem,epsr,epsi</p= ><p>c calcul des parties reelle (nr) et imaginaire (ni)<br>c de l indice de= refraction</p><p>delta=3D16*(epsr*epsr+epsi)<br> rac1=3D(4*epsr+sqrt(delta= ))/8<br> c rac2=3D(4*epsr-sqrt(delta))/8<br> rac1=3Dsqrt(rac1)<br> rac2=3D-epsi/(2*r= ac1) <br>c write(ito,*)'rac1,rac2 ',rac1,rac2<br> zm=3Dcmplx(rac1,r= ac2)<br> <br> return<br> end<br><br>and I saved it like format =9A *.f<br><= br>3) I tried to read it in python. But it is failed.. Any answers are appr= eciated!<br> <br><br>=9A</p><br><br><br><br><br>=9A</div> <br>_______________________________________________<br> f2py-users mailing list<br> <a href=3D"mailto:f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]">f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]</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></blockquote></div><br></div> --e89a8ff256446f49cd04d33570f8-- --===============2764643030381989946== 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 --===============2764643030381989946==--