#!/usr/bin/ksh
#
# call_aari_gmag_mirror.ksh - This script sets the arguments
# to the script which downloads AARI gmag data
#
#								June 8th 2012 lphilpott@igpp.ucla.edu
#
# NB: it is intended that this script be run on gaia2 as the log file formats differ between machines
# and aari_gmag_mirror.ksh relies on information within the log file.
#
## 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

#
## Loop through last 30 days
#
integer n=1
# But do not process data within the last 6 days
integer dday=-6

while ((n <= 4))
do
  ((dday = dday - 1))
  ((n = n + 1))

  thisDate=$(date +%F -d $dday'day')
  year=$(echo $thisDate | awk -F- '{print $1}')
  month=$(echo $thisDate | awk -F- '{print $2}')
  day=$(echo $thisDate | awk -F- '{print $3}')

  aari_gmag_mirror.ksh $year $month $day

done 

## Clean up
#
	exit 0