Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaned up the way that BIN_OUT is handled when extracting initial conditions. Instead of having a specific new_bin_out argument, just read it in from new_param if it gets passed in
  • Loading branch information
daminton committed Sep 15, 2022
1 parent f481880 commit 4c501a1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def save(self, param_file, framenum=-1, codename="Swiftest"):

return

def initial_conditions_from_bin(self, framenum=-1, new_param=None, new_param_file="param.new.in", new_initial_conditions_file="bin_in.nc", new_bin_out_file=None, restart=False, codename="Swiftest"):
def initial_conditions_from_bin(self, framenum=-1, new_param=None, new_param_file="param.new.in", new_initial_conditions_file="bin_in.nc", restart=False, codename="Swiftest"):
if codename != "Swiftest":
self.save(new_param_file, framenum, codename)
return
Expand All @@ -259,13 +259,9 @@ def initial_conditions_from_bin(self, framenum=-1, new_param=None, new_param_fil
else:
print(f"{self.param['OUT_TYPE']} is an invalid OUT_TYPE file")
return
if new_bin_out_file is None:
new_param['BIN_OUT'] = os.path.basename(self.param['BIN_OUT'])
else:
if restart:
print(f"Restart run with new output file. Copying {self.param['BIN_OUT']} to {new_bin_out_file}")
shutil.copy2(self.param['BIN_OUT'],new_bin_out_file)
new_param['BIN_OUT'] = new_bin_out_file
if self.param['BIN_OUT'] != new_param['BIN_OUT'] and restart:
print(f"Restart run with new output file. Copying {self.param['BIN_OUT']} to {new_param['BIN_OUT']}")
shutil.copy2(self.param['BIN_OUT'],new_param['BIN_OUT'])
new_param['IN_FORM'] = 'XV'
if restart:
new_param['OUT_STAT'] = 'APPEND'
Expand Down

0 comments on commit 4c501a1

Please sign in to comment.