#!/bin/bash
#SBATCH -J LH
#SBATCH --exclusive       
###SBATCH -o OUTPUT.oLH_12             
###SBATCH -e OUTPUT.e1                 
#SBATCH --mail-user=villaescusa.francisco@gmail.com     
#SBATCH --mail-type=ALL  
#SBATCH -t 0-56:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=28
#SBATCH --export=ALL
#SBATCH -p cca --qos=cca   

module purge
module load slurm
module load gcc
module load openmpi
module load lib/fftw2/2.1.5-openmpi1
module load lib/openblas
module load lib/gsl
module load lib/hdf5

LPT_code="/mnt/ceph/users/camels/Codes/2lpt/2LPTic"
G3="/mnt/ceph/users/camels/Codes/Gadget_III/P-Gadget3"
root="/mnt/ceph/users/camels/Sims/SIMBA_DM/"

folder=$root"LH_12"
cd $folder

if [ ! -f snap_033.hdf5 ]; then
    if [ ! -f restartfiles/restart.0 ]; then
        cd ICs
        mpirun -np 28 $LPT_code 2LPT.param >> logIC
        cd ..
        mpirun -np 28 $G3 G3.param >> logfile    
    else
        mpirun -np 28 $G3 G3.param 1 >> logfile    
    fi
fi
    