function [width,len,xfirst,yfirst,xstep,ystep]=read_header(filename)

%%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%Read Binary Grid file headers
%Header file should at least contain 
%WIDTH
%FILE_LENGTH
%X_FIRST
%Y_FIRST
%X_STEP 
%Y_STEP 
%Please refer to the format in the given example
%%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

fid_header=fopen(filename,'r');
header_src=textscan(fid_header,'%s%s');
fclose(fid_header);

for i=1:length(header_src{1})
    name=char(header_src{1}(i));
   if(strcmp(name,'WIDTH')==1)
       width=ceil(str2double(header_src{2}(i)));
       continue;
   end
   if(strcmp(name,'FILE_LENGTH')==1)
       len=ceil(str2double(header_src{2}(i)));
       continue;
   end
   if(strcmp(name,'X_FIRST')==1)
       xfirst=str2double(header_src{2}(i));
   end
   if(strcmp(name,'Y_FIRST')==1)
       yfirst=str2double(header_src{2}(i));
       continue;
   end
   if(strcmp(name,'X_STEP')==1)
       xstep=str2double(header_src{2}(i));
       continue;
   end
   if(strcmp(name,'Y_STEP')==1)
       ystep=str2double(header_src{2}(i));
       continue;
   end
end