[f2py] COMMON BLOCK revisited
pavanakumar mohanamuraly <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <C7AC38BA.4AB8%[email protected]> |
Hi I dug the user mailing list and found this post on COMMON BLOCKS: -------- thread message ---------------------------------------- > Pearu, > > I have the same common blocks in different modules. I'd like to make > common blocks from both modules reference the same variable. I can't > seem to do it. Because it is not possible. > ................. No. And it is not due to f2py limitations. Namely COMMON blocks are 'common' only for routines that are inside of the same executable (e.g. shared module). And each time a module is loaded, a memory is allocated for COMMON blocks and pointers inside Fortran routines (inside that module) point to these COMMON blocks, roughly speaking. If you load another module, it will have its own COMMON blocks and pointers in its routines will point to that. > ................ Sorry, not possible :( COMMON blocks just are sticked to one executable and I don't see any ways how they could be shared between different executables. ------ end of thread message -------------------------------- I need to wrap a f77 code which has common block declared in almost every subroutine. There are inputs like max dimensions of arrays in the common block used by every subroutine. So explicitly using assignment to pass the value to every common block in each subroutine is not worth it (but definitely a solution). Changing the code by removing the common block is one thing, but are there other ways ? Referencing a numpy variable to the variable in the COMMON BLOCK is impossible according to the above post. And assignment of a numpy array to the wrapped COMMON BLOCK array (I believe) copies the contents and does not reference (or is there a way). >> import WarppedSubroutine >> NumpyReal = 0.1 >> WrappedSubroutine.CommonBlock.RealInBlock = NumpyReal I would appreciate if some one can give some hints. Regards, -- Pavanakumar Mohanamuraly