;+
;NAME:
;       go_arch_sum
;PURPOSE:
;       Grep through the control file archive to make summaries
;HISTORY:
;       Written 13-Mar-96 by M.Morrison
;	18-Mar-96 (MDM) - added /bin/csh to spawn command to let it work in sh
;V2.0	 5-Aug-96 (MDM) - Modified to make the output directory $MDI_CAL_INFO
;V2.1	21-Oct-97 (MDM) - Modified to run on diapason
;V2.2	 9-Nov-99 (RIB) - Removed trig_mirror command - to be run in separate
;                         cron job
;-
;
if (n_elements(date) eq 0) then date = ut_time()
indir = '/mdisw_cmd/archive'
if (get_host(/short) eq 'diapason') then indir = '/mdisw/archive'
outdir = '$MDI_CAL_INFO'
cd, indir
;
qredone = 0
;
top:
date = gt_day(date,/str)
tarr = anytim2ex(date)
fid = ex2fid(tarr)
outfil0 = concat_dir(indir, strmid(fid,0,4) + '.summary')
outfil1 = concat_dir(outdir, strmid(fid,0,4) + '.cfl_sum_cron')
outfil2 = concat_dir(outdir, strmid(fid,0,4) + '.cfl_sum_alph')
;
ssw_file_delete, outfil0
for i=0,3 do spawn, '/bin/csh -c "grep ^source ' + strmid(fid, 0, 4)+strtrim(i,2) + '* >> ' + outfil0 + '"'
;
mat = rd_tfile(outfil0,2)
fids = reform(strmid(mat(0,*), 0, 13))
files0 = str_replace(reform(mat(1,*)), '"', '')
break_file, files0, dsk_log, dir00, filenam, ext
;
tit = ['GO_ARCH_SUM   Ver 2.0  Program Run: ' + ut_time() + ' UT', ' ']
out = fids + '       ' + filenam + ext
;out = string(filenam+ext+'                                 ', format='(a30)') + fids
prstr, [tit, out], file=outfil1
prstr, [tit, out(sort(filenam+fids))], file=outfil2
;
;;spawn, 'rcp -p ' + outfil1 + ' diapason:/hosts/pore1/usr/local/etc/httpd/htdocs/MDI/ops/run_stuff
;;spawn, 'rcp -p ' + outfil2 + ' diapason:/hosts/pore1/usr/local/etc/httpd/htdocs/MDI/ops/run_stuff
;;spawn, '/mdisw/bin/trig_mirror ' + getenv('MDI_CAL_INFO')
;
end
