%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: 
%== comp_press_bar =============================================
% comp_press_bar: calculates the temparature compensated pressure in bar
% using the method in Appendix G of the Parosci Digiquartz manual
%(from Odyssey Code parosci.c)
%
% AUTHOR:  Sib and Rob
% DATE:    2002/10/23
%
% RETURNS: Depth in meters.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [press] = comp_press_bar( p_per, double t_per)

% double Parosci::comp_press_bar(double p_per, double t_per)
% double U, Temp;
% double Tn, C, D, T0, psi;

  U = t_per - pc[U0];
  C = pc[C1] + (pc[C2] + pc[C3]*U)*U;
  D = pc[D1] + pc[D2]*U;
  T0 = pc[T1] + (pc[T2] + (pc[T3] + (pc[T4] + pc[T5]*U)*U)*U)*U;
  Tn = T0*T0/(p_per*p_per);
  psi = C*(1-Tn) * (1-D*(1-Tn));

  return psiToBar(psi);
}
