You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Fortran modules really are singletons, that is all module data is stored only once in memory. This is why I chose to mirror this in Python. If you want several different instances in memory, you will need to use a Fortran derived type, not a module. There is no problem with having multiple instances of FortranDerivedType since this does not implement the singleton pattern.
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
andmymodule2 = 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
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.The text was updated successfully, but these errors were encountered: