#!/bin/bash
#SBATCH --job-name=752
#SBATCH -o OUTPUT.o752
#SBATCH -e OUTPUT.e752  
#SBATCH --partition=general
#####SBATCH --partition=preempt
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=48
#SBATCH --export=ALL
#SBATCH -t 7-00:00    

module purge
module load slurm
module load gcc
module load openmpi
module load lib/fftw2/2.1.5-openmpi1
module load lib/gsl
module load lib/hdf5
LPT_code="/simons/scratch/fvillaescusa/hydro_DL/Software/2lpt/2LPTic"
G3="/simons/scratch/fvillaescusa/hydro_DL/Gadget_III/P-Gadget3"

root="/simons/scratch/fvillaescusa/hydro_DL/N-body/SIMBA/"

folder=$root"752"
cd $folder

if [ ! -f snap_033.hdf5 ]; then

    if [ ! -f sim_stopped ]; then

        if [ ! -f restartfiles/restart.0 ]; then

           cd ICs
           mpirun -n 8 $LPT_code 2LPT.param >> logIC
           cd ..
           mpirun -n 48 $G3 G3.param >> logfile    

        else

           mpirun -n 48 $G3 G3.param 1 >> logfile    

        fi
    fi
fi
    