#!/usr/bin/ksh

## 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/astraea2_test/soc_it_to_me.config
  #. ${THMSOC}/src/config/ground_mag.config
  . /home/thmsoc/astraea2_test/ground_mag_test.config

## Process sites
#
	for line in $(cat ${CONFIGDIR}/ualberta_ascii_site_list.txt)
	do
		ucsite=$(echo $line | awk -F_ '{print $1}')
		lcsite=$(echo $line | awk -F_ '{print $2}')
		find ${UALB_MIRROR_HOME} -name \*${ucsite}\*gz -exec /bin/basename {} \; | awk '{print substr($1,1,8)}' | sort >> /tmp/gmag_raw_alb_${lcsite}.txt
		previous=NaN
		for line in $(cat /tmp/gmag_raw_alb_${lcsite}.txt)
		do
			if [[ $line != $previous ]]
			then
				echo $line >> ${LOCAL}/gmag_raw_alb_${lcsite}.txt
				previous=${line}
			fi
		done
		rm -f /tmp/gmag_raw_alb_${lcsite}.txt
		mv -f ${LOCAL}/gmag_raw_alb_${lcsite}.txt ${FILELISTS}/gmag_raw_alb_${lcsite}.txt
	done

#
## Cleanup
#
	exit 0
