#!/bin/sh
#++++++++++++++++
# Copyright:    (C) 2008-2017 UDS/CNRS
# License:       GNU General Public License
#.IDENTIFICATION findsdss
#.LANGUAGE       Bourne shell
#.AUTHOR         Francois Ochsenbein [CDS]
#.ENVIRONMENT    CDSclient Scripts
#.KEYWORDS       UCAC2 catalog
#.VERSION  1.0   22-Nov-2010
#.PURPOSE        Find Stars in SDSS installations at CDS
#.COMMENTS       The "CDSCLIENT" env. variable indicates node ,
#		 eventually preceded by 'http:'
#----------------

D_BIN=`dirname $0`
pgm=`basename $0`
rpc=`basename $0 | sed 's/find//'`
v=""
# No argument is assumed to call for help
test $# -eq 0 && exec $0 -help

while [ $# -gt 0 ]; do
  case "$1" in
     h*)  # Assume help
      exec $0 -help
      ;;
    -h*)  # Differs from standard help
    cat <<===Help
Usage: $pgm [6|7|8|9|...|a|l] plate-mjd-fiber
--------------------------------------------------------------------
   Retrieves the J-name(s) position for spectroscopic SDSS targets
   from a specific or all SDSS data release (default l=last) e.g. 
> $0 306-51637-427         [result from last SDSS-spectro]
> $0 10 306-51637-427      [result from DR10]
> $0 a  306-51637-427      [result from all versions]
--------------------------------------------------------------------
===Help
   exec $D_BIN/find_gen $pgm $rpc -rhelp 
   exit 0
    ;;

  # Version specified
 -1[0-9]) v=`echo $1 | tr -d -`; shift
    ;;
 -[6789]) v=`echo $1 | tr -d -`; shift
    ;;
  1[0-9]) v=`echo $1 | tr -d -`; shift
    ;;
  [6789]) v=$1; shift
    ;;
 -[a]) v="a"; shift
    ;;
  [a]) v="a"; shift
    ;;
  # Use the generic find_gen service
  *)
    echo "#...exec $D_BIN/find_gen $pgm ${rpc}$v $*" 
    exec $D_BIN/find_gen $pgm ${rpc}$v "$@"; exit 0
    ;;
  esac
done
