#! /bin/sh

#   Nov 21/07 - F. Majaess (Phase out "NEWDOW/HCNDOW/NCCRDHP/NCCRDCP/NEWVIC/HCNVIC"
#                           options support since "lonoplotpgm" is no longer valid)
#   Oct 01/96 - F. Majaess (Added "CCRDCP/NCCRDCP/DOW/NEWDOW/HCDOW/HCNDOW" options)
#   Oct 23/95 - F. Majaess (Added "YORK" option for 'York' site)
#   Jan 17/95 - F. Majaess (Force changing 'QMS' to 'CCRDHP')
#   Dec 22/94 - F. Majaess (Added "CCRDHP/NCCRDHP" options)
#   May 26/94 - F. Majaess (Added "HCVIC/HCNVIC/HCSUN/HCNSUN/" options)
#   Mar 14/94 - F. Majaess (Added "UTOR" option)
#   Oct 25/93 - F. Majaess (Added "NEWSUN" option)
#   Sep 22/93 - F. Majaess (Added "NEWVIC" option)
#   May 22/93 - F. Majaess (Added "VIC" option)
#   Sep 14/92 - T. JANG

#id libncar - setup for plotting programs according to "PLUNIT" option.

#   AUTHOR - T. JANG

#hd PURPOSE - "libncar" script is used to setup for plotting programs according 
#hd           to "PLUNIT" option

#pr PARAMETERS:
#pr
#pr   PRIMARY
#pr
#pr     plunit    = "QMS"   , small size plots (8.5"X11") on QMS LG2200 plotter.(disabled)
#pr               = "QMSBIG", large size plots (11" X17") on QMS LG2200 plotter.(disabled)
#pr               = "QMS8"  , small size plots (8.5"X11") on QMS LG2000 plotter.(disabled)
#pr               = "DOW"   , metacode to be send to Downsview site.
#pr               = "HCDOW" , metacode to be send to Downsview site, hardcopy generated on "lw".
#pr               = "CCRDHP", metacode to be send to Downsview site, hardcopy generated on "lj4".
#pr               = "CCRDCP", metacode to be send to Downsview color printer,
#pr                           hardcopy generated on "tek".
#pr               = "VIC"   , metacode to be send to Victoria node filesystem.
#pr               = "HCVIC" , metacode to be send to Victoria node filesystem,
#pr                           hardcopy generated.
#pr               = "UTOR"  , metacode to be send to University of Toronto filesystem.

#ex EXAMPLE:
#ex
#ex     libncar plunit=VIC

#  * Reset field separators (otherwise those defined in the parwent process will
#  * be used and these may cause problems if they include special charceters
#  * used in this script).

IFS=' '
export IFS

#set -xv

#  * Obtain the specified options.

arg_list=$@
for arg in $arg_list
do
  case $arg in
      plunit=*) eval "$arg"                                              ;;
  esac
done

#  * Set the defaults.

# if [ "$SITE_ID" = 'Victoria' ] ; then
#  plunit=${plunit:=VIC}
# elif [ "$SITE_ID" = 'York' ] ; then
#  plunit=${plunit:=YORK}
# elif [ "$SITE_ID" = 'Utor1' ] ; then
#  plunit=${plunit:=UTOR1}
# else
#  plunit=${plunit:=CCRDHP}
# fi
if [ -z "$plunit" ] ; then
 echo "Abort from LIBNCAR: You must specify a value for plunit!" 
 echo "Abort from LIBNCAR: You must specify a value for plunit!"  >> haltit
 exit 1
fi
plunit=`echo $plunit | tr '[a-z]' '[A-Z]'`
case $plunit in
  QMS|QMSBIG|QMS8) plunit='CCRDHP' ;;
  SUN)             plunit='DOW' ;;
  NEWSUN)          plunit='NEWDOW' ;;
  HCSUN)           plunit='HCDOW' ;;
  HCNSUN)          plunit='HCNDOW' ;;
  * )              break ;;
esac
if [ "$plunit" = "NEWVIC" -o "$plunit" = "NEWDOW" -o "$plunit" = "HCNVIC" \
    -o "$plunit" = "HCNDOW" -o "$plunit" = "NCCRDHP" \
                            -o "$plunit" = "NCCRDCP"  ] ; then
 echo "Abort from LIBNCAR: Invalid plunit=$plunit !"
 echo "Abort from LIBNCAR: Invalid plunit=$plunit !" >> haltit
 exit 2
fi

#  * create the dummy file to turn off overlays

(\rm -f AAAZMAP || : )

cat << woof > AAAZMAP
  This is a dummy file controling overlays under NCARLIBCCRN setup.
woof

cat << woof > dummy

woof

#  * delete the dummy file to turn on overlays
#  * if plunit = QMS, QMSBIG or QMS8

if [ "$plunit" = "QMS" -o "$plunit" = "QMSBIG" -o "$plunit" = "QMS8" ] ; then
   (\rm -f AAAZMAP || : )
   txtplot input=dummy
fi

exit
