#! /bin/csh -f
# $Id: petscarch,v 1.9 1997/09/16 16:09:17 balay Exp $ 

#
#   petscarch - Returns the machine's PETSc environmental variable, PETSC_ARCH.
#
#   You can place the command
#       "setenv PETSC_ARCH `$PETSC_DIR/bin/petscarch`"
#   in a .cshrc file if using the csh or tcsh shell.  Thus, if you have several 
#   machines of different types that share the same filesystem, then when 
#   you log into any of them, the PETSC_ARCH will always be set correctly.
# 
if (-e /bin/uname) then
    set LARCH = `/bin/uname -s`
    if ("$LARCH" == "AIX") then
        set LARCH = "rs6000"
    else if ("$LARCH" == "HP-UX") then
	set LARCH = "hpux"
    else if ("$LARCH" == "Linux") then
	set LARCH = "linux"
    else if ("$LARCH" == "FreeBSD") then
	set LARCH = "freebsd"    
    else if ("$LARCH" != "IRIX" && "$LARCH" != "IRIX64") then 
        set LARCH = `/bin/uname -m`
    endif
else  if (-e /usr/bin/uname) then
    set LARCH = `/usr/bin/uname`
    if ("$LARCH" == "FreeBSD") then
      set LARCH = "freebsd"
    else
      echo "Unable to determine architecture"
      set LARCH = "unknown"
    endif
else
    echo "Unable to determine architecture"
    set LARCH = "unknown"
endif

set SunOSTest = `expr "$LARCH" : "\(....\)"`
if ("$SunOSTest" == "sun4") then
  set LARCH = sun4
  set Version = `/bin/uname -r`
  set MajorVersion = `expr "$Version" : "\(.\)"`
  if ("$MajorVersion" ==  5) then
    set LARCH = "solaris"
  endif
else if ("$LARCH" == "iris4d" || $LARCH == "IRIX") then
  set LARCH = "IRIX"
  set Version = `/bin/uname -r`
  set MajorVersion = `expr "$Version" : "\(.\)"`
  if ("$MajorVersion" ==  5) then
    set LARCH = "IRIX5"
  endif
else if ("$LARCH" == "AIX") then
   set LARCH = "rs6000"
else if ("$LARCH" == "RIOS") then
   set LARCH = "rs6000"
else if ("$LARCH" == "Linux" ) then 
  set LARCH = "linux"
else if ("$LARCH" == "CRAY Y-MP" ) then 
  set LARCH = "t3d"
else if ("$LARCH" == "CRAY T3E" ) then
  set LARCH = "t3e"
endif
#
echo $LARCH
exit 0
