#!/usr/bin/ksh
#
# gbo_uc_rmd_mirror_batch.ksh - Calls the main mirror script
# for GBO mag data collected at UCalgary
#
#
# Creation Date:
#
#               22 April 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

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

	if (( $ilastMonth <= 0 ))
  then
    lastMonth=12
    lastYear=$(( $thisYear - 1 ))
  else
    lastYear=$thisYear
    lastMonth=$(echo $ilastMonth | awk '{printf("%02d",$1)}')
	fi

  thisYearMonth=${thisYear}_${thisMonth}
  lastYearMonth=${lastYear}_${lastMonth}

  year=2011
  month=11
  gbo_uc_rmd_mirror.ksh $year $month
  month=12
  gbo_uc_rmd_mirror.ksh $year $month
  year=2012

#	for yearMonth in $thisYearMonth $lastYearMonth
	for month in 01 02 03 04 05 06 07
	do
		year=$(echo $yearMonth | awk -F_ '{print $1}')
		month=$(echo $yearMonth | awk -F_ '{print $2}')
		gbo_uc_rmd_mirror.ksh $year $month
	done		

#
## Cleanup
#
  exit 0