#!/bin/bash
# Submit this script as : sbatch ./[script-name]
#SBATCH -A m3525
#SBATCH -q regular
#SBATCH -t 48:00:00
#SBATCH -N 2
#SBATCH  --job-name=ncclimo_ctrl
#SBATCH  --output=job%j 
#SBATCH  --exclusive 
#SBATCH  --constraint=knl,quad,cache
  
#ssh dtn01.nersc.gov
#screen
#bash
#source ~/.bashrc.ext
#conda activate e3sm_unified_latest 
#source /global/common/software/e3sm/anaconda_envs/base/envs/e3sm_unified_latest.csh 
#exit


source /global/common/software/e3sm/anaconda_envs/load_latest_e3sm_unified_pm-cpu.sh

workdir="/pscratch/sd/z/zhan391/seacrogs_scratch"
hpssdir="/home/z/zhan391/SEACROGS/training_data"

i=1 
for dir in e3sm_diag e3sm_diag_old evaluation rmse_bar share_python offline_test Green_Function New_Training;do 
 echo $workdir/$dir
 cd $workdir/$dir
 if [ ! -d ${workdir}/$dir/zstash ]; then
   zstash create --hpss=$hpssdir/$dir --maxsize 128 . >& zstash_create.log &
 else 
   zstash update --hpss=$hpssdir/$dir  >& zstash_create.log & 
 fi
 k=$((i % 3))
 if [ $k == 0 ];then 
   wait
 else 
   i=$((i+1))
 fi 
done 
wait 
exit
