% ------------------------------------------------------------------------
% Compute potential temperature
%
% Author:  Xin-Zhong Liang @ UMD
% Coded:   2012/08/25
%
% ------------------------------------------------------------------------

function [theta] = potemp(temp, pres)
%
%  Input:
%     temp = temperature [K]
%     pres = pressure [Pa]
%
%  Output:
%     theta = potential temperature [K]
%
%  set constants
%
   p0 = 100000.;         % standard reference pressure [Pa]
   rd = 287.04;          % gas constant for dry air [J/kg/K]
   cp = 1005.7;          % specific heat of dry air [J/kg/K]
%
%  compute the potential temperature
%
   theta = temp .* (p0 ./ pres) .^ (rd/cp);
%
%  all done
%
end