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

## Process sites
#
	for line in $(cat ${CONFIGDIR}/ucla_rmd_site_list.txt)
	do
		site_fullname=$(echo $line | awk -F_ '{print $1}')
		site_abbr=$(echo $line | awk -F_ '{print $2}')
		find ${UCLA_MIRROR_HOME}/${site_fullname}/ -name \*RMD -exec /bin/basename {} \; | awk -F_ '{print "20" substr($1,5,6)}' | sort >> /tmp/gmag_raw_epo_${site_abbr}.txt
		previous=NaN
		for line in $(cat /tmp/gmag_raw_epo_${site_abbr}.txt)
		do
			if [[ $line != $previous ]]
			then
				echo $line >> ${LOCAL}/gmag_raw_epo_${site_abbr}.txt
				previous=${line}
			fi
		done
		rm -f /tmp/gmag_raw_epo_${site_abbr}.txt
		mv -f ${LOCAL}/gmag_raw_epo_${site_abbr}.txt ${FILELISTS}/gmag_raw_epo_${site_abbr}.txt
	done

#
## Cleanup
#
	exit 0
