#!/usr/bin/env bash

AEVOL_CREATE=$1
AEVOL_RUN=$2

cd mini_run
pwd

if [ -e last_gener.txt ]; then
  echo "NOTHING TO DO"
else
  CMD="$AEVOL_CREATE params.in"
  echo "running $CMD from $PWD..."
  $CMD || exit 1

  CMD="$AEVOL_RUN -e 100 -p 0"
  echo "running $CMD from $PWD..."
  $CMD || exit 1

  cp checkpoints/checkpoint_000000100/checkpoint_000000100.ae ckpts/ckpt/my_checkpoint_100.ae
  cp checkpoints/checkpoint_000000100/population_000000100.fa ckpts/ckpt/my_population_100.fa
  cp checkpoints/checkpoint_000000100/setup_000000100.txt     ckpts/ckpt/my_setup_100.txt
  ln -sr ckpts/ckpt/my_population_100.fa ckpts/ckpt/ignored.fa

  ln -sr checkpoints/checkpoint_000000000/checkpoint_000000000.ae ckpts/custom_ckpt/foo.ae
  ln -sr checkpoints/checkpoint_000000000/population_000000000.fa ckpts/custom_ckpt/bar.fasta
  ln -sr checkpoints/checkpoint_000000000/setup_000000000.txt		ckpts/custom_ckpt/baz.txt
fi

cd ..
