      SUBROUTINE AIRPROP(T_AMBK,P_KPA,AIRPROPS)

!--------------------------------------------------------------------------------
!      THIS SUBROUTINE TAKES TEMPERATURE (K) AND PRESSURE (kPa) AS ARGUMENTS
!      AND CALCULATES VARIOUS PROPERTIES OF DRY AIR. THE PROPOERTIES ARE 
!      BASED ON CURVE FITS THAT COME FROM THE CORRESPONDING EES (VERSION 6.207)
!      THERMOPHYSICAL FUNCTIONS
!--------------------------------------------------------------------------------
! Copyright © 2004 Thermal Energy System Specialists, LLC. All rights reserved.

	IMPLICIT NONE
      
      INTEGER, PARAMETER :: iknd=SELECTED_INT_KIND(8)  ! nobody does this
      INTEGER, PARAMETER :: DP=SELECTED_REAL_KIND(14)  ! this is double precision
      INTEGER, PARAMETER :: SP=SELECTED_REAL_KIND(6)  ! this is single precision
      
	real(DP) :: T_AMBK,P_KPA,AIRPROPS(5)    !,P_KP

!     SPECIFIC VOLUME [m^3/kg] = F(TEMPERATURE [K],PRESSURE [KPA])       
      AIRPROPS(1) = 1.836D0 + 0.0057304D0*T_AMBK - 1.3190D-09*T_AMBK**2 
     &-0.036364D0*P_KPA+0.00017586D0*P_KPA**2-0.000027907D0*T_AMBK*P_KPA

!     VISCOSITY [kg/m-s] = F(TEMPERATURE [K])
      AIRPROPS(2) = 0.0000017531D0 + 6.6382D-08*T_AMBK - 3.8634D-11*
     & T_AMBK**2 + 1.2279D-14*T_AMBK**3

!     PRANDTL NUMBER [-] = F(TEMPERATURE [K])
      AIRPROPS(3) = 0.85542D0 - 0.00086742D0*T_AMBK + 0.0000017383D0*
     & T_AMBK**2 - 1.5090D-09*T_AMBK**3 + 4.9145D-13*T_AMBK**4

!     THERMAL CONDUCTIVITY [W/m-K] = F(TEMPERATURE [K])
      AIRPROPS(4) = 0.0037165D0 + 0.000079354D0*T_AMBK - 
     & 1.5903D-08*T_AMBK**2

!     SPECIFIC HEAT [kJ/kg-K] = F(TEMPERATURE [K])
	IF (T_AMBK.LE.400.D0) THEN
         AIRPROPS(5) = 0.81764D0 + 0.0017855D0*T_AMBK - 0.0000056517D0*
     &    T_AMBK**2 + 6.0054D-09*T_AMBK**3
	ELSE
	   AIRPROPS(5) = 1.0027D0 - 0.00017196D0*T_AMBK + 5.8549D-07*
     &    T_AMBK**2 - 2.7594D-10*T_AMBK**3
      ENDIF
      
      return
      end subroutine Airprop


!      DOUBLE PRECISION FUNCTION HFG_WATER(T1,STATUS)
!	  IMPLICIT NONE
!	  DOUBLE PRECISION T1  !C
!	  INTEGER STATUS
!
!C      CHECK FOR OUT OF CORRELATION RANGE
!	  IF(T1.LT.-164.) THEN
!	     STATUS=1
!	     T1=-164.
!	  ELSE IF(T1.GT.300.) THEN
!	     STATUS=1
!	     T1=300.
!	  ELSE
!	     STATUS=0
!	  ENDIF
!
!C      USE A CORRELATION FROM EES TO GET THE VALUE
!        IF(T1.LT.0.) THEN
!	     HFG_WATER=2834.27-0.240108*T1-0.00354147*T1*T1
!	  ELSE
!	     HFG_WATER=2505.03 - 2.63922*T1 + 0.00394873*T1*T1 
!	1              - 0.0000242865*T1*T1*T1
!	  ENDIF
!      END
