function isNew = isNewEph(fid);
%---------------------------------------------------------
% check if ephemeris data is new
% Ju-Yong Do,  Jan 20, 2009
%---------------------------------------------------------
% input  : NSTB file indicator
% output : indicator whether new or not
%=========================================================
%=========================================================
persistent ephLog   %record of lastest ephmeris data 

%read header
fseek(fid, 8, 'cof'); %skip rxID, gpswk, rxID, tow
eph.prn     = fread(fid, 1, 'uint8',6);         %prn number
eph.iodc    = fread(fid, 1, 'uint16');          %issue of data, clock
fseek(fid, -17, 'cof'); %rewind to eph.tow

%search for previous eph for this prn
numLog = size(ephLog,2);
for i=1:numLog
    if eph.prn == ephLog(i).prn,         
        if eph.iodc == ephLog(i).iodc, 
            isNew = 0;  %same as previous eph
        else
            ephLog(i).iodc = eph.iodc;
            isNew = 1;  %different from previous eph          
        end
        return;
    end
end        

%create an entry if not exist
ephLog(numLog+1).prn   = eph.prn;
ephLog(numLog+1).iodc  = eph.iodc;
isNew = 1;

return
%=========================================================
%=========================================================