
Delivered-To: rgroman@globec.whoi.edu
Date: Mon, 14 Jun 1999 16:04:10 -0400
From: JGOFS Data System <jgofs@chips1.gso.uri.edu>

#!/bin/csh -f
#
# oi_sst.bisagni script
#
# Edited June 8, 1998.  Replace use of dsp2gif with d2g.  No changes
# in functionality, just a name change.  To version V1.01 rcg
# Created November 25, 1996 to handle optimally-interpolated images rcg
#  from modhtml3.bisagni
# Used with defexec method for serving satellite images.  Script
# generates the list of available satellite images, according to
# their dates (after preselecting by type based on passed parameter
# $1) and year ($2).  The user will see each line as a hypertext link.
# When clicked, the cgi that is called will convert the specified image
# to gif format and pass it to caller.
#

# Restrictions
#	Watch out for length of output string.  It cannot get much/any
#	bigger without truncation, unless routine (defgb variant) is
#	modified to handle it.

set version="#oi_sst.bisagni V1.01"
set image_type=$1
set year=$2
#	set image_type="oi"
#	set year="1993"

#					 echo " "
#					echo "image_type = $image_type"
#					 echo "year = $year"

echo "$version"
echo "	yrday0_utc"

set initpath="/c2/data2/bisagni/avhrr/jgofs_img1day"
if (! -e $initpath ) then
  echo " *Cannot continue with displaying oi images."
  echo "$initpath is not a directory or does not exist"
  exit
endif

cd $initpath
#					 echo "Change directory to: `pwd`"
# Check for directory validity
if (-d $year) then

set dirpath=$initpath/$year
#					echo "dirpath = $dirpath"

set count=`ls -1 ${dirpath}/*.IMG.Z*  |& fgrep -c "No match"` 
#						echo "count = $count"
if ($count == "0" ) then
	set files=`ls -1 ${dirpath}/*.IMG.Z`

	foreach file ($files)
#					echo "file = $file"
		set filetail=$file:t
#					echo "filetail = $filetail"
		set yrday=`echo $filetail | awk '{print substr($1,6,4)}' `
		set yrday1=`echo $yrday | awk '{print substr($1,1,3)}' `
		set yrday2=`echo $yrday | awk '{print substr($1,4,1)}' `
#					echo "yrday = $yrday"
#					echo "yrday1 = $yrday1"
#					echo "yrday2 = $yrday2"
		set yrday="${yrday1}.${yrday2}"
#					echo "new yrday = $yrday"
cat <<XSTUFF
"<a href="http://chips1.gso.uri.edu/jg/d2g?${file}">${yrday}</a>"
XSTUFF
          end
endif
#					echo "End of script"


