function [d, p, err, errmsg] = OsiSendProfileData(vardesc)
%
% OsiSendProfileData.m		Request profile data from OLGA Server 
%
% The calling syntax is:
%
%   [d, p, err] = OsiSendProfileData(vardesc);
%
% Input:
%   VARDESC: String identifying the variables to be reported from olga. 
%
% Outputs:
%   D - pipeline distance (at the current version the distance is equal to the 
%       accumulated pipeline section number).
%   P - profile data, one variable in each column.
%
% Copyright (c) 1998 by ABB Corporate Research.
% All Rights Reserved.
%
% $Revision: 1.0, 6/10-1998 by Kjetil Havre$ 


  if nargin ~= 1 
     errmsg = 'OsiSendProfileData usage: [err, errmsg] = OsiSendProfileData(vardesc)';
     disp(errmsg);
     err = -1;
     return
  end

  [err, msg, ibody, rbody, errmsg] = osmi(1, 'OLGA_SENDPR_NAMES', [], [], vardesc);

  p = []; d = [];

if err == 0
     nrm = max(ibody);
     nc  = size(ibody,1); 
     d = zeros(nrm,nc);
     p = zeros(nrm,nc);
     irbs = 1;
     for i = 1:nc 
        d(1:ibody(i),i) = (1:ibody(i))';
        p(1:ibody(i),i) = rbody(irbs:(irbs+ibody(i)-1));
        irbs = irbs+ibody(i);
     end
  end
  

































































































































