#!/bin/csh -f

foreach FILE (*.DAT)

   set DATA     = $FILE:r
   echo "Now working on: "$DATA
   set OUT      = $DATA
   set LABEL    = $DATA.LBL
   set NEWLBL   = $DATA.lbl
   set START    = `grep START_TIME $LABEL | sed s/1978/1992/g`
   set STOP     = `grep STOP_TIME $LABEL | sed s/1978/1992/g`
   set REC      = `grep FILE_RECORDS $LABEL`

   set F        = $START[3]
   set L        = $STOP[3]
   set R        = $REC[3]

   cp /pds/archive1/VOLUME/PV10_0003/DATA/IONUNCERT.DES $DATA.DES
   cp /pds/archive1/VOLUME/PV10_0003/DATA/DATA.ABS $DATA.ABS
   cp /pds/archive1/VOLUME/PV10_0003/DATA/DATA.HED $DATA.HED

   cat /pds/archive1/VOLUME/PV10_0003/DATA/IONUNCERT_LABEL.LBL | sed s/_rec/$R/g | sed s/_start/$F/g | sed s/_stop/$L/g | sed s/_file/$DATA/g > $NEWLBL
   /bin/mv $NEWLBL $LABEL

   mp bp=/pds/archive1/VOLUME/PV10_0003/DATA/ion_uncert.bp INF=$DATA OUT=$OUT
   /bin/rm *DES *HED *ABS $FILE *FMT INF*
   unix2dos $DATA.TAB

end

exit (0)

