function s=average_icq5(fl1,fl2,flout)
s1=read_icq4_nomex(fl1);
s2=read_icq4_nomex(fl2);

s=s2;
f=fields(s1);
n=length(f);
for k=1:n
  k
  if ~ischar(eval(['s.',f{k}])) ,
    k
    str=['s.',f{k},'=(s1.',f{k},'+s2.',f{k},')/2;'];
    disp(str)
    eval(str);
  end
end

% set time by the second of the two averaged files
% should always put later timed file as second entry
% for this to be correct.

s.day = s2.day;
s.mon = s2.month;
s.year = s2.year;
s.curr_seconds = s2.curr_seconds;

write_icq4(flout,s)
