%%HP:T(3)A(D)F(.);
@ AIR pressure, temperature and density, given altitude.
@ by Jay Nestle
DIR
  CST {
GROB 21 8 0C70000290000013A00094110017110294E10984010603E0
GROB 21 8 400000800000803000484000080000003000044000083000
"STD" "ATM" "TABLE"
RUN }
  RUN
    \<<
"Prg by Jay Nestle"
DROP
"Geopotential Alt? (m)
(height above sea lvl)"
":height?:" INPUT
OBJ\-> OBJ\-> DROP 'H'
STO TST1
    \>>
  PVRS
    \<< { P T \Gr }
PURGE
    \>>
  DSPR
    \<< H "Ht (m)"
\->TAG T "T (K)" \->TAG
P "P (Pa)" \->TAG \Gr
"\Gr (kg/m^3)" \->TAG
PVRS
    \>>
  PREV1
    \<< E3.14 EVAL
OBJ\-> DROP DROP 4
RND SWAP STO E3.13
EVAL OBJ\-> DROP DROP
5 RND SWAP STO
E3.12 EVAL OBJ\->
DROP DROP 4 RND
SWAP STO DSPR
    \>>
  PREV2
    \<< E3.9 EVAL
OBJ\-> DROP DROP 4
RND SWAP STO E3.10
EVAL OBJ\-> DROP DROP
5 RND SWAP STO DSPR
\>>
  OVPRG
    \<<
"That's in space!"
    \>>
  TST7
    \<<
      IF H 105000 >
      THEN OVPRG
      ELSE 90000
'H0' STO 165.66
'T0' STO .004 'A'
STO .1105 'P0' STO
0 '\Gr0' STO PREV1
      END
    \>>
  TST6
    \<<
      IF H 90000 >
      THEN TST7
      ELSE 79000
'H0' STO 165.66 'T'
STO 1.0669 'P0' STO
.00002244 '\Gr0' STO
PREV2
      END
    \>>
  TST5
    \<<
      IF H 79000 >
      THEN TST6
      ELSE 5300
'H0' STO 282.66
'T0' STO -.0045 'A'
STO 61.493 'P0' STO
.00075791 '\Gr0' STO
PREV1
      END
    \>>
  TST4
    \<<
      IF H 53000 >
      THEN TST5
      ELSE 47000
'H0' STO 282.66 'T'
STO 125.58 'P0' STO
.0015535 '\Gr0' STO
PREV2
      END
    \>>
  TST3
    \<<
      IF H 47000 >
      THEN TST4
      ELSE 25000
'H0' STO 216.16
'T0' STO .003 'A'
STO 2527.3 'P0' STO
.040639 '\Gr0' STO
PREV1
      END
    \>>
  TST2
    \<<
      IF H 25000 >
      THEN TST3
      ELSE 11000
'H0' STO 216.66 'T'
STO 22700 'P0' STO
.3648 '\Gr0' STO
PREV2
      END
    \>>
  TST1
    \<<
      IF H 11000 >
      THEN TST2
      ELSE 0 'H0'
STO 288.16 'T0' STO
-.0065 'A' STO
101325 'P0' STO
1.225 '\Gr0' STO
PREV1
      END
    \>>
  E3.9 'P=P0*EXP((
H0-H)*G/(R*T))'
  E3.10 '\Gr=\Gr0*EXP((
H0-H)*G/(R*T))'
  E3.12 'P=P0*(T/T0
)^-(G/(A*R))'
  E3.13 '\Gr=\Gr0*(T/T0
)^-(G/(A*R)+1)'
  E3.14 'T=T0+A*(H-
H0)'
  \Gr0 1.225
  P0 101325
  G 9.8
  R 287
  A -.0065
  T0 288.16
  H0 0
  H 10000
END
