#!/usr/bin/ksh
#
# call_candat_ascii2all.ksh - Check for CAN_ASCfiles files and
# and if found, run candat_ascii2all.ksh to process ascii files to
# CDF and UCB formatted ascii files
#
# Creation Date:
#
#								26 September 2006 TimQuinn
#
#	

## Set environment variables
#
  if [[ -z $THMSOC ]]
  then
    THMSOC=/disks/socware/thmsoc_dp_current
    export THMSOC
  fi
#	. $THMSOC/src/config/soc_it_to_me.config
. /home/thmsoc/astraea2_test/soc_it_to_me.config

## Process CAN_ASCfiles files
#
#for file in $(ls -1 $GMAGMIRROR/CAN_ASCfiles*)
# temporarily modified to read files from production version and not 
# delete them after processing
for file in $(ls -1 /disks/themisdata/workdir/gmag_mirror/CAN_ASCfiles*)
do
	for line in $(cat $file)
	do 
		filename=$(basename $line)
		year=$(echo $filename |awk '{print substr($1,1,4)}')
		month=$(echo $filename |awk '{print substr($1,5,2)}')
		day=$(echo $filename |awk '{print substr($1,7,2)}')
		input="${year}/${month}/${day}/${filename}"
		candat_ascii2all_test.ksh $input
	done
	#rm -f $file
done

exit 0
