#!/bin/csh

if ($#argv != 1) then
     echo "Usage: $0 dir1"
     echo "creates pysyn_cdbs directories for files to be"
     echo "delivered to SSB for ETC testing."
endif

# Base directory to and from
setenv dir1 /grp/hst/cdbs/deliveries/etc/$1
setenv dircdbs /grp/hst/cdbs/

#Save command line in argument dir1
#set dir1 = $1

echo $dir1
echo $dircdbs

if (! -d $dir1) then
    mkdir $dir1
    cd $dir1
    mkdir comp calobs calspec extinction grid mtab etc
    cd comp
    mkdir acs cos stis wfc3 nicmos nonhst ota
    cd ../etc
    mkdir background source
else
     echo " $dir1 directory already exist. Do you want to still copy"
     echo " the files there? (y/n)"
     set ans1 = $<
     if ($ans1 == "y") then
          echo "I can do that."
     else 
          echo " "
          echo "Ok bye!"
          exit 1
     endif
endif

# All the directories
echo "copying all the CDBS Tree to $dir1"
/bin/cp -Rf $dircdbs/grid/* $dir1/grid/.
/bin/cp -Rf $dircdbs/calspec/* $dir1/calspec/.
/bin/cp -Rf $dircdbs/calobs/* $dir1/calobs/.
/bin/cp -Rf $dircdbs/extinction/* $dir1/extinction/.
/bin/cp -Rf $dircdbs/etc/background/* $dir1/etc/background/.
/bin/cp -Rf $dircdbs/etc/source/* $dir1/etc/source/.

echo "provide with the MJD for the new mjd.dat file "
set mjd_val = $<
echo "You have selected  mjd_val"
if ($mjd_val == "") then
  echo "no tmc file give, leaving the file ipysyn_lookup.dat as is"
#cp $dircdbs/etc/mjd.dat  $dir1/etc/.

echo "provide with the name of the new TMC file "
set tmc_file = $<
if ($tmc_file == "") then
  echo "no tmc file give, leaving the file ipysyn_lookup.dat as is"
#else
#  switch ($argv[1])
#    case [yY][eE][sS]:
#      echo "argv[1] is 'yes'"
#      breaksw
#    case [nN][oO]:
#      echo "argv[1] is 'no'"
#      breaksw
#    default:
#      echo "invalid arg: must be yes or no"
#      breaksw
#  endsw
endif
#cp $dircdbs/etc/pysyn_lookup.dat $dir1/etc/.

