f90wrap icon indicating copy to clipboard operation
f90wrap copied to clipboard

Question: Why is `FortranModule` a `Singleton`?

Open smiet opened this issue 6 months ago • 1 comments

I see that the FortranModule class is implemented with __metaclass__=Singleton, such that only one instance can be created.

This creates some issues, if on the python side I want to do things like mymodule1 = mycode.mycode_f90wrapped and mymodule2 = mycode.mycode_f90wrapped.

We are using the FORTRAN module in optimization, and it would be nice to have several instances in memory at the same time, for example to: compare differences between initial and final state; plot the properties of two different objects in one script; run the fortran code with slightly different initial parameters.

The class docstring says

class FortranModule(object):
    """
    Baseclass for Fortran modules

    Metaclass is set to Singleton, so only one instance of each subclass of
    FortranModule can be created.
    """"

Before I go barking at the wrong dead horse, and trying to modify the code to allow for several instances, I wanted to ask what lead to the design choice to implement the module as a Singleton, and if there are insurmountable obstacles to allowing for several top-level modules of f90wrapped modules in python.

smiet avatar Aug 06 '24 08:08 smiet