#!/bin/csh -f

# Routine to read in monthly nc files
# make into timeseries for tropical SST.

set echo verbose

setenv CASE_NAME b31.002.2
setenv FILE_IN nino_anom.nc
set ncl_home = /fis/cgd/home/yeager/ccsm_diag/ncl
set work_dir = /ptmp/yeager/$CASE_NAME


if (! -e /ptmp/yeager/$CASE_NAME) then
    mkdir /ptmp/yeager/$CASE_NAME
endif

if (! -e $work_dir) then
    mkdir $work_dir
endif

cd $work_dir

if (! -e  ${FILE_IN}) then
   scp ahab.cgd:/project/ccsmweb/d1/yeager/${CASE_NAME}/time_series/nino_anom.nc ${FILE_IN} || echo ' --FAILED-- ' && exit 1
endif

echo "Performing ENSO ncl code"

ncl < $ncl_home/enso_plot_klts.ncl

convert -crop 0x0+5+5 -density 85 ${CASE_NAME}.ENSO.nino3.4.analysis.ps ${CASE_NAME}.ENSO.nino3.4.analysis.png
convert -crop 0x0+5+5 -density 85 ${CASE_NAME}.ENSO.nino3.analysis.ps ${CASE_NAME}.ENSO.nino3.analysis.png
exit 0
