#!/usr/bin/ksh
#
# gbo_ualaska_mirror_batch.ksh - Calls the main mirror script
# for ground mag data collected the GIMA Network
#
#
# Creation Date:
#
#               1 May 2008 TimQuinn
#

#
## Set the 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/gaia2_test/soc_it_to_me.config

#
## Determine dates to check
#
  thisYear=$(date -u '+%Y')
	thisMonth=$(date -u '+%m')
	integer ithisMonth=$thisMonth
	integer ilastMonth=$(( ithisMonth - 1 ))

	if (( $ilastMonth <= 0 ))
  then
    lastYear=$(( $thisYear - 1 ))
		while read line
		do
			site=$(echo $line |awk -F_ '{print $2}')
			/home/thmsoc/gaia2_test/gbo_ualaska_mirror_gaia.ksh $site $thisYear
			/home/thmsoc/gaia2_test/gbo_ualaska_mirror_gaia.ksh $site $lastYear
		done < ${CONFIGDIR}/gima_network.txt
  else
		while read line
		do
			site=$(echo $line |awk -F_ '{print $2}')
			/home/thmsoc/gaia2_test/gbo_ualaska_mirror_gaia.ksh $site $thisYear
		done < ${CONFIGDIR}/gima_network.txt
	fi

#
## Cleanup
#
  exit 0

