#                              sassetup
# SANS setup file at ILL for SGI-IRIX, Linux, Macintosh OS-X
# invoked as % source /home/cs/sans/sassetup
#
# this version April 2012 (R. Ghosh  reghosh @ gmail.com)
# 
# requires modifications to /etc/cshrc reflect location of host
# instrument specific parts are placed in
# .login for standard users, or 
# e.g. /home/vis/d22/.login.group for visitor_d22 zones etc.
# (this is invoked by getname procedure in F. Pinet's login routine)
# 
# started 29-Oct-1995  R.E. Ghosh
#------------------------------------------
#                          /etc/cshrc
# 1. /etc/cshrc could define SAS_ROOT  (the present directory)
# 2. /etc/cshrc should define SAS_DEF_PRINTER a local printer (host dependent)
# =======================================================================
#		.login  or .login.group e.g. for D11
# setenv SAS_INSTRUMENT d11
# setenv SAS_DATA_PATH /usr/illdata/data/d11
# source $SAS_ROOT/sassetup
#--------------------------------------------------
# The .login files in /home/group/xxxx set an absolute path, requiring
# the re-invocation of /etc/cshrc
#========================================================================
#               Mounted filesystems
# This setup file assumes that the SAS program root directory SAS_ROOT
# has been mounted (SAS_ROOT ==> /home/cs/sans) and that, for Linux, the
# filesystem /usr/public/  has been mounted too. 
# The standard mountpoint  for data is /usr/illdata
# these are set in standard automount maps.
# manually:
# mount serhom:/home/cs /home/cs
# mount serdon:/illdata /usr/illdata
# for linux
# mount serhom:/usr/idefix/public/linux /usr/public
#                        expectk
# This is the primary gui and is system dependent and may not
# be moved from its place of installation - only linked.
# For SGI it was installed in SAS_ROOT
# For OSX it was installed in /sw  (copy in $SASROOT/Osx/expect5.39.zip)
# For Linux it was installed in /usr/public/bin/expectk
# in each case the expectk in the $SAS_ROOT/system/expectk is linked
# to the appropriate expectk 
#
# wish is installed as standard on most systems and replaces the above expectk 
#
#========================================================================
# This present file contains environment variables primarily, rather than
# executables which are all in SAS_DIR
#
#          February 2007 REG/RPM
# EDITING  please note that the "alias" command REQUIRES all to be on one line
#          some editors will break these long lines inserting an unacceptable \
# ZCAT     a local copy (in SAS_DIR) of zcat is used.  On SGI this is a copy
#          of /usr/sbin/gzcat, Linux, OSX it is the gnu zcat (/usr/bin/zcat)
#          this will uncompress files written by compress or gzip
#
echo
echo "in ~sans/sassetup"
stty intr ^C
if ( $?NEW_SAS_SETUP == 0 ) then
# remaining steps 1,2,3,4,5 will be skipped
  setenv SAS_ROOT /home/cs/sans
  setenv SAS_EXTRA_G g2x
  setenv SAS_DECOMPRESS zcat
  echo "SAS_ROOT is " $SAS_ROOT
  echo "check OSNAME..."
  set OSNAME=`/bin/uname -s`
  echo "OSNAME is " $OSNAME
  switch ($OSNAME)
# case 'IRIX*' :
  case 'IRIX' :
    setenv SAS_DIR $SAS_ROOT
    setenv COMPILER_DEFAULTS_PATH /home/cs/sans
    alias help "$SAS_ROOT/help"
    alias oldsetup "setenv NEW_SAS_SETUP undefined;source /home/cs/sans/sassetup-1"
    echo " "
    echo  "For previous setup give command   oldsetup"
    echo  "For previous program version use==>  program-1"
  breaksw
  case 'Linux' :
    setenv SAS_DIR $SAS_ROOT/Linux12
    alias help "/usr/bin/firefox http://www.ill.eu/instruments-support/computing-for-science/cs-software/all-software/sans/"
echo " "
echo " "
echo " A program distribution may be found at ftp://ftp.ill.fr/pub/cs/sans"
echo " "
echo " "

  breaksw
  case 'Darwin' :
    setenv SAS_DIR $SAS_ROOT/Osx12
    alias help "/Applications/Safari.app/Contents/MacOS/Safari http://www.ill.eu/instruments-support/computing-for-science/cs-software/all-software/sans/"
setenv DYLD_LIBRARY_PATH $SAS_DIR
setenv SAS_DECOMPRESS "gunzip -c "
echo " "
echo " "
echo " A program distribution may be found at ftp://ftp.ill.fr/pub/cs/sans"
echo " "
echo" "
echo "running programs on OSX assumes that the /home/cs/sans directory"
echo "is available - if not then download the distribution to your machine"
  breaksw
  endsw
  setenv MY_INST NONE
  switch ($USER)
  case 'd11'
    setenv MY_INST d11
  breaksw
  case 'd16'
    setenv MY_INST d16
  breaksw
  case 'd22'
    setenv MY_INST d22
  breaksw
  case 'd33'
    setenv MY_INST d33
  breaksw
  endsw
# note if the DATA_PATH is predefined this is used (e.g. at instrument)
  if ($MY_INST !~ "NONE") then
    if($?SAS_INSTRUMENT == 0) then
      setenv SAS_INSTRUMENT $MY_INST
    endif
    if ($?SAS_DATA_PATH == 0) then
      setenv SAS_DATA_PATH "/usr/illdata/data/"$MY_INST"/"
    endif
  else
    setenv SAS_INSTRUMENT $MY_INST
    setenv SAS_DATA_PATH $MY_INST
  endif
# to get non-US date formats on some systems
  unsetenv LANG
#echo "#1"
  if (! $?SAS_DEF_PRINTER ) then
    setenv SAS_DEF_PRINTER lp
    echo "Not standard SAS_DEF_PRINTER"
  endif
  if (! $?SAS_DEF_PLOTTER ) then
    setenv SAS_DEF_PLOTTER lp
    echo "Not standard SAS_DEF_PLOTTER"
  endif
#echo "#1b"
  echo $SAS_DIR" is being added to path"
  set path = ( . $SAS_DIR $SAS_ROOT $path )
  rehash
#echo "#2"
  setenv SAS_CHECK limited
# places executables in current path
  setenv ILLUSER_DIR "$SAS_ROOT/"
# for graphics:
  setenv PGPLOT_XW_WIDTH 0.45
  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
# for mosaic 2.75
  setenv http_proxy "http://proxy.ill.fr:8888/"
  setenv ftp_proxy "http://proxy.ill.fr:8888/"
  setenv gopher_proxy "http://proxy.ill.fr:8888/"
  setenv WWW_HOME "http://www.ill.fr/"
#echo "#3"
#
  alias newest "more $SAS_ROOT/SANSLOG"
  alias xplots-1 "expectk $SAS_ROOT/xplots"
  alias xpolly-1 "expectk $SAS_ROOT/xpolly"
  alias xmill-1  "expectk $SAS_ROOT/xmill"
  alias xplots "wish $SAS_DIR/xplots.bat"
  alias xpolly "wish $SAS_DIR/xpolly.bat"
  alias xmill "wish $SAS_DIR/xmill.bat"
#  alias xmplot "wish $SAS_DIR/xmplot.bat"
  alias xreg  "wish $SAS_DIR/xreg.bat"
  
#
# Local printers are set up initially using a pseudo- pri command
# which is normally used for printing here. myprinter can be used to modify
# choice manually
#
# first check if enviroment variable DISPLAY is set, and if yes, run a 
# GUI version, else run a text version.
#echo "#4"
  if ($?DISPLAY ) then
        echo "setting up X environment"
	alias myprinter "$SAS_DIR/expectk $SAS_DIR/sasprinter.tk " 
	alias pri "$SAS_DIR/expectk $SAS_DIR/sasprinter.tk ; source $HOME/.login.sasprinter;unalias pri;alias pri $SAS_DIR/prip;$SAS_DIR/prip "
  else
# rather unlikely nowadays...
	alias myprinter "$SAS_DIR/sasprinter.tcl;source $HOME/.login.sasprinter" 
	alias pri "$SAS_DIR/sasprinter.tcl;source $HOME/.login.sasprinter ; unalias pri; alias pri $SAS_DIR/prip; $SAS_DIR/prip"
  endif
#echo "#5"
# Similarly plotters - typically colour printers printing direct to PostScript
# Local plotters are set up initially using a pseudo- plo command
# which is normally used for printing here. myplotter can be used to modify
# choice manually
  alias myplotter-1 "$SAS_DIR/expectk $SAS_DIR/sasplotter.tk ; source $HOME/.login.sasplotter" 
  alias myplotter "wish $SAS_DIR/sasplotter.tk ; source $HOME/.login.sasplotter" 
  alias plo-1 "$SAS_DIR/expectk $SAS_DIR/sasplotter.tk ; source $HOME/.login.sasplotter ;unalias plo-1; alias plo-1 $SAS_DIR/plop;$SAS_DIR/plop"
  alias plo "wish $SAS_DIR/sasplotter.tk ; source $HOME/.login.sasplotter ;unalias plo; alias plo $SAS_DIR/plop;$SAS_DIR/plop"
  alias xmplot-1 "$SAS_DIR/expectk $SAS_DIR/sasplotter.tk ; source $HOME/.login.sasplotter ; unalias xmplot-1; alias xmplot-1 $SAS_DIR/xmplott; $SAS_DIR/xmplott" 
  alias xmplot "wish $SAS_DIR/sasplotter.tk ; source $HOME/.login.sasplotter ; unalias xmplot; alias xmplot wish $SAS_DIR/xmplot.bat;wish $SAS_DIR/xmplot.bat" 
  setenv NEW_SAS_SETUP completed
  echo "SANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANS"
  echo "                       ILL - SANS"
  echo "Currently SAS_INSTRUMENT is set to $SAS_INSTRUMENT"
  echo "Current SAS_DATA_PATH is $SAS_DATA_PATH "
  echo "For help give the command help"
  echo "For information on recent changes give the command newest"
  echo " WWW information  "
  echo " www.ill.eu/sites/grasp/grasp_main.html"
  echo " www.ill.eu/computing-for-science/cs-software/all-software/sans"
  echo " "
  echo "For most recent Mac/Linux/PC-Windows programs (containing Prop updates)"
  echo " 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 " "
  echo "SANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANSANS"
else
  echo NEW_SAS_SETUP is $NEW_SAS_SETUP "(nothing has been done)"
endif
echo "end of ~sans/sassetup"
echo
