%
  function [ub,lb,u0,options] = initial_post(DATA);
%
% initialize problem parameters
%
% set bounds for the controls
%
  if isfield(DATA,'U_lower')
      tmp = DATA.U_lower;
  else
      tmp = -inf*ones(DATA.N_controls,1);
  end
  lb =  reshape([tmp(:)*ones(1,DATA.N_panels)],...
        1,DATA.N_controls*DATA.N_panels);
%
  if isfield(DATA,'U_upper')
      tmp = DATA.U_upper;
  else
      tmp = inf*ones(DATA.N_controls,1);
  end 
  ub =  reshape([tmp(:)*ones(1,DATA.N_panels)],...
        1,DATA.N_controls*DATA.N_panels); 
%
% initial estimates for controls
%
  if (isfield(DATA,'U_guess'))
    u0 =  reshape([DATA.U_guess(:)*ones(1,DATA.N_panels)],...
        1,DATA.N_controls*DATA.N_panels);
  else
    u0 = zeros(size(ub));
  end
%
  options = optimset('fmincon');
%
% Test to see if constraint types and their jacobian are included
  test_eq = ( (isfield(DATA,'Phi_eq') & isfield(DATA,'Phi_eqj') ) | ~isfield(DATA,'Phi_eq') );
  test_in = ( (isfield(DATA,'Phi_in') & isfield(DATA,'Phi_inj') ) | ~isfield(DATA,'Phi_in') );
% 
  if ( isfield(DATA,'Rhsj') & isfield(DATA,'Mayerj') & test_eq & test_in)
     options.GradObj    = 'on';
     options.GradConstr = 'on';
  else
     disp(['Not all Jacobians are available'])
  end
%
% Pass through any OPTIONS settings
%
 if isfield(DATA,'DerivativeCheck')
    options.DerivativeCheck = DATA.DerivativeCheck;
 end
%
 if isfield(DATA,'Diagnostics')
    options.Diagnostics = DATA.Diagnostics;
 end
%
 if isfield(DATA,'DiffMaxChange')
    options.DiffMaxChange = DATA.DiffMaxChange;
 end
%
 if isfield(DATA,'DiffMinChange')
    options.DiffMinChange = DATA.DiffMinChange;
 end
%
 if isfield(DATA,'Display')
    options.Display = DATA.Display;
 end
%
 if isfield(DATA,'LargeScale')
    options.LargeScale = DATA.LargeScale;
 end
%
 if isfield(DATA,'MaxFunEvals')
    options.MaxFunEvals = DATA.MaxFunEvals;
 end
%
 if isfield(DATA,'MaxIter')
    options.MaxIter = DATA.MaxIter;
 end
%
 if isfield(DATA,'MaxPCGIter')
    options.MaxPCGIter = DATA.MaxPCGIter;
 end
%
 if isfield(DATA,'TolCon')
    options.TolCon = DATA.TolCon;
 end
%
 if isfield(DATA,'TolFun')
    options.TolFun = DATA.TolFun;
 end
%
 if isfield(DATA,'TolPCG')
    options.TolPCG = DATA.TolPCG;
 end
%
 if isfield(DATA,'TolX')
    options.TolX = DATA.TolX;
 end
%
 if isfield(DATA,'TypicalX')
    options.TypicalX = DATA.TypicalX;
 end
%
% return
%
