function fid2mo, fid
;+
;   Name: fid2mo
;
;   Purpose: return mo number for input fid
;
;   Calling Sequence:
;      mos=fid2mo(fid)
;
;   Calling Example:
;      mos=fid2mo('920932.1234')
;
;   Input Parameters:
;      fid - string of form YYMMDD.HHMM
;
;   History:
;       4-oct-94 (SLF) from week2mo
;       5-oct-94 (SLF) allow file names as well as fids - allow arrays
;       2-Dec-94 (SLF) zero pad output to 4 places
;-
common fid2mo_blk, modat, startfid, stopfid

if not data_chk(fid,/string) then begin
   message,/info,'Need FID in form: YYMMDD.HHMM
   return,''
endif

fids=fid						; dont clobber input
molist=strarr(n_elements(fids))

filess=where(strlen(fids) eq 14,fcnt)
if fcnt gt 0 then fids(filess) = strmid(fids(filess),3,11)

if n_elements(modat) eq 0 then begin		; not very dynamic so only
   modat=rd_modb()		  	        ; read mo dbase first time
   startfid=string(modat.st$first_fid)
   stopfid =string(modat.st$last_fid)
endif

for i=0,n_elements(molist)-1 do begin
   ss=where((fids(i) ge startfid) and (fids(i) le stopfid),mocount) 
   if mocount gt 0 then begin
      modisk=strtrim(modat(ss).mo_disk,2)            
      moside=string(reform([modat(ss).st$side],1,mocount))
      molist(i)=strtrim(modisk + moside,2)
   endif else begin
      message,/info,"No MOs for fid: " + fids(i)
      molist(i)=''
   endelse
endfor

; zero pad to 4 places
pads=['00','0','']
lengths=strlen(molist)-2
valid=where(molist ne '',vcnt)
if vcnt gt 0 then molist(valid)=pads(lengths(valid)) + molist(valid)

if n_elements(molist) eq 1 then molist=molist(0)	; scaler in? scaler out



return,molist
end
