pro virtotemp,mixrat,virtemp,airtemp,badval ; Converts virtual temperature into temperature. ; KJ Davis, December, 1998. ;INPUTS ; MIXRAT - dry air mixing ratio in g H2O/kg dry air ; VIRTEMP - virtual temperature in K ; BADVAL - bad data value marker (usually -999) ;OUTPUTS ; AIRTEMP - air temperature in K. ; Ratio of water vapor gram molecular weight to 'dry air' gram ; molecular weight is EPS eps = 0.622 ; Convert mixing ratio from g/kg to kg/kg mixr=mixrat/1000. if ((mixrat ne badval) and (virtemp ne badval)) then begin ; See Wallace and Hobbs, 1977, for the conversion from temperature to ; virtual temperature. airtemp=virtemp*(1.- (mixr/(mixr+eps))*(1.-eps)) endif else begin airtemp=badval endelse ;debugging/testing stop ;stop return end