# Modified for Mac OSX 10.5 2/05/2012  Ron Ghosh  Vesrion 2.0
# started 29-Oct-1995  R.E. Ghosh
#
# to start from Terminal ( Applications/Utilities/Terminal )
# > tcsh            (change to tcshell)
# > cd current_work_directory
# > source ~/sans2012/sasprogmac/sassetup
#       (Assuming files are unzipped in the HOME directory                 )
#       (this should be an absolute path, not relative to the workdirectory)
#========================================================================
#
# The directory of programs is found from the source command line
# (eventually allowing simultaneous storage of versions for different systems)
#
# In this version of sassetup (Macintosh 1.4, 10.5, 10.6 specific) this is 
# set in the next line, and this may have to be edited if the distribution is not
# unzipped in the HOME directory 
#
# The following tries to ensure absolute path is given for SAS_DIR
#
setenv SAS_DIR {!!:1:h}
setenv WD $PWD
cd $SAS_DIR
setenv SAS_DIR $PWD
cd $WD
echo "  SAS_DIR has been set to $SAS_DIR "
echo "  Current work directory is $WD "

#
#
setenv PGPLOT_DIR $SAS_DIR
# This present file contains environment variables primarily, rather than
# executables which are all in SAS_DIR
setenv DYLD_LIBRARY_PATH $SAS_DIR
# this sets search path for libgfortran.2.0.0.dylib etc to local directory
echo
echo "in sassetup"
echo " "
stty intr ^C
echo " Current work directory is "
pwd
echo ""
setenv SAS_INSTRUMENT d22
setenv SAS_DATA_PATH "$PWD/"
echo "Instrument Name and Raw data directory"
echo "======================================"
echo "Current instrument name, SAS_INSTRUMENT, is $SAS_INSTRUMENT"
echo " "
echo " to modify SAS_INSTRUMENT give command (eg)"
echo " setenv SAS_INSTRUMENT d11 "
echo " "
echo "Currently location of raw SANS data, SAS_DATA_PATH, is  $PWD/"
echo " "
echo " to modify SAS_DATA_PATH give command "
echo " setenv SAS_DATA_PATH newdirectoryname/    (NOTE trailing /)"
echo " "
echo "--------------------------------------"
if ( $?NEW_SAS_SETUP == 0 ) then
# remaining steps 1,2,3,4,5 will be skipped
  setenv SAS_EXTRA_G g2x
  echo "SAS_DIR  is " $SAS_DIR
# to get non-US date formats on some systems
  unsetenv LANG
#echo "#1  setup this directory into default path"
  echo $SAS_DIR" is being added to path"
  set path = ( .  $SAS_DIR $path )
  rehash
#echo "#2  environment variables for sans programs"
  setenv SAS_CHECK limited
  setenv SAS_DECOMPRESS "gunzip -c "
# for graphics:
  setenv PGPLOT_XW_WIDTH 0.3
# (this sets the initial pgplot window size as 0.3 of full screen)  
  setenv PGPLOT_ILL_DEV_1 /xserv
  setenv PGPLOT_ILL_DEV_2 /vcps
  setenv PGPLOT_ILL_DEV_3 /null
  setenv PGPLOT_ILL_PPAGE 2
  setenv PGPLOT_ILL_PGRUNFIGDISP figdisp
  setenv PGPLOT_DIR $SAS_DIR
#echo "#3"
alias xplots "wish $SAS_DIR/xplots.bat"
alias xpolly "wish $SAS_DIR/xpolly.bat"
alias mill   "wish $SAS_DIR/xmill.bat"
alias xmplot "wish $SAS_DIR/xmplot.bat"
alias xreg   "wish $SAS_DIR/xreg.bat"
alias clickfit "wish $SAS_DIR/clickfit.bat"
alias clickfit_m "wish $SAS_DIR/clickfit_m.bat"
#
# Local printers are not set up initially here, 
#unlike at the ILL using a pseudo- pri command
  setenv NEW_SAS_SETUP completed
  echo "_______________________________________________________"
  echo " "
  echo "                       ILL - SANS"
  echo "Currently SAS_INSTRUMENT is set to "$SAS_INSTRUMENT
  echo "Currently SAS_DATA_PATH is "$SAS_DATA_PATH
  echo " WWW information  "
  echo " www.ill.eu/computing-for-science/cs-software/all-software/sans"
  echo " "
  echo "For documentation (Manual, Updates, Notes, and"
  echo "for most recent PC-Windows programs (containing Prop updates)"
  echo "and Linux/Macintosh programs see ftp://ftp.ill.fr/pub/cs/sans "
  echo " "
  echo "XML output of regrouped data is enabled; SAS_EXTRA_G is "$SAS_EXTRA_G
  echo "______________________________________________________"
else
  echo NEW_SAS_SETUP is $NEW_SAS_SETUP "(nothing has been done)"
endif
# start X11 graphics before leaving (OSX)
echo " "
echo " X-window now starting... "
echo " "
$SAS_DIR/pgcprtx
echo "end of sassetup"
echo
