#!/usr/bin/ksh
#
# call_maccs_ascii2all.ksh - Check for MACCS files and
# and if found, run maccs_ascii2all.ksh to process ascii files to
# CDF and UCB formatted CDF and ascii files
#
# Creation Date:
#
#								April 2009 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 Greenland files
#
#for line in $(ls -1 $GMAGMIRROR/*.sec)
# temporarily modified to read files from production directory but not delete them
# after processing
for line in $(ls -1 /disks/themisdata/workdir/gmag_mirror/*.sec)
do
	filename=$(basename $line)
	fileSite=$(echo $filename |awk -F_ '{print substr($1,1,3)}')
	site=$(grep $fileSite ${CONFIGDIR}/maccs_site_list.txt | awk -F_ '{print $1}')
	year=$(echo $filename |awk -F_ '{print substr($1,4,4)}')
	mon=$(echo $filename |awk -F_ '{print substr($1,8,2)}')
	day=$(echo $filename |awk -F_ '{print substr($1,10,2)}')
	yyyymmdd=${year}${mon}${day}
	maccs_ascii2all_test.ksh $site $yyyymmdd
	#rm -f $line
done

exit 0
