% Traverses all of the CODAR files grouping the E/N components
% ex:

output_dir='/d20/www/mrs/newcodar/data/1999/August';


PRECISION=2; % Number of digits or precision in original data.
INDIV_F=strcat('%6.',num2str(PRECISION),'f');
FORMAT=[INDIV_F,'  ',INDIV_F,'  ','%11.5f','  ','%11.5f','  ','%6.1f','  ','%6.1f','  ','%10.4f','  ','%3d','  ','%3d','  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ',INDIV_F,'  ','%8.4f','\n'];

eval(fullfile('cd ',output_dir,';'));

[s,file_names]=unix(['ls *']);
% file_names=file_names(6:length(file_names)); % Only necessary in directory with
                                               % 1998 subdirectory
file_name_size = 26;
file_info=size(file_names)./(file_name_size+1);
num_of_files=file_info(1,2)

LON_ADJUST=-.0045;
LAT_ADJUST=.0053;

for i=1:num_of_files
  i
  filename_w_ext=file_names((i-1)*file_name_size+(i):i*file_name_size+(i-1));
  data=load(filename_w_ext);
  data(:,3)=data(:,3)+LON_ADJUST;
  data(:,4)=data(:,4)+LAT_ADJUST;
  eval(['fid=fopen(''',filename_w_ext,''', ''w'');']);
  fprintf(fid,FORMAT,data');
  fclose(fid);
  fclose('all');
  clear data;
end;








