#!/bin/bash -l
#PBS -N DYNLAM
#PBS -q std
#PBS -l nodes=1:ppn=64
#PBS -l walltime=05:00:00
#PBS -V
#PBS -l mem=60gb,vmem=60gb

# sample job script to run in the batch system on camelot.ipsl.polytechnique.fr
# submit this job with :
# qsub jobs/camelot.pbs

#Jobs start in the HOME directory, cd to submitted directory
cd "$PBS_O_WORKDIR"

############################################################
NCPU=`wc -l < $PBS_NODEFILE`
echo ------------------JOB SUMMARY--------------------------
echo 'PBS OUT: Job allocated on: '${NCPU}' cpu(s)'
echo 'PBS OUT: Job running on the following node(s): '
cat $PBS_NODEFILE
echo -------------------------------------------------------
echo PBS OUT: Job running on: $PBS_O_HOST
echo PBS OUT: Originating queue: $PBS_O_QUEUE
echo PBS OUT: Executing queue: $PBS_QUEUE
echo PBS OUT: Work directory: $PBS_O_WORKDIR
echo PBS OUT: Execution mode: $PBS_ENVIRONMENT
echo PBS OUT: Job identifier: $PBS_JOBID
echo PBS OUT: Job name: $PBS_JOBNAME
echo PBS OUT: Node file: $PBS_NODEFILE
echo PBS OUT: Current home directory: $PBS_O_HOME
echo PBS OUT: PATH= $PBS_O_PATH
echo -------------------------------------------------------
############################################################

function run()
{
    NI=8
    NJ=4
    NX=$1
    NY=$2
    NDAVIES=$3
    DT=$4
    rm -f output_dynamico_native.nc xios_client* 
    ./python.sh serial py/write_Cartesian_mesh.py --nx=$NX --ny=$NY --Lx=$NX --Ly=$NY
    ./python.sh mpi $((NI*NJ)) py/Baroclinic_3D_ullrich.py --mpi_ni $NI --mpi_nj $NJ --T 3600 --N 360 --ny $NY --nx $NX --dt $DT --Davies_N1 $NDAVIES --Davies_N2 $NDAVIES
}


#run 400 84 6 300. # high-res
run 200 42 3 300. >gcm.log # low-res

# ./python.sh mpi $((NI*NJ)) py/Baroclinic_3D_ullrich.py --mpi_ni $NI --mpi_nj $NJ --T 3600 --N 360 --ny 84 --nx 400 --dt 300. --Davies_N1 6 --Davies_N2 6
#./python.sh mpi $((NI*NJ)) py/Baroclinic_3D_ullrich.py --mpi_ni $NI --mpi_nj $NJ --T 3600 --N 360 --ny 72 --nx 400 --dt 300. --Davies_N1 3 --Davies_N2 3
#./python.sh mpi $((NI*NJ)) py/Baroclinic_3D_ullrich.py --mpi_ni $NI --mpi_nj $NJ --T 3600 --N 288 --ny 42 --nx 200 --dt 300. --Davies_N1 6 --Davies_N2 6
#./python.sh mpi $((NI*NJ)) py/Baroclinic_3D_ullrich.py --mpi_ni $NI --mpi_nj $NJ --T 3600 --N 288 --ny 42 --nx 200 --dt 300. --Davies_N1 6 --Davies_N2 6

############################################################
