#!/bin/ksh # Get the NCEP RSST ancillary data file closest to a MODIS granule date and time # Check number of arguments if [ $# != 3 ]; then echo "Usage: get_rsst dir date time" echo " dir is the directory containing the NCEP RSST files" echo " date is the date (yyyyddd)" echo " time is the time (hhmm)" exit 1 fi # Get arguments dir=$1 date=$2 time=$3 # Find the closest date within a 28 day window for delta in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do list="- +" for sign in $list; do # Compute the Gregorian date (yyyymmdd) of the closest NCEP RSST file modis_date=`dateplus -J $date` rsst_date=`dateplus $sign$delta $modis_date` # Find the NCEP RSST file rsst_name="oisst."$rsst_date rsst_file=`find $dir -size +583263c -name $rsst_name` # Check for success if [[ $rsst_file != "" ]]; then echo $rsst_file exit 0 fi done done # If we get here, no matching NCEP ice file was found exit 1