Skip to content

Commit

Permalink
Merge pull request #5 from AlexHeide/resub_test
Browse files Browse the repository at this point in the history
finalize restart_iteration step saving
  • Loading branch information
AlexHeide authored Aug 27, 2020
2 parents 867aeec + f804fdd commit 17a7bcf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,27 @@ def copy_old_steps(self, restart_iteration, xtpl_restart):
while os.path.exists(f'{self.path}/STEP{itr:>02d}'):
itr += 1

restart_itr = 0
while os.path.exists(f'{self.path}/{itr}_opt'):
restart_itr = 1
while os.path.exists(f'{self.path}/{restart_itr}_opt'):
restart_itr += 1
restart_itr -= 1 # counts too high

# Move highest indexed group up. Delete. move previous up to replace delete.
# Delete STEP0X for X >= restart index

if restart_itr:
for index in range(restart_itr, 0, -1): # stop before 0
for index in range(restart_itr, 0, -1): # stop before 0.
shutil.copytree(f'{index}_opt',
f'{index + 1}_opt')
# copy tree must be able to perform a mkdir for python <= 3.8
shutil.rmtree(f'{index}_opt')

for step_idx in range(itr):
shutil.copytree(f'{self.path}/STEP{step_idx:>02d}',
f'{self.path}/1_opt/STEP{step_idx:>02d}')
if step_idx >= restart_iteration:
shutil.rmtree(f'{self.path}/STEP{step_idx:>02d}')

shutil.copyfile(f'{self.path}/output.dat', f'{self.path}/1_opt/output.dat')
with open(f'{self.path}/output.dat', 'w+'):
pass # clear file

0 comments on commit 17a7bcf

Please sign in to comment.