#!/bin/ksh # Get the NCEP ice ancillary data file closest to a MODIS granule date and time # Check number of arguments if [ $# != 3 ]; then echo "Usage: get_icec dir date time" echo " dir is the directory containing the NCEP ice 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 ice file modis_date=`dateplus -J $date` ice_date=`dateplus $sign$delta $modis_date | cut -c3-8` # Find the NCEP ice file ice_name="eng."$ice_date ice_file=`find $dir -size +226000c -name $ice_name` # Check for success if [[ $ice_file != "" ]]; then echo $ice_file exit 0 fi done done # If we get here, no matching NCEP ice file was found exit 1