//  *************************************************************************
        /// @name Temperature access functions.
        /// There are several ways to get the temperature, and several modeled
        /// temperature values that can be retrieved. The U.S. Standard Atmosphere
        /// temperature either at a specified altitude, or at sea level can be
        /// retrieved. These two temperatures do NOT include the effects of any bias
        /// or delta gradient that may have been supplied by the user. The modeled
        /// temperature and the modeled temperature at sea level can also be
        /// retrieved. These two temperatures DO include the effects of an optionally
        /// user-supplied bias or delta gradient.
        // @{
        /// Returns the actual modeled temperature in degrees Rankine at a specified
        /// altitude.
        /// @param altitude The altitude above sea level (ASL) in feet.
        /// @return Modeled temperature in degrees Rankine at the specified altitude.
        public override double GetTemperature(double altitude)
        {
            double GeoPotAlt = GeopotentialAltitude(altitude);

            double T;

            if (GeoPotAlt >= 0.0)
            {
                T = StdAtmosTemperatureTable.GetValue(GeoPotAlt);

                if (GeoPotAlt <= gradientFadeoutAltitude)
                {
                    T -= temperatureDeltaGradient * GeoPotAlt;
                }
            }
            else
            {
                // We don't need to add TemperatureDeltaGradient*GeoPotAlt here because
                // the lapse rate vector already accounts for the temperature gradient.
                T = StdAtmosTemperatureTable.GetValue(0.0) + GeoPotAlt * LapseRates[0];
            }

            T += temperatureBias;

            if (GeoPotAlt <= gradientFadeoutAltitude)
            {
                T += temperatureDeltaGradient * gradientFadeoutAltitude;
            }

            return(T);
        }
        /// Returns the standard temperature in degrees Rankine at a specified
        /// altitude.
        /// @param altitude The altitude in feet above sea level (ASL) to get the
        ///                 temperature at.
        /// @return The STANDARD temperature in degrees Rankine at the specified
        ///         altitude.
        public virtual double GetStdTemperature(double altitude)
        {
            double GeoPotAlt = GeopotentialAltitude(altitude);

            if (GeoPotAlt >= 0.0)
            {
                return(StdAtmosTemperatureTable.GetValue(GeoPotAlt));
            }
            else
            {
                return(StdAtmosTemperatureTable.GetValue(0.0) + GeoPotAlt * LapseRates[0]);
            }
        }
        /// Returns the standard pressure at the specified altitude.
        public virtual double GetStdPressure(double altitude)
        {
            double GeoPotAlt = GeopotentialAltitude(altitude);

            // Iterate through the altitudes to find the current Base Altitude
            // in the table. That is, if the current altitude (the argument passed in)
            // is 20000 ft, then the base altitude from the table is 0.0. If the
            // passed-in altitude is 40000 ft, the base altitude is 36089.2388 ft (and
            // the index "b" is 2 - the second entry in the table).
            double BaseAlt = StdAtmosTemperatureTable.GetElement(1, 0);
            int    numRows = StdAtmosTemperatureTable.GetNumRows();
            int    b;

            for (b = 0; b < numRows - 2; ++b)
            {
                double testAlt = StdAtmosTemperatureTable.GetElement(b + 2, 0);
                if (GeoPotAlt < testAlt)
                {
                    break;
                }
                BaseAlt = testAlt;
            }

            double Tmb    = GetStdTemperature(GeometricAltitude(BaseAlt));
            double deltaH = GeoPotAlt - BaseAlt;
            double Lmb    = LapseRates[b];

            if (Lmb != 0.0)
            {
                double Exp    = Constants.g0 / (Rdry * Lmb);
                double factor = Tmb / (Tmb + Lmb * deltaH);
                return(StdPressureBreakpoints[b] * Math.Pow(factor, Exp));
            }
            else
            {
                return(StdPressureBreakpoints[b] * Math.Exp(-Constants.g0 * deltaH / (Rdry * Tmb)));
            }
        }
        /// Destructor
        //virtual ~FGStandardAtmosphere();

        public override bool InitModel()
        {
            // Assume the altitude to fade out the gradient at is at the highest
            // altitude in the table. Above that, other functions are used to
            // calculate temperature.
            gradientFadeoutAltitude = StdAtmosTemperatureTable.GetElement(StdAtmosTemperatureTable.GetNumRows(), 0);

            temperatureDeltaGradient = 0.0;
            temperatureBias          = 0.0;
            LapseRates = StdLapseRates;

            PressureBreakpoints = StdPressureBreakpoints;

            SLpressure    = StdSLpressure;
            SLtemperature = StdSLtemperature;
            SLdensity     = StdSLdensity;
            SLsoundspeed  = StdSLsoundspeed;

            Calculate(0.0);

            //  PrintStandardAtmosphereTable();

            return(true);
        }