function write_hirlam(hirdat,dirnow,start_date,ext)

sx = size(hirdat);
notims = sx(1);
nmax   = sx(2);
mmax   = sx(3);

filout = strcat(dirnow,'\hirlam_',start_date,'.',ext);
fid    = fopen (filout,'w');

x1 = -12.;
y1 =  48.;
dx = 1/8 ;
dy = 1/12;

for itim = 1: notims;
   if (itim == 1);
      if (ext == 'amp');
         fprintf(fid,'%s\n',['/*y               100000.000']);
      end;
      fprintf(fid,'%s\n',['ncols                ' num2str(mmax)]);

      fprintf(fid,'%s\n',['nrows                ' num2str(nmax)]);
      fprintf(fid,'%s\n',['xllcentre            ' num2str(x1)]);
      fprintf(fid,'%s\n',['yllcentre            ' num2str(y1)]);
      fprintf(fid,'%s\n',['cellsize             ' num2str(dx) '   ' num2str(dy)]);
      fprintf(fid,'%s\n','NODATA_value           -999.000');
   end;

   timnow = (itim -1)*3;

   fprintf(fid,'%s\n',['/* TIME (HRS)       ' num2str(timnow,'%10.1f')]);
   for n = nmax:-1:1;
      fprintf(fid,[repmat('%8.3f   ',1,mmax) '\n'],hirdat(itim,n,:));
   end;
end;
fclose (fid);
