#!/bin/csh -f -x
#*************************************************************************
# Copyright (c) 2002 The University of Chicago, as Operator of Argonne
# National Laboratory.
# Copyright (c) 2002 The Regents of the University of California, as
# Operator of Los Alamos National Laboratory.
# This file is distributed subject to a Software License Agreement found
# in the file LICENSE that is included with this distribution. 
#*************************************************************************
if ${?EPICS_EXTENSIONS} == 0 then
set EPICS_EXTENSIONS = `/usr/local/epics/extensions`
endif
set PVT_LOC = $EPICS_EXTENSIONS/bin/$EPICS_HOST_ARCH

if ${?EPICS_EXTENSIONS_PVT} == 1 then 
        set PVT_LOC = $EPICS_EXTENSIONS_PVT/bin/$EPICS_HOST_ARCH
endif
setenv IDL_DEVICE X

# source /usr/local/rsi/idl_5.3/bin/idl_setup

setenv IDL_STARTUP $PVT_LOC/../../idllib/viewer_startup.pro
#
# set default IDL_USERDIR
#

set dir=`pwd`
echo "PWD" $dir
if (-w $dir)  == 1  then 
	set IDL_USERDIR=$dir
	setenv IDL_USERDIR $IDL_USERDIR
	echo IDL_USERDIR $IDL_USERDIR
	exit
endif

if ${?IDL_USERDIR} == 0 then
		set IDL_USERDIR=$HOME/idl
		if -e $IDL_USERDIR then
		        if (-d $IDL_USERDIR )== 0 then
		        set IDL_USERDIR=$HOME
		        endif
		else
		        mkdir ${IDL_USERDIR}
		endif

endif

setenv IDL_USERDIR $IDL_USERDIR
echo IDL_USERDIR $IDL_USERDIR
cd $IDL_USERDIR
