#!/bin/bash
## Request name
#MSUB -r DYN_bench
#MSUB -E '--exclude=irene[1325-1346]'
## Number of tasks (=MPI processes) to use
#MSUB -n NUM_MPI
## Number of OpenMP threads
#MSUB -c NUM_OMP
## Elapsed time limit in seconds
#MSUB -T 1800
# account, partition (Xeon/KNL)
#MSUB -A gch0316
#MSUB -q skylake
# Mount  on compute node
#MSUB -m work

function run_standard()
{
    date > gcm.log
    ccc_mprun /ccc/work/cont003/gen7548/dubosth/IRENE/testing/build_mpi_omp/bin/icosa_gcm.exe >> gcm.log
    date >> gcm.log
}

function run_mpmd()
{
    ln -s dynamico.0000.out gcm.log
    ccc_mprun -f mpmd.conf
}

function run_hmpmd()
{
    module load feature/bridge/heterogenous_mpmd
    ln -s dynamico.0000.out gcm.log
    ccc_mprun -f hmpmd.conf
}

cd ${BRIDGE_MSUB_PWD} 

source  /ccc/work/cont003/gen7548/dubosth/IRENE/testing/build_mpi_omp/arch.env
module load ipm
export IPM_REPORT=full
export OMP_NUM_THREADS=$BRIDGE_MSUB_NCORE
export OMP_STACKSIZE=128M

rm -rf dynamico.* gcm.log logs *.nc netcdf
ulimit -s unlimited

#run_standard
run_mpmd
#run_hmpmd

grep MAIN gcm.log
tail -n 50 gcm.log

mkdir -p netcdf
cp gcm.log *.def netcdf
mv *.nc netcdf

mkdir -p logs
cp *.xml logs
cp -pr /ccc/work/cont003/gen7548/dubosth/IRENE/testing/build_mpi_omp/bin/icosa_gcm.exe logs
cp -pr /ccc/work/cont003/gen7548/dubosth/IRENE/testing/DYNAMICO_trunk/src logs
mv gcm.log xios_client_*.err xios_client_*.out dynamico.* logs

touch already_done
