From d0b10757bf44b67b938c2b658f9b93519e701375 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sun, 15 Jan 2023 11:38:12 -0500 Subject: [PATCH] Changed so that a fresh swiftest_driver binary is always copied when save or run is executed --- python/swiftest/swiftest/simulation_class.py | 34 +++++++------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index cdd89a98f..009e71470 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -488,20 +488,13 @@ def run(self,**kwargs): warnings.warn(f"Running an integration is not yet supported for {self.codename}",stacklevel=2) return - if self.driver_executable is None or self.binary_source is None: + if not self.binary_source.exists(): msg = "Path to swiftest_driver has not been set!" msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_path)}" warnings.warn(msg,stacklevel=2) return - - if not self.driver_executable.exists(): - if not self.binary_source.exists(): - msg = "Path to swiftest_driver has not been set!" - msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_path)}" - warnings.warn(msg,stacklevel=2) - return - else: - shutil.copy(self.binary_source, self.driver_executable) + else: + shutil.copy(self.binary_source, self.driver_executable) if not self.restart: self.clean() @@ -2897,23 +2890,20 @@ def save(self, if param is None: param = self.param - self.simdir.mkdir(parents=True, exist_ok=True) - + if not self.simdir.exists(): + self.simdir.mkdir(parents=True, exist_ok=True) if codename == "Swiftest": infile_name = Path(self.simdir) / param['NC_IN'] io.swiftest_xr2infile(ds=self.data, param=param, in_type=self.param['IN_TYPE'], infile_name=infile_name, framenum=framenum, verbose=verbose) self.write_param(param_file=param_file,**kwargs) - - if not self.driver_executable.exists(): - if not self.binary_source.exists(): - msg = "Path to swiftest_driver has not been set!" - msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_path)}" - warnings.warn(msg,stacklevel=2) - return - else: - shutil.copy(self.binary_source, self.driver_executable) - + if not self.binary_source.exists(): + msg = "Path to swiftest_driver has not been set!" + msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_path)}" + warnings.warn(msg,stacklevel=2) + return + else: + shutil.copy2(self.binary_source, self.driver_executable) elif codename == "Swifter": if codename == "Swiftest": swifter_param = io.swiftest2swifter_param(param)