#!/bin/sh

#-------------------------------------------------------------

  MDL="${HOME}/hysplit"
  MET="${HOME}/Tutorial/captex"
  MAP="${MDL}/graphics/arlmap"
  INP="hysplit2.bin"
  OUT="${MDL}/working"

  cd $OUT

  if [ ! -f $INP ];then
     echo "Missing input file: $INP"
     echo "Run model to generate output file!"
     exit
  fi
  echo "###$0 ###"

#--------------------------------------------------------------

  echo "'TITLE&','### $0 ###&'"  >LABELS.CFG

  ${MDL}/exec/concplot -i$INP -j${MDL}/graphics/arlmap -z80 -x1.0E+12 -upg
  if [[ "$OSTYPE" == "darwin"* ]]; then
     cp concplot.ps tempfile.ps
     ${MDL}/exec/catps2ps -m -itempfile.ps -oconcplot.ps
     rm -f tempfile.ps
     open concplot.ps   
  else
     gs concplot.ps   
  fi
  echo "Create animation: concplot.gif"
  convert -trim +repage -density 140 -loop 100 -delay 50 -dispose Background concplot.ps concplot.gif
  echo "Enter to continue ..."; read x

  echo "Creating particle plot ..."
  ${MDL}/exec/parxplot -iPARDUMP -j$MAP -k1 -z80 -n10
  echo "Create animation: parxplot.gif"
  convert -trim +repage -density 140 -loop 100 -delay 50 -dispose Background parxplot.ps parxplot.gif
  if [[ "$OSTYPE" == "darwin"* ]]; then
     cp parxplot.ps tempfile.ps
     ${MDL}/exec/catps2ps -m -itempfile.ps -oparxplot.ps
     rm -f tempfile.ps
     open parxplot.ps   
  else
     gs parxplot.ps   
  fi
  echo "Enter to continue ..."; read x

  ${MDL}/exec/isochron -i$INP -j$MAP -d6 -n10 -t0.0
  if [[ "$OSTYPE" == "darwin"* ]]; then
     open toa.ps        
  else
     gs toa.ps 
  fi
  echo "Enter to continue ..."; read x

  ${MDL}/exec/gridplot -i$INP -ogridplot -j$MAP -c1.0E+12 -d2.0 -a1 -upg -l-1.0
  echo "Create animation: gridplot.gif"
  convert -trim +repage -density 140 -loop 100 -delay 50 -dispose Background gridplot.ps gridplot.gif
  if [[ "$OSTYPE" == "darwin"* ]]; then
     cp gridplot.ps tempfile.ps
     ${MDL}/exec/catps2ps -m -itempfile.ps -ogridplot.ps
     rm -f tempfile.ps
     open gridplot.ps   
  else
     gs gridplot.ps   
  fi
