function getp(blk, prf, max_nprfs, max_nbins, seq_flag, ref0, refn)
%
% Usage:  getp(blk,prf)
%         getp(blk,prf,max_nprfs)
%         getp(blk,prf,max_nprfs,max_nbins)
%         getp(blk,prf,max_nprfs,max_nbins, ref0, refn)
%
% A function that calls the external program 'getmat' to retrieve from a
% CODAS database the U, V, W, E, AMP, PGOOD, and TIME data
% for the "key" profile indicated by <blk> <prf> and adjacent profiles.
% These are stored in .MAT files.  If max_nprfs and max_nbins are not specified,
% default values setup in SETUP.M will be used.
global DBNAME INITed DEFAULT_NPRFS DEFAULT_NBINS DEFAULT_SEQ_FLAG
global REFLAYER_STARTBIN REFLAYER_ENDBIN
% 2000/11/23 PJ Added GETMAT
global GETMAT

%editglob

INITed = 0;
if (nargin < 2)
   error('Invalid number of arguments.');
end;

if (nargin == 2)
   max_nprfs = DEFAULT_NPRFS;
end;

if (nargin <= 3)
   max_nbins = DEFAULT_NBINS;
end;

if (nargin <= 4)
   seq_flag = DEFAULT_SEQ_FLAG;
end;

if (nargin <= 5)
   ref0 = REFLAYER_STARTBIN;
   refn = REFLAYER_ENDBIN;
end;

s = sprintf(' %3.0f %3.0f %3.0f', blk, prf, max_nprfs);
t = sprintf(' %3.0f %3.0f', max_nbins, seq_flag);
u = sprintf(' %3.0f %3.0f', ref0, refn);

% 2000/11/23 PJ Added for GETMAT
if exist('GETMAT', 'var') & length(GETMAT),
  cmd_str = GETMAT;
else
  cmd_str = 'getmat';
end
cmd_str = [ cmd_str ' ' DBNAME s t u];
%%eval(['!getmat ' DBNAME s t u]);
%%cmd_str = ['getmat ' DBNAME s t u];   2000/11/23 PJ Removed
disp(cmd_str)
[status, output] = dos(cmd_str);
disp(output);
xx = findstr(output, 'Starting getmat ...');
if isempty(xx),
   disp('Either the operating system could not find the "getmat" command,')
   disp('or you are running an older version of it')
end



