function seismic_spectra_format_SHOM(spectrum,freq,dates,station,filename)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Input parameters:  à compléter
%  WARNING: only correct for regularly spaced frequencies
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid1=fopen(filename,'w');
%
% loop on time records
%
nt=length(dates);
Nfo=length(freq);
df=freq(2)-freq(1);
for irec=1:nt
%
% Output to file
%
%
% File header
%
   if irec == 1
      fprintf(fid1,' 1\n %4.f   1    1 \n',Nfo);
      fprintf(fid1,'   %10.8E   %10.8E   %10.8E   %10.8E   %10.8E \n',freq(1:Nfo)-df*0.5);       
      if mod(Nfo,5) ~= 0 
         fprintf(fid1,'\n');
      end
      fprintf(fid1,'   %10.8E   %10.8E   %10.8E   %10.8E   %10.8E \n',freq(1:Nfo)+df*0.5);       
      if mod(Nfo,5) == 0 
      else 
         fprintf(fid1,'\n');
      end
      fprintf(fid1,[station,'     \n']);
      fprintf(fid1,'Ef      \n');
   end 
%
% Write data for time record
%
   dates2=datevec(dates(irec));
   zone=0.0;
   A=[dates2(1),dates2(2),dates2(3),dates2(4),dates2(5),zone];
   fprintf(fid1,' %4.f %02.f %02.f   %02.f %02.f %03.1f    \n',transpose(A(1:6)));
   fprintf(fid1,'  %16.8E  %16.8E  %16.8E  %16.8E  %16.8E \n',spectrum(irec,1:Nfo));
   if mod(Nfo,5) ~= 0 
      fprintf(fid1,'\n');
   end
end
fclose(fid1);

