/*

   FUNCTION:  read_ref

      This function reads the velocity of the ship relative to the
      reference layer, as calculated and written to an ascii file
      by the "navigation" option in ADCPSECT.C

   RETURNS:  0 if successful
             1 on EOF or failure to scan a full line

   USED BY:  REFABS, get_ref()

   UPDATES:

   Fri  12-02-1988  from REFABSBT.C:
                    Changed read_ref to ignore lines with
                    BADFLOAT for u-component.

*/

#include <stdio.h>         /* FILE, EOF */
#ifndef dbext_included
#include "dbext.h"         /* ADJ_BADFLOAT */
#endif
#ifndef cal_included
#include "cal.h"           /* VELOCITY_TYPE */
#endif

#if PROTOTYPE_ALLOWED
int read_ref(FILE *fp_ref, VELOCITY_TYPE *ref)
#else
int read_ref(fp_ref, ref)
FILE *fp_ref;
VELOCITY_TYPE *ref;
#endif
{
   char buf[80];

   do
   {
      if ( getline_nc(fp_ref, buf, 80) == EOF ) return 1;
      if ( 3 != sscanf(buf, " %lf %lf %lf", &(ref->t), &(ref->u), &(ref->v)) )
         return 1;
   } while (ref->u >= ADJ_BADFLOAT);
   return(0);
}

