jameskermode / f90wrap

F90 to Python interface generator with derived type support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array in class gives wrong values in simetrical positions

braghiere opened this issue · comments

I have a fortran module as:

`module gen 
  use ISO_C_BINDING
  use parm

  real (type_r8), allocatable :: xg(:)

  end module gen`

And f2py-f90wrap produces the following python class/def:

` class Gen(f90wrap.runtime.FortranModule):

Module gen
Defined at ../src/gen.f lines 1-1607

@property
def xg(self):
  
    Element xg ftype=real (type_r8) pytype=float
    Defined at ../src/gen.f line 150
    
   
    array_ndim, array_type, array_shape, array_handle = \
        _min3p.f90wrap_gen__array__xg(f90wrap.runtime.empty_handle)
    if array_handle in self._arrays:
        xg = self._arrays[array_handle]
    else:
        xg = f90wrap.runtime.get_array(f90wrap.runtime.sizeof_fortran_t,
                                f90wrap.runtime.empty_handle,
                                _min3p.f90wrap_gen__array__xg)
        self._arrays[array_handle] = xg
    return xg

@xg.setter
def xg(self, xg):
    self.xg[...] = xg`

It looks fine, however when I ask my python main to print it, it gives something like:

1.96938765049 -1.32611814684e+23 1.97448968887 -1.86322722022e+26 1.97959172726 -2.61938127341e+29 1.98469376564 -3.57632946796e+32 1.98979580402 -5.15415206355e+35 1.99489784241 4.20389539297e-45

That looks like a right value followed by a wrong value... Does anyone know what is going on there?

Cheers!