File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,12 @@ def __init__(self,
141141 filename = f"{ filename } .sp"
142142 logger .info (f"Initializing a SPEC object from file: { filename } " )
143143
144+ # If spec has run before, clear the f90wrap array caches.
145+ # See https://github.com/hiddenSymmetries/simsopt/pull/431
146+ # This addresses the issue https://github.com/hiddenSymmetries/simsopt/issues/357
147+ if spec .allglobal ._arrays :
148+ self ._clear_f90wrap_array_caches ()
149+
144150 if tolerance <= 0 :
145151 raise ValueError (
146152 'tolerance should be greater than zero'
@@ -716,6 +722,18 @@ def set_dofs(self, x):
716722 if p is not None :
717723 p .phiedge = x [0 ]
718724
725+ def _clear_f90wrap_array_caches (self ):
726+ """
727+ Clear the f90wrap array caches. This is necessary when a new file is
728+ read after SPEC has run before.
729+
730+ See https://github.com/hiddenSymmetries/simsopt/pull/431
731+
732+ This function is for addressing the issue https://github.com/hiddenSymmetries/simsopt/issues/357
733+ """
734+ spec .allglobal ._arrays = {}
735+ spec .inputlist ._arrays = {}
736+
719737 def init (self , filename : str ):
720738 """
721739 Initialize SPEC fortran state from an input file.
You can’t perform that action at this time.
0 commit comments