function MakeSpecList(inpdir,tstart,dt,runid,imodel,outdir,outfile,trefxbeach,morfac)

% MakeSpecList(inpdir,tstart,dt,runid,imodel,outdir,fout,trefxbeach,morfac)
%
% inpdir : flow-wave run directory with sp2 files (incl. last backslash)
% tstart : start time of flow model (e.g. datenum(2008,5,10))
% dt     : interval of wave computations (minutes)
% runid  : runid of wave simulation
% imodel : grid number
% outdir : XBeach run directory (incl. last backslash)
% outfile :  filename spectra list (e.g. speclist.txt)
% trefxbeach : reference time xbeach (e.g. datenum(2008,5,10))
% morfac : MORFAC

files=dir([inpdir runid 'n' num2str(imodel) 't*.sp2' ]);

nfiles=length(files);

if (nfiles >0);
   for i=1:nfiles
       k=str2double(files(i).name(7:9));
       t(i)=tstart+(k-1)*dt/1440;
   end

   t=t-trefxbeach;
   t0=find(t>=0);
   it0=t0(1);

   fid=fopen([outdir outfile],'wt');
   fprintf(fid,'%s\n','FILELIST');
   for i=it0:nfiles
       [succes] = copyfile ([inpdir files(i).name ],outdir);
       fprintf(fid,'%8.1f %8.1f %s\n',dt*60/morfac,1.0,files(i).name);
   end
   fclose(fid);
end;
