#!/bin/bash

# Usage: download yy ddd stations.txt [hourly]
#
# RINEX files are stored in the current directory!

yy=$1
ddd=$2
stations=$3
hourly=$4

for station in `cat $stations`
do

if [ "$hourly" = hourly ]
then

for hour in `cat hours.txt`
do

hourn=`echo $hour | cut -c1-2`
hourl=`echo $hour | cut -c3-3`

file="ftp://cddis.gsfc.nasa.gov/gps/data/hourly/20$yy/$ddd/$hourn/$station"$ddd"$hourl."$yy"d.Z"

echo $file

ncftpget $file

done

else

file="ftp://cddis.gsfc.nasa.gov/gps/data/daily/20$yy/$ddd/"$yy"d/$station"$ddd"0."$yy"d.Z"

echo $file

ncftpget $file

fi

done


