#!/bin/bash


sim=NPv3.1ada_1982_1991
sim=NPv5.17h_1982_1989
sim=CLOS2_2001_2002
sim=CTRL_2001_2002
sim=BREEZE_2001_2002
sim=SPLITTH1_2001_2002
sim=MIX1_2001_2002

sims="NPv5.3_1982_1989     NPv5.3Mix_1982_1989  NPv5.3Th_1982_1989 NPv5.3Ice_1982_1989  NPv5.3Sto_1982_1989  NPv5.3Tune_1982_1989 AR4.0ada_1982_1991 NPv3.1ada_1982_1991"
sims="NPv5.3_1982_1989"

for sim in $sims ; do



module load python/2.7.5 nco ncview ncl
module load ncl/6.3.0
ulimit -s unlimited
export PYTHONPATH=$PYTHONPATH:~ssenesi/climaf
export PATH=$PATH:~ssenesi/climaf/bin

vars1="pr,hurs,rstt,rlut,rtt,crelt,crest,crett,hfns,hfss,hfls,tas,tasc,tauu,tauv,pslhPa,zg500"
vars2="rsah,rsahcs,rsahcre,rlah,rlahcs,rlahcre,rah,rahcs,rahcre,cress,rsts,rsut,rlutcs,albs,albt,cress,crels,crets,rts,crelt"
vars3="cltcalipso,clhcalipso,clmcalipso,cllcalipso"

for pas in 1 2 3  ; do

\rm -f index_example.html

case $pas in
   3) vars_SE=pr,tas,hfls,hurs,rldscs,rlds,rlus,rsdscs,psl,rsds,rsuscs,rsus,rsutcs,rsut,rlut,rlutcs,tas,tauu,tauv,psl,zg500,crest,crelt,crett,cress,crels,crets ;;
   2) vars_SE=pr,tas,hfls,hurs,rldscs,rlds,rlus,rsdscs,psl,rsds,rsuscs,rsus,rsutcs,rsut,rlut,rlutcs ;;
   1) vars_SE=pr,tas,hfls,hurs,rldscs,rlds,rlus,rsdscs,psl,rsds ;;
esac

vars="$vars_SE"
echo python ./atlas.py -f -v $vars -s $sim
python ./atlas.py -f -v $vars -s $sim

done

echo pdfjam \\ >| jam.sh
grep pdf index_example.html | sed -e "1,2d" -e 's/^.*.HREF..//' -e 's/pdf.*.$/pdf \\/' >> jam.sh
echo --landscape --outfile $sim.pdf >> jam.sh ; chmod +x jam.sh ; ./jam.sh

done
