Re: [f2py] allocatable arrays
Benjamin Kutz <[email protected]> Wed, 17 Nov 2010 14:36:56 +0100
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, thanks for your fast response. You are right. I've made a typing error but only in my e-mail. The correct syntax is: >>>from something import * >>>mod.work() >>>print 'test',mod.test My numpy version: numpy-1.4.1 >>> from something import* >>> mod.work() >>> mod.test I receive no output. With the print statement I receive the wrong values, as listed below. Thanks. Regards, Benjamin Am 17.11.2010 13:48, schrieb Pearu Peterson: > Hi, > > Your example works fine here: > f2py -c wrap.pyf mod.f90 > >>> import something > >>> something.mod.work() > >>> something.mod.test > array([ 60.5, 60.5, 60.5, 60.5, 60.5], dtype=float32) > > What numpy version are you using? > Btw, you are calling mod.test. But it is not callable. So your example > usage must be wrong. > > Pearu > > On 11/17/2010 02:24 PM, Benjamin Kutz wrote: > >> Hi everybody, >> >> I try to work with allocatable arrays. Therfore I ask for your help. >> I have programmed the following code. >> >> Fortran: >> /module mod >> real , dimension (:) , allocatable :: test >> contains >> subroutine work >> integer i >> i=1 >> allocate ( test(5) ) >> do i=1,5 >> test(i)=60.5 >> enddo >> end subroutine/ >> end module mod >> >> wrap.pyf: >> >> /python module something ! in >> interface ! in :something >> module mod ! in : something:mod.F >> real allocatable,dimension(:) :: test >> subroutine work ! in : something:mod.F >> end subroutine work >> end module mod >> end interface >> end python module something >> / >> python: >> >> />>>from something import * >> >>>mod.test() >> >>>print 'test',mod.test >> / >> So far everything works fine. >> Python prints the allocated array, but with the following values: >> >> test [ -1.58818684e-23 3.26132798e+00 -1.58818684e-23 3.26132798e+00 >> -1.58818684e-23] >> >> It is obvious, that those values are wrong. Can anybody see a mistake in >> my syntax? Or is it even not possible to do what I want? >> I know the example in the manual, so please give me further support. >> Thank you very much in advance. >> >> Regards >> Benjamin >> >> >> >> _______________________________________________ >> f2py-users mailing list >> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] >> http://cens.ioc.ee/mailman/listinfo/f2py-users >> > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users >