Fortran array in python (f2py?)...

T

tripp

Hello Folks,

I have a fortran program I use to process several satellite images. I
currently output the results to a text file (~750 mb) which is then
read by a perl program that outputs a GIS-ready image using GDAL
(www.gdal.org). There are python libraries for GDAL too.

I'd like to pipe the array directly to python from fortran (instead of
writing it out to a text file). Is it possible to access an in-memory
fortran array with python?

I've looked at f2py, but I could not tell if this was possible.

Thanks.
-TLowe
 
M

MRAB

tripp said:
Hello Folks,

I have a fortran program I use to process several satellite images. I
currently output the results to a text file (~750 mb) which is then
read by a perl program that outputs a GIS-ready image using GDAL
(www.gdal.org). There are python libraries for GDAL too.

I'd like to pipe the array directly to python from fortran (instead of
writing it out to a text file). Is it possible to access an in-memory
fortran array with python?

I've looked at f2py, but I could not tell if this was possible.
How about outputting the results to the Python program via a pipe?
 
T

tripp

How about outputting the results to the Python program via a pipe?

The array I'd like to output is 8500 x 7500. Would that be possible?
I'm NOT RAM limited.
 
R

Robert Kern

Hello Folks,

I have a fortran program I use to process several satellite images. I
currently output the results to a text file (~750 mb) which is then
read by a perl program that outputs a GIS-ready image using GDAL
(www.gdal.org). There are python libraries for GDAL too.

I'd like to pipe the array directly to python from fortran (instead of
writing it out to a text file). Is it possible to access an in-memory
fortran array with python?

I've looked at f2py, but I could not tell if this was possible.

f2py makes Python extension modules that wrap FORTRAN code. Basically, what you
would have to do is use f2py to wrap the subroutines of your FORTRAN program;
your Python program will be the main driver. It is usually recommended that your
Python program allocate the memory in the form of a numpy array, and pass it
into your FORTRAN subroutines to be filled. F77 fixed arrays are well-supported;
F90 allocatable arrays and pointers are not. You may need a fixed array shim
layer around your Fortran 90 code if it uses these features.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
T

tripp

OK. It sounds like it would be easiest for me, then, to dump the
arrays to a binary file (much faster than dumping it to a text) from
the fortran program. Then use f2py to load a fortran module to read
it.?.

How well does python handle binary files? Maybe I could skit the f2py
all together if I can get python to read the fortran binary file...

-TLowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top