#!/usr/bin/env bash
if (test -d /usr/local/globus-2.4); then
  export GLOBUS_LOCATION=/usr/local/globus-2.4
else if (test -d /net/optlinux/globus-2.4); then
  export GLOBUS_LOCATION=/net/optlinux/globus-2.4
fi
fi

if (test -n "$GLOBUS_LOCATION"); then
  . $GLOBUS_LOCATION/etc/globus-user-env.sh
  export MPI_HOME=${GLOBUS_LOCATION}/mpich-g2-1252
  if (test -d "$MPI_HOME"); then
    export PATH=${MPI_HOME}/bin:$PATH
    export CC=mpicc
    printf "\nGLOBUS ok      MPICHG2 ok\n\n"
  else	
    printf "\nGLOBUS ok      MPICHG2 ---- NOT THERE ------ \n\n"
  fi
  HOST=$(hostname)
  ARCH=$(uname -p 2>/dev/null) 
  MACH=$(uname -m)
  export HOSTA=`hostname -s`
  export HOSTB=`hostname -f`
  if (test "$HOSTA" == "$HOSTB"); then
     printf "\nENSEIRB config\n\n"
     export HOSTB="${HOSTA}.enseirb.fr"
  fi 
  export GLOBUS_HOSTNAME="${HOSTB}"
  export GLOBUS_TCP_PORT_RANGE=30000,40000
else
  echo "GLOBUS not installed properly"
fi

