function runpro(cast);
% runpro(cast); Ledwell; 9/9/05
% processes a profile to update the matrices in cesp.mat, and
% plots the GC standard curve on the screen.
% Calls profiles.m to do the actual calculations.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% finds standard numbers for cast number 'cast' from:
%	 c:\ledwell\anal\Std_nums.txt
% reads in blank area and error from:
%	 c:\ledwell\anal\blank.txt
%
% runs 'profiles' for the given tow
% adds cast number, tow number, column integral to
%   existing matrix: c:\ledwell\anal\col_int.mat
% adds C,E,to exising data matrices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% standards:

load std_nums.txt
ik = find(~isnan(std_nums(cast,2:16)));
k = std_nums(cast,ik+1);

[z,C,E,A,h]=profiles(cast,k);

%% loads existing col_int matrix and includes the current
%% cast#,tow#, and column integral

% load col_int.mat

% a = isnan(col_int(cast,:));
% if a(1) == 0 | a(2) == 0 | a(3) == 0
%    disp('Data for this cast has already been saved to col_int.mat');
%   disp(['   Previous values: ' num2str(col_int(cast,1)) ' ' num2str(col_int(cast,2)) ' ' num2str(col_int(cast,3))]);
%    disp(['   Current values:  ' num2str(cast,2) ' ' num2str(sta,2) ' ' num2str(int)]);
%   yorn = input('Overwrite the old data? (y or n) ','s');
%   if yorn == 'y'
%      col_int(cast,1) = cast;
%      col_int(cast,2) = sta;
%      col_int(cast,3) = int;
%      save col_int col_int
%      yorn2 = input('Overwrite C,E,S,P,sigma,theta matrices also? (y or n) ','s');
%   end
% else
   % col_int(cast,1) = cast;
   % col_int(cast,2) = sta;
   % col_int(cast,3) = int;
   % save col_int col_int
   % yorn2 = 'y';
% end

% if yorn2 == 'y' 
  load cez.mat			% load file containing current matrices of
				% C,E,z
j=1:length(C);
  Cmat(j,cast) = C;
  Emat(j,cast) = E;
  zmat(j,cast) = z;
  Amat(j,cast) = A;
  hmat(j,cast) = h;

  save cez Cmat Emat zmat Amat hmat
  % end
  
 figure(3)
 i=find(~isnan(C));
 plot(C(i),z(i),'o',C(i),z(i),'--')
 xerrbar(C,z,E)
 axis([0 100 -60 60])
 ylabel('z  (m)')
 xlabel('C  (fM)')
 
 text(50,50,['Tow ',int2str(cast)])
 
 
  
