function out = stdatm(z);

% stdatm.m
%
% Syntax: pressure = stdatm(elevation)
%
% Units: elevation in m; pressure in hPa; accepts vector arguments
%
% This function converts elevation to atmospheric pressure according
% to the "standard atmosphere" (cf. CRC Handbook of Chem and Phys). 
%
% Written by Greg Balco -- UW Cosmogenic Nuclide Lab
% balcs@u.washington.edu
% First version, Feb. 2001
% checked March, 2006
% Part of the CRONUS-Earth online calculators: 
%      http://hess.ess.washington.edu/math
%
% Copyright 2001-2007, University of Washington
% All rights reserved
% Developed in part with funding from the National Science Foundation.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License, version 2,
% as published by the Free Software Foundation (www.fsf.org).

% define constants

gmr = -0.03417;

Ts = 288.15;

dtdz = 0.0065;

Ps = 1013.25;

% calculation

out_1 = Ps .* exp( (gmr/dtdz) .* ( log(Ts) - log(Ts - (z.*dtdz)) ) );

% return a row vector

if size(out_1,1) > size(out_1,2);
	out = out_1';
else;
	out = out_1;
end;
