Re: [f2py] problems with parameters and common blocks
Pearu Peterson <[email protected]> Mon, 15 Aug 2011 14:19:08 +0300
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <CAPpwKcyFZEEJ6nvLS56DS2-3QGWmvOnSgoGV_kbaNWkgD2Euxg@mail.gmail.com> |
On Mon, Aug 15, 2011 at 10:38 AM, teichmann.clemens < teichmann.clemens-gM/[email protected]> wrote: > Hi Pearu, > > thanks for that advice, but the actual size of the array is dynamic between > two or more runs. In my example it has the size four, but it could also be > smaller/bigger up to max value. At the moment I'm trying to append dummy > values to the arrays and check the internal computation. If this doesn't > work, i need to change the size of the arrays in the modul (after it was > wrapped) or dynamic wrap the fortran program, which could be really hard. > > Hi Ben, > > A little example to demonstrate my problem. > this is my common.f > integer someCount > integer maxg > parameter (maxg = 22) > real*8 c(maxg) > common /asd/ > * c, > * someCount > > and the subroutine > subroutine foo() > include 'common.f' > integer sum > sum = 0 > > do 111 i = 1,someCount > sum = sum + c(i) > 111 continue > > return > end > > the variable "someCount" and the array "c" is set in the python program. > someCount can now have e.g. the value four, because there are just four > elements to compute. Because of the parameter maxg, the modul wants a list > with exact 22 entries to set the array "c" > > If you someCount in Python then you can set the common block array via slicing: For example, someCount = common.asd.someCount common.asd.c[:someCount] = [1,2,3,4] # assuming someCount=4 HTH, Pearu _______________________________________________ f2py-users mailing list f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] http://cens.ioc.ee/mailman/listinfo/f2py-users