#!/bin/csh 
# copy the raw .000 ladcp data into cruise/data/ladcp/raw/
# then make links to those files using the filename format expected by IX processing

cd /local/users/pstar/cruise/data/ladcp/rawdata

rsync -av /mnt/data/jcr/current/ladcp/* . 

#make links for IX
foreach i (`ls JR18002_*.000`)
   set num = `awk -v nm="$i" 'BEGIN {print substr(nm,index(nm,".000")-3,3)}'`
   set linkfile = ${num}DL000.000
   if(! -e ../ix/raw/$num) then
      echo Making directory $num for raw file $i
      mkdir -p ../ix/raw/$num
   endif
   cd ../ix/raw/$num
   if (! -e $linkfile) then
      echo Making link $linkfile for raw file $i
      ln -s ../../../rawdata/$i $linkfile
   endif
   cd ../../../rawdata
end

cd ../..