[f2py] module variable in multiple instances

Ed <[email protected]> Mon, 29 Jul 2013 08:14:48 +0000 (UTC)
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Suppose I have the following fortran code:

MODULE MOD_example
   INTEGER :: param
CONTAINS
SUBROUTINE squareparam()
   param=param*param
END SUBROUTINE
END MODULE

Which I then use f2py to compile into FTmod, and define a python class as 
such:

class exampleclass(object):
    def __init__(self, param):
        import FTmod
        self._FTmod=FTmod
        self._FTmod.param=param

    def squareparam(self):
        self._FTmod.squareparam()
        print self._FTmod.param

I then get the following results when trying to use this class:

In [1]:A=exampleclass(1)

In [2]:B=exampleclass(2)

In [3]:A.squareparam()
4

In [4]:B.squareparam()
16

How can I get A and B to exist separately?