%calculates a saturated moist adiabatic lapse rate given a temperatrue and
%pressure
function out=MALR(T,P)


%define some basic physical parameters
a=6.36*10^6;
g=9.81;
cp=1004;
L=2.51*10^6; 

%calculate how the sataration mixing ration changes with temperature
delT=1;
[ESAT_H,QSAT_H] = Clausius_Clapeyron(T+delT,P);
[ESAT_L,QSAT_L] = Clausius_Clapeyron(T-delT,P);

dQdT=(QSAT_H-QSAT_L)/(2*delT);


MALR=(1000*g/cp)/(1+L*dQdT/cp);
out=MALR;
