Re: [f2py] Dynamic Arrays in f2py

<[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Yes, I tried it. But i dont want to use global variables, and when i try to pass them as a parameter:

  integer, allocatable :: indx(:) !outgoing parameter
                             1
Error: ALLOCATABLE attribute conflicts with DUMMY attribute at (1)



 
Hi,

Have you considered using allocatable arrays? See, for example,

http://cens.ioc.ee/projects/f2py2e/usersguide/index.html#allocatable-arrays

HTH,
Pearu

[email protected] wrote:
> hello,
> 
> I have a small program and would like to use its functionality with f2py:
> 
> module example_mod
> 	contains
> 	subroutine init(indx,x)
> 		integer, pointer :: indx(:) !outgoing parameter
> 		integer, dimension(:,:), intent(in) :: x !incoming parameter
> 			
> 		print *, "shape(x) = ",shape(x)
> 		allocate(indx(10))
> 		do i=1, 10
> 			indx(i) = i
> 		enddo
> 	end subroutine init
> end module example_mod
> 
> program test
> 	use example_mod
> 	integer,pointer ::indx(:)
> 	double precision, pointer :: x(:,:)
> 	
> 	allocate(x(3,3))
> 	call init(indx,x)
> 	print *, "indx(5) = ", indx(5)
> end program test
> 
> 
> gfortran -c example_mod.f90
> gfortran test.f90 -o test example_mod.o
> ./test
> 
>  shape(x) =            3           3
>  indx(5) =            5
> 
> 
> 
> 
> Now i compiled with f2py:
> f2py -m main -h --overwrite-signature main.pyf example_mod.f90
> f2py -c --fcompiler=gfortran main.pyf example_mod.f90
> 
> It worked, but i dont know how to call the function, i alwas got memory errors.
> Unfortunately i just read that pointer are not supported by f2py. Is there another way to realize it?
> Maybe passing the whole arrays? 
> 
> Thanks in advance
> Malte Mauelshagen
> 
> -----------------------------------------------------------------------------
> Deutsches Zentrum für Luft- und Raumfahrt e.V.
> in der Helmholtz-Gemeinschaft
> Ausbildung - Duale Hochschule Baden-Württemberg
> 
> Malte Mauelshagen
> 
> Lilienthalplatz 7
> 38108 Braunschweig
> Tel.: 0531/295-2483
> 
> 
> _______________________________________________
> 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

_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users
winmail.dat (application/ms-tnef, 3.6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.