pro get_pnt, tim_in, pdata, offset=offset
;
;+
;NAME:
;	get_pnt
;PURPOSE:
;	Given a set of input times, return the single PNT data record
;	closest to that time.
;CALLING SEQUENCE:
;	get_pnt, index, pdata
;	get_pnt, index, pdata, offset=offset
;INPUT:
;	tim_in	- The input time(s) in any of the 3 standard formats
;OUTPUT:
;	pdata	- The PNT data structure
;OPTIONAL KEYWORD OUTPUT:
;	offset	- The number of seconds that the matching PNT data is off
;		  from the input time(s)
;HISTORY:
;	Written 10-Jun-92 by M.Morrison
;	19-Apr-93 (MDM) - Fixed problem which occurs because the PNT orbit
;			  pointer time is for the first ADA data available,
;			  not the start time of the orbit (FID).
;-
last_fid = 'xxx'
tim = anytim2ints(tim_in)
n = n_elements(tim)
;
tim2orbit, tim, fid=fid, tim2fms=tim2fms
for i=0,n-1 do begin
    if (fid(i) ne last_fid) then begin		;only read PNT file if new orbit
	;;rd_pnt, tim(i), tim(i), pdata0
	ss = where(fid eq fid(i), count)
	rd_pnt, tim(i), tim(ss(count-1)), pdata0
	last_fid = fid(i)
    end
    if (i eq 0) then begin
	pdata = replicate(pdata0(0), n)
	offset = fltarr(n)
    end

    ii = tim2dset(pdata0, tim(i), delta=off0)		;find closest time within orbit of data
    pdata(i) = pdata0(ii)
    offset(i) = off0
end
;
end
