#!/bin/sh
#
# drft06trr_dredgepage - make top DRFT06RR dredge web page (drft06rr_dredges.html)
#
# This script creates the drft06rr_dredges.html file which is the top level web
# page in the DRFT tree. It doesn't care if any of the files and
# images it links to are not there yet.
#
# Paul Wessel, 19-NOV-2001
H=drft06rr
#---------------------------
mkdir -p $H
cd $H
date=`date`
cat << EOF > drft06rr_dredges.html
Drift Expedition Leg 6: The Easter/Salas y Gomez/Nazca Survey Dredges
Drift Expedition Leg 6: The Easter/Salas y Gomez/Nazca Survey Dredges
This page provides one-step access to each dredge's individual web page, as well as to
the seamount the dredge is located on, and the box containing that
seamount. The individual dredge
pages are also accessible directly from the seamount page to which it belongs. Dredges that
potentially are suitable for dating are shown in red; other dredges are colored gold.

EOF
# Loop over all the dredges in such a way as to generate two columns. We thus
# need to find the length of the list, divide by two to get the offset to the
# second column, and keep track of where we are in the file:
grep -v '^#' ../drft06rr_dredges.lis > $$.lis
n=`cat $$.lis | wc -l`
off=`gmtmath -Q $n 2 DIV CEIL =`
row1=1
row2=`expr $off + 1`
i=1
while [ $i -le $n ]; do
echo "" >> drft06rr_dredges.html
line1=`sed -n ${row1}p $$.lis`
echo $line1 | awk '{printf "  | \n On seamount |  | In box: |  | \n", "'$H'", $1, $1, $1, "'$H'", $2, $2, $2, "'$H'", $3, $3, $3}' >> drft06rr_dredges.html
row1=`expr $row1 + 1`
i=`expr $i + 1`
if [ $row2 -le $n ]; then
line2=`sed -n ${row2}p $$.lis`
echo $line2 | awk '{printf "  | \n On seamount |  | In box: |  | \n", "'$H'", $1, $1, $1, "'$H'", $2, $2, $2, "'$H'", $3, $3, $3}' >> drft06rr_dredges.html
row2=`expr $row2 + 1`
i=`expr $i + 1`
else
echo " N/A | N/A | N/A | N/A | N/A | " >> drft06rr_dredges.html
fi
echo "
" >> drft06rr_dredges.html
done
echo "
" >> drft06rr_dredges.html
cat << EOF >> drft06rr_dredges.html

Return to Drift Expedition Leg 6 home page
drft06rr_dredgepage: Page last updated $date by $USER.
EOF
rm -f $$.lis
cd ..