clear all;
disp('***************************************************************');

%disp('read_Eureka_2010_files.m');
%disp('read_Eureka_2009_files.m');
%disp('read_Eureka_2008_files.m');
%disp('read_Eureka_2007_files.m');
%
siter='eut';
yrr='10';
%yrr='09';
%yrr='08';
%yrr='07';
yrd=2000+str2num(yrr);
file_out = ['/data/lmatrosova/arctic/eureka/flux/towermet/20' yrr '/60min/' siter yrr '_60mn_NaN.txt']
file_out1 = ['/data/lmatrosova/arctic/eureka/flux/towermet/20' yrr '/60min/' siter yrr '_60mn.txt']
id_out = fopen(file_out,'a');
%
z=[]
for day = 1:365
%for day = 241:365
if day < 10
  dayr=['00' num2str(day)];
elseif day < 100
  dayr=['0' num2str(day)];
else
  dayr=num2str(day);
end
%
infil=['/data/lmatrosova/arctic/eureka/flux/towermet/20' yrr '/'  siter yrr dayr '_60mn.txt']
flist=fopen(infil,'r')
 if flist <= 0 ; % if the file does not  exist 
        y(1:24,1:42) = NaN ; y(:,1) = [yrd] ; y(:,2) = (0:23)/24 + day ;
 end  
 if flist >  0 ;   y = load([infil]); fclose(flist);  end  %if the file does not  exist
       z = vertcat(z,y);
end;
save(file_out,'z','-ascii','-tabs');
z(find(isnan(z)))=-9999.9;
save(file_out1,'z','-ascii','-tabs');
fclose('all')

