#!/usr/bin/ksh
#
# call_make_stack.ksh - Check for stack files
# and if found, run make_mag_stack_plots.ksh 
# to create stack plots
#
# 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 stack files
#
	previous=NaN
	for fullpath in $(ls -1 ${WORKMAGSTACKS}/stack*)
	do
		datepart=$(echo $fullpath | awk -F/ '{print substr($6, 7, 8)}')
		if [[ $datepart != $previous ]]
		then
			date=$(cat $fullpath)
			make_mag_stack_plots_test.ksh $date
			previous=${datepart}
		fi
		rm -f $fullpath
	done
		
#
## Cleanup and exit
#
	exit 0
