function ew = vapor_press(pressure, t)
%function ew = vapor_press(pressure, t)
%This returns the partial pressure, ew, of water vapor in air at
%saturation over sea water.  pressure is the air pressure in millibars
%and t is the water temperature in celsius.

%ew_pure is the saturation vapor pressure of pure water vapor
%over a plane water surface in millibars, given t, the temperature in
%degrees celsius.  The formula is A4.5 in Gill and has been checked
%against tabulated values in the Chemical Rubber tables.
%ew_air involves correcting ew_pure for water vapor in air. From
%A4.6 and A4.7 in Gill.
%A final correction is for the conversion from fresh water to
%seawater.  This is taken from page 46 of Kraus (1972).

%     Copyright J. V. Mansbridge, CSIRO, september 28 1993

%Define scale factors.

salinity = 0.035;
cmw_ms = 0.527;
rescale = 1 - cmw_ms*salinity;

if ( t < -40 | t > 40 )
  str = ['t = ' num2str(t) ' is outside the range (-40, 40)' ];
  disp(str)
  abort
else
  ew_pure = 10.^((0.7859 + 0.03477*t)./(1 + 0.00412*t));
  ew_air = ( 1 + 1.0e-6*pressure.*( 4.5 + 0.0006*t.^2 ) ).*ew_pure;
  ew = rescale*ew_air;
end

