[Numpy-discussion] String arrays from Python to Fortran

Sturla Molden sturla@molden...
Mon Mar 23 07:25:23 CDT 2009


How did you import the function? f2py? What did you put in your .pyf file?




> *My Fortran code:*
>
> subroutine print_string (a, c)
> implicit none
> character(len=255), dimension(c), intent(inout)::  a
> integer, intent(in) :: c
> integer :: i
> do i = 1, size(a)
> print*, a(i)
> end do
>
> end subroutine print_string
>
> *My Python code:*
>
> from test import *
> from numpy import *
>
> a = "this is the test string."
> a = a.split()
>
> b = a
>
> a = char.array(a, itemsize=1, order = 'Fortran')
>
> print_string(a, len(a)) #this is imported from the compiled Fortran code
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the Numpy-discussion mailing list