Re: [f2py] Frotran, GDAL and f2py

Robin <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
On Mon, Mar 1, 2010 at 11:21 PM, Jamie Lahowetz <[email protected]> wrote:
> Thanks for the reply. Its nice to know that there are other packages for
> shapefile manipulation. GDAL is an opensource GIS package that does
> everything I need it to do so there is no real benifit in learning a new
> package. My first question still stands though: How do I call python from
> fortran using f2py?

I don't think you really can. f2py is designed to allow calling
fortran code from python as a python extension. I think there is a
facility for callbacks to python from the fortran code, but I don't
think that can be used in a standalone way (without calling the
fortran code as an extension from a python process).

I think the idea is one can write the wrapping stuff (including file
io etc.) in Python which is faster to write but slower to run, and
then implement any computationally expensive inner loops in fortran
which are called easily from the python process.

I don't know of any way to call python from a standalone fortran
program (other than through a shell). In C it is possible to embed a
python interpreter in another process, to use python from a c program,
but I am not aware of anything similar for fortran. Possibly you could
embed Python in your own C library and interact with that from fortran
but I think it would be quite complicated.

Cheers

Robin

>
> On Mon, Mar 1, 2010 at 2:59 PM, James Boyle <[email protected]> wrote:
>>
>> As part of Jeff Whittaker's Basemap toolkit for matplotlib, there is a
>> ability to read/write shapefiles.
>> The ability to write shapefiles in not cited in the online docs, but there
>> is an example in the download.
>> I have only used the read so YMMV.
>> Jeff is a meteorologist and his stuff is very useful in that field.
>> http://matplotlib.sourceforge.net/
>> http://matplotlib.sourceforge.net/users/toolkits.html
>> --Jim
>> On Mar 1, 2010, at 12:27 PM, Jamie Lahowetz wrote:
>>
>> I have a fortran program that creates storm tracks. I can output these
>> tracks into a csv file but it would be really helpful if I could just create
>> shapefiles instead. So heres my question(s):
>> 1. Im very new to f2py and from what I read, python can be called from
>> fortran using f2py. I looked at the examples in the documentation but dont
>> fully understand how to really do this. Can anyone help me out by maybe
>> explaining it or perhaps share an example of python being called from a
>> Fortran program.
>> 2. Is it even possible to do the above using the GDAL python bindings?
>>
>> --
>> Jamie Ryan Lahowetz
>> University of Nebraska - Lincoln
>> Graduate Student - Geosciences
>> 402.304.0766
>> [email protected]
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Jamie Ryan Lahowetz
> University of Nebraska - Lincoln
> Graduate Student - Geosciences
> 402.304.0766
> [email protected]
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users
>
>
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.