You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.7 KiB

From: ddb at (Douglas du Boulay)
Date: Thu, 29 Apr 1999 09:57:23 +0800
Subject: sharing variables in fortran
References: <> <>
Message-ID: <>
Content-Length: 1364
X-UID: 173
Travis Oliphant wrote:
> > I am wondering if it is possible to coerce python to use
> > memory addresses corresponding to a fortran common block (by way of a c
> > extension)
> > for storage of certain variables.
> There is an exported function you can call from C called
> PyArray_FromDimsAndData that creates a NumPy array from some dimension
> information and a pointer to already allocated memory. There is some
> improving documentation on the C-API to Numeric in the documentation
> recently released for NumPy. See the scientific computing topic section
> of
> I'm not sure how to access a Fortran common block from C at the moment.
Thanks Travis, that at least gets me started
If I can borrow from Greg Landrums reply:
if testblock is my fortran common block,
the equivalent in C is
typedef struct {
float var1;
int var2;
} common1;
common1 testblock; /* a global block that exists for the entire
period of module use */
so if I have a testmodule.c file with:
typedef struct {
/* something is missing here */
} TestObject;
What do I have to put in the TestObject struct to be able to read and write
the var1 and var2 variables
directly in a python script with something along the lines of
self.testblock.var1=2.0 ?
Thanks again.