#!/usr/bin/ksh
#
# call_gima_netcdf2all.ksh - Check for GIMA_NC2ALL files and
# and if found, run gima_netcdf2all.ksh to process netCDFs to
# CDF and other formats.
#
# 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

  testlogfile=/home/thmsoc/astraea2_test/gimatestlog
#
## Process GIMA_NC2ALL files
#
	#for file in $(ls -1 $GMAGMIRROR/GIMA_NC2ALL*)
	echo "TESTING"  >> $testlogfile
        for file in $(ls -1 /disks/themisdata/workdir/gmag_mirror/GIMA_NC2ALL*)
        do
		for line in $(cat $file)
		do 
			year=$(echo $line |awk -F_ '{print $1}')
			doy=$(echo $line |awk -F_ '{print $2}')
			site=$(echo $line |awk -F_ '{print $3}')
			gima_netcdf2all_test.ksh $year $doy $site
		done
	#	rm -f $file
	done

#
## Cleanup
#
	exit 0
