Dear all,
I recently (had to) implement a checkpoint version of my K-wave simulation using the C++ binaries. As a small feedback, i would like to say that the manual is a bit weak at this point, at least for me. However, after i figured out the role of the input, output and checkpoint file in this scenario, i do miss some kind of feedback from the binaries telling me that the simulation was ended due to the wall time i defined. This would give the straight forward possibility to rerun from the saved step, if possible. I come up with some Bash magic i'm sharing with you, but i guess it would be nice to have a better solution clearly checking if the simulation is already finished. One clear disadvantage of my solution is that if by coincidence the simulation is finished but needs more time to save data,and thereby taking more time, my script will then assume that it need to run another loop. I guess not a big problem, but 'imperfect' ;)
Anyway, find the script below, reduced to the important part. The required files has to be provided by the command line.
Best Regards from Munich,
Sebastian
#!/bin/bash -le
#Setup files
INPUTFILE=#1
OUTPUTFILE=#2
CHECKPOINT_FILE=#3
CPP_BIN_ADD_PARAM='--p_raw'
#one day in seconds
CHECKPOINT_TIME=86400
loop_rerun=true
while $loop_rerun; do
#date +%s will give you the current time in seconds starting at the 1.1.1970
start_time=<code>date +%s</code>
echo Start time in seconds:
echo $start_time
#Running the Simulation with the c++ binaries
kspaceFirstOrder3D-OMP_SSE4 -i $INPUTFILE -o $OUTPUTFILE $CPP_BIN_ADD_PARAM --checkpoint_interval $CHECKPOINT_TIME --checkpoint_file $CHECKPOINT_FILE
echo End time in seconds:
end_time=<code>date +%s</code>
echo $end_time
#calculate the difference
difference=<code>expr $end_time - $start_time</code>
echo Assumed Runtime:
echo $difference
if [ "$difference" -lt "$CHECKPOINT_TIME" ]; then
loop_rerun=false
echo "End of Checkpoint simulation, finishing"
fi
done