anchor.diff:  !!       RC                 REYNOLDS NUMBER BASED ON CHORD       ---
   !!       U                  FREESTREAM VELOCITY                METERS/SEC
   !!       KinViscosity       KINEMATIC VISCOSITY                M2/SEC
  -!!
  -!!
  -!!      COMPUTE ZERO ANGLE OF ATTACK BOUNDARY LAYER
  -!!      THICKNESS (METERS) AND REYNOLDS NUMBER
  -!!      -------------------------------------------
  -  REAL(ReKi),           	                  INTENT(IN   )  :: ALPSTAR        ! AOA
  -  REAL(ReKi),           	                  INTENT(IN   )  :: C              ! Chord Length
  -  REAL(ReKi),           	                  INTENT(IN   )  :: RC             !
  -  REAL(ReKi),           	                  INTENT(IN   )  :: M              !
  -  TYPE(AA_ParameterType),                         INTENT(IN   )  :: p                ! Parameters
  -
  -  REAL(ReKi),                            	  INTENT(  OUT)  :: DELTAP         !
  -  REAL(ReKi),                            	  INTENT(  OUT)  :: DSTRS          !
  -  REAL(ReKi),                            	  INTENT(  OUT)  :: DSTRP          !
  -  INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  -  character(*),                                   INTENT(  OUT)  :: errMsg         ! Error message if ErrStat /= ErrID_None
  -  integer(intKi)                                             :: ErrStat2           ! temporary Error status
  -  character(ErrMsgLen)                                       :: ErrMsg2            ! temporary Error message
  -  character(*), parameter                                    :: RoutineName = 'Thick'
  -
  -      ! Initialize variables for this routine
  -   !real(ReKi)                                    :: STPRIM(size(p%FreqList))      
  -   real(ReKi)                                    :: DELTA0              ! BOUNDARY LAYER THICKNESS AT ZERO ANGLE OF ATTACK METERS
  -   real(ReKi)                                    :: DSTR0 		! DISPLACEMENT THICKNESS AT ZERO   ANGLE OF ATTACK METERS
  -
  -   ErrStat = ErrID_None
  -   ErrMsg  = ""
  -
  -!      M        = U  / C0
  -!
  -!      RC       = U  * C/KinViscosity
  -!
  -      DELTA0   = 10.**(1.6569-.9045*LOG10(RC)+ &
  -                .0596*LOG10(RC)**2.)*C
  -!      IF (p%ITRIP .EQ. 2) DELTA0 = .6 * DELTA0  ! corrected with respect to the Suzlon document Contact Pat Moriarty for further. added 2 lines below.(EB_DTU)
  -	IF (p%ITRIP .GT. 0) DELTA0 = 10.**(1.892-0.9045*LOG(RC)+0.0596*LOG(RC)**2.)*C
  -	IF (p%ITRIP .EQ. 2) DELTA0=.6*DELTA0
  -
  -!!      COMPUTE PRESSURE SIDE BOUNDARY LAYER THICKNESS
  -!!      ----------------------------------------------
  -      DELTAP   = 10.**(-.04175*ALPSTAR+.00106*ALPSTAR**2.)*DELTA0
  -
  -!!      COMPUTE ZERO ANGLE OF ATTACK DISPLACEMENT THICKNESS
  -!!      ---------------------------------------------------
  -      IF ((p%ITRIP .EQ. 1) .OR. (p%ITRIP .EQ. 2)) THEN
  +    REAL(ReKi),                INTENT(IN   )  :: ALPSTAR        !< AOA
  +    REAL(ReKi),                INTENT(IN   )  :: C              !< Chord Length
  +    REAL(ReKi),                INTENT(IN   )  :: RC             !< RC= U*C/KinViscosity
  +    REAL(ReKi),                INTENT(IN   )  :: M              !< M = U/C0
  +    TYPE(AA_ParameterType),    INTENT(IN   )  :: p              !< Parameters
  +    REAL(ReKi),                INTENT(  OUT)  :: DELTAP         !<
  +    REAL(ReKi),                INTENT(  OUT)  :: DSTRS          !<
  +    REAL(ReKi),                INTENT(  OUT)  :: DSTRP          !<
  +    INTEGER(IntKi),            INTENT(  OUT)  :: errStat        !< Error status of the operation
  +    character(*),              INTENT(  OUT)  :: errMsg         !< Error message if ErrStat /= ErrID_None
  +    ! Local variables
  +    integer(intKi)          :: ErrStat2           ! temporary Error status
  +    character(ErrMsgLen)    :: ErrMsg2            ! temporary Error message
  +    character(*), parameter :: RoutineName = 'Thick'
  +    real(ReKi)              :: DELTA0              ! BOUNDARY LAYER THICKNESS AT ZERO ANGLE OF ATTACK METERS
  +    real(ReKi)              :: DSTR0      ! DISPLACEMENT THICKNESS AT ZERO   ANGLE OF ATTACK METERS
  +    ErrStat = ErrID_None
  +    ErrMsg  = ""
  +    !
  +    DELTA0   = 10.**(1.6569-.9045*LOG10(RC)+.0596*LOG10(RC)**2.)*C
  +    !      IF (p%ITRIP .EQ. 2) DELTA0 = .6 * DELTA0  ! corrected with respect to the Suzlon document Contact Pat Moriarty for further. added 2 lines below.(EB_DTU)
  +    IF (p%ITRIP .GT. 0) DELTA0 = 10.**(1.892-0.9045*LOG(RC)+0.0596*LOG(RC)**2.)*C
  +    IF (p%ITRIP .EQ. 2) DELTA0=.6*DELTA0
  +    ! Pressure side boundary layer thickness
  +    DELTAP   = 10.**(-.04175*ALPSTAR+.00106*ALPSTAR**2.)*DELTA0
  +    ! Compute zero angle of attack displacement thickness
  +    IF ((p%ITRIP .EQ. 1) .OR. (p%ITRIP .EQ. 2)) THEN
           IF (RC .LE. .3E+06) DSTR0 = .0601 * RC **(-.114)*C
           IF (RC .GT. .3E+06) &
  -         DSTR0=10.**(3.411-1.5397*LOG10(RC)+.1059*LOG10(RC)**2.)*C
  +            DSTR0=10.**(3.411-1.5397*LOG10(RC)+.1059*LOG10(RC)**2.)*C
           IF (p%ITRIP .EQ. 2) DSTR0 = DSTR0 * .6
  -      ELSE
  +    ELSE
           DSTR0=10.**(3.0187-1.5397*LOG10(RC)+.1059*LOG10(RC)**2.)*C
  -      ENDIF
  -!!      PRESSURE SIDE DISPLACEMENT THICKNESS
  -!!      ------------------------------------
  -       DSTRP   = 10.**(-.0432*ALPSTAR+.00113*ALPSTAR**2.)*DSTR0
  -!      IF (p%ITRIP .EQ. 3) DSTRP = DSTRP * 1.48 ! commented since itrip is never 3 check if meant 2.(EB_DTU)
  -
  -!!      SUCTION SIDE DISPLACEMENT THICKNESS
  -!!      -----------------------------------
  -      IF (p%ITRIP .EQ. 1) THEN
  +    ENDIF
  +    ! Pressure side displacement thickness
  +    DSTRP   = 10.**(-.0432*ALPSTAR+.00113*ALPSTAR**2.)*DSTR0
  +    !      IF (p%ITRIP .EQ. 3) DSTRP = DSTRP * 1.48 ! commented since itrip is never 3 check if meant 2.(EB_DTU)
  +    ! Suction side displacement thickness
  +    IF (p%ITRIP .EQ. 1) THEN
           IF (ALPSTAR .LE. 5.) DSTRS=10.**(.0679*ALPSTAR)*DSTR0
           IF((ALPSTAR .GT. 5.).AND.(ALPSTAR .LE. 12.5)) &
  -         DSTRS = .381*10.**(.1516*ALPSTAR)*DSTR0
  +            DSTRS = .381*10.**(.1516*ALPSTAR)*DSTR0
           IF (ALPSTAR .GT. 12.5)DSTRS=14.296*10.**(.0258*ALPSTAR)*DSTR0
  -      ELSE
  +    ELSE
           IF (ALPSTAR .LE. 7.5)DSTRS =10.**(.0679*ALPSTAR)*DSTR0
           IF((ALPSTAR .GT. 7.5).AND.(ALPSTAR .LE. 12.5)) &
  -         DSTRS = .0162*10.**(.3066*ALPSTAR)*DSTR0
  +            DSTRS = .0162*10.**(.3066*ALPSTAR)*DSTR0
           IF (ALPSTAR .GT. 12.5) DSTRS = 52.42*10.**(.0258*ALPSTAR)*DSTR0
  -      ENDIF
  -
  -      RETURN
  -
  -      END SUBROUTINE Thick
  -
  +    ENDIF
  +END SUBROUTINE Thick
   !====================================================================================================
  -      SUBROUTINE DIRECTH(M,THETA,PHI,DBAR, errStat, errMsg)
  -
  -!     THIS SUBROUTINE COMPUTES THE HIGH FREQUENCY
  -!     DIRECTIVITY FUNCTION FOR THE INPUT OBSERVER LOCATION
  -  REAL(ReKi),           	                  INTENT(IN   )  :: THETA       ! 
  -  REAL(ReKi),           	                  INTENT(IN   )  :: PHI        ! 
  -  REAL(ReKi),           	                  INTENT(IN   )  :: M              !
  -
  -  REAL(ReKi),                            	  INTENT(  OUT)  :: DBAR         !
  -  INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  -  character(*),                               INTENT(  OUT)  :: errMsg         ! Error message if ErrStat /= ErrID_None
  -  integer(intKi)                                             :: ErrStat2           ! temporary Error status
  -  character(ErrMsgLen)                                       :: ErrMsg2            ! temporary Error message
  -  character(*), parameter                                    :: RoutineName = 'Directh'
  -
  - ! Initialize variables for this routine
  -   real(ReKi)                                    :: MC
  -   real(ReKi)                                    :: DEGRAD
  -   real(ReKi)                                    :: PHIR
  -   real(ReKi)                                    :: THETAR
  -
  -   ErrStat = ErrID_None
  -   ErrMsg  = ""
  -
  -
  -      DEGRAD  = .017453
  -
  -      MC     = .8 * M
  -      THETAR = THETA * DEGRAD
  -      PHIR   = PHI * DEGRAD
  -
  -      DBAR=2.*SIN(THETAR/2.)**2.*SIN(PHIR)**2./((1.+M*COS(THETAR))* &
  -           (1.+(M-MC)*COS(THETAR))**2.)
  -      RETURN
  -
  -      END SUBROUTINE DirectH
  +!> This subroutine computes the high frequency directivity function for the input observer location
  +SUBROUTINE DIRECTH(M,THETA,PHI,DBAR, errStat, errMsg)
  +    REAL(ReKi),        INTENT(IN   ) :: THETA      !
  +    REAL(ReKi),        INTENT(IN   ) :: PHI        !
  +    REAL(ReKi),        INTENT(IN   ) :: M          !
  +    REAL(ReKi),        INTENT(  OUT) :: DBAR       !
  +    INTEGER(IntKi),    INTENT(  OUT) :: errStat    ! Error status of the operation
  +    character(*),      INTENT(  OUT) :: errMsg     ! Error message if ErrStat /= ErrID_None
  +    ! Local variables
  +    character(*), parameter :: RoutineName = 'Directh'
  +    real(ReKi)              :: MC
  +    real(ReKi)              :: DEGRAD
  +    real(ReKi)              :: PHIR
  +    real(ReKi)              :: THETAR
  +    ErrStat = ErrID_None
  +    ErrMsg  = ""
  +    DEGRAD = .017453
  +    MC     = .8 * M
  +    THETAR = THETA * DEGRAD
  +    PHIR   = PHI * DEGRAD
  +    DBAR   = 2.*SIN(THETAR/2.)**2.*SIN(PHIR)**2./((1.+M*COS(THETAR))* (1.+(M-MC)*COS(THETAR))**2.)
  +END SUBROUTINE DirectH
   !====================================================================================================
  -      SUBROUTINE DIRECTL(M,THETA,PHI,DBAR, errStat, errMsg)
  -!     THIS SUBROUTINE COMPUTES THE HIGH FREQUENCY
  -!     DIRECTIVITY FUNCTION FOR THE INPUT OBSERVER LOCATION
  -  REAL(ReKi),           	                  INTENT(IN   )  :: THETA       ! 
  -  REAL(ReKi),           	                  INTENT(IN   )  :: PHI        ! 
  -  REAL(ReKi),           	                  INTENT(IN   )  :: M              !
  -
  -  REAL(ReKi),                            	  INTENT(  OUT)  :: DBAR         !
  -  INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  -  character(*),                               INTENT(  OUT)  :: errMsg         ! Error message if ErrStat /= ErrID_None
  -  integer(intKi)                                             :: ErrStat2           ! temporary Error status
  -  character(ErrMsgLen)                                       :: ErrMsg2            ! temporary Error message
  -  character(*), parameter                                    :: RoutineName = 'DirectL'
  -
  - ! Initialize variables for this routine
  -   real(ReKi)                                    :: MC
  -   real(ReKi)                                    :: DEGRAD
  -   real(ReKi)                                    :: PHIR
  -   real(ReKi)                                    :: THETAR
  -
  -   ErrStat = ErrID_None
  -   ErrMsg  = "" 
  -	  
  -!     THIS SUBROUTINE COMPUTES THE LOW FREQUENCY
  -!     DIRECTIVITY FUNCTION FOR THE INPUT OBSERVER LOCATION
  -
  -      DEGRAD  = .017453
  -
  -      MC     = .8 * M
  -      THETAR = THETA * DEGRAD
  -      PHIR   = PHI * DEGRAD
  -
  -      DBAR = (SIN(THETAR)*SIN(PHIR))**2/(1.+M*COS(THETAR))**4
  -
  -      RETURN
  -
  -      END SUBROUTINE DirectL
  -
  -!==================================================================================================================================!
  -!==================================================================================================================================!
  +!> This subroutine computes the high frequency directivity function for the input observer location
  +SUBROUTINE DIRECTL(M,THETA,PHI,DBAR, errStat, errMsg)
  +    REAL(ReKi),           INTENT(IN   ) :: THETA      !<
  +    REAL(ReKi),           INTENT(IN   ) :: PHI        !<
  +    REAL(ReKi),           INTENT(IN   ) :: M          !<
  +    REAL(ReKi),           INTENT(  OUT) :: DBAR       !<
  +    INTEGER(IntKi),       INTENT(  OUT) :: errStat    !< Error status of the operation
  +    character(*),         INTENT(  OUT) :: errMsg     !< Error message if ErrStat /= ErrID_None
  +    ! Local variables
  +    character(*), parameter :: RoutineName = 'DirectL'
  +    real(ReKi)              :: MC
  +    real(ReKi)              :: DEGRAD
  +    real(ReKi)              :: PHIR
  +    real(ReKi)              :: THETAR
  +    ErrStat = ErrID_None
  +    ErrMsg  = "" 
  +    !   This subroutine computes the low frequency directivity function for the input observer location
  +    DEGRAD  = .017453
  +    MC     = .8 * M
  +    THETAR = THETA * DEGRAD
  +    PHIR   = PHI * DEGRAD
  +    DBAR = (SIN(THETAR)*SIN(PHIR))**2/(1.+M*COS(THETAR))**4
  +END SUBROUTINE DirectL
   !==================================================================================================================================!
   !===============================  Full Guidati Model Inflow Turbulence Noise -  Addition ==========================================!
   !==================================================================================================================================!
  -!==================================================================================================================================!
  -!==================================================================================================================================!
   SUBROUTINE FullGuidati(ALPSTAR,U,Chords,d,RObs,THETA,PHI,MeanVNoise,TINoise,p,whichairfoil,SPLti,errStat,errMsgn)
  -	USE Atmosphere
  -	USE TINoiseGeneric
  -	USE TINoiseGeo
  -	!USE BLParams
  -	USE TINoiseInput
  -	USE TICoords
  -	USE AirfoilParams
  -	USE TI_Guidati
  -
  -	IMPLICIT NONE
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: ALPSTAR        ! AOA					(deg)
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: Chords         ! Chord Length
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: U              !
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: d              ! element span
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: RObs           ! distance to observer
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: THETA          ! 
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: PHI            ! Spanwise directivity angle 
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: MeanVNoise     ! 
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: TINoise        ! 
  -  integer(intKi),           	      	          INTENT(IN   )  :: whichairfoil   ! whichairfoil
  -  TYPE(AA_ParameterType),                         INTENT(IN   )  :: p              ! Parameters
  -
  -
  -
  -  REAL(R8Ki),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLti         !
  -  INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  -  character(*),                                   INTENT(  OUT)  :: errMsgn         ! Error message if ErrStat /= ErrID_None
  -  integer(intKi)                                                 :: ErrStat2       ! temporary Error status
  -  character(ErrMsgLen)                                           :: ErrMsg2        ! temporary Error message
  -  character(*), parameter                                        :: RoutineName = 'FullGuidati'
  -
  -  integer(intKi)                                                 :: loop1       ! temporary 
  -! local variables
  -!  REAL(R8Ki)                   :: Mach                                            ! local mach number
  -
  -   ErrStat = ErrID_None
  -   ErrMsgn  = "" 
  -
  -	rho     = p%AirDens
  -	co      = p%SpdSound
  -	nu      = p%KinVisc
  -	aofa    = ALPSTAR
  -	a_chord = Chords
  -	npath = 40         !   Number of Streamlines                (Guidati full model)
  -	dpath = 0.005 	   !   Distance between streamlines         (Guidati full model)
  -	mach_ti = U / co
  -	CALL INICON
  -!      	CALL READIN	INSTEAD OF CALLING READIN ROUTINE THE NECESSARY VARIABLES ARE ASSIGNED WITHIN THIS SUBROUTINE
  -        csound  = co
  -        chord   = a_chord
  -        alpha_in= aofa
  -!	alpha_in=3.0d0
  -        alfa    = alpha_in(1) * pi2 / 360.0d0
  -        nfreq   = size(p%FreqList)
  -        freq_in(1:size(p%FreqList)) = p%FreqList
  -
  -	x_ti=0.0d0
  -	y_ti=0.0d0
  -	n_in=size(p%AFInfo(whichairfoil)%X_Coord)-1
  -       	x_ti(1:n_in)=p%AFInfo(whichairfoil)%X_Coord(2:n_in+1) ! starts from 2 first value is aerod center
  -       	y_ti(1:n_in)=p%AFInfo(whichairfoil)%Y_Coord(2:n_in+1) ! starts from 2 first value is aerod center
  -
  -        CALL DEFGEO
  -	CALL DRM_AER
  -        CALL DRM_ACU
  -
  -RETURN
  +    USE Atmosphere
  +    USE TINoiseGeneric
  +    USE TINoiseGeo
  +    USE TINoiseInput
  +    USE TICoords
  +    USE AirfoilParams
  +    USE TI_Guidati
  +    REAL(R8Ki),                               INTENT(IN   ) :: ALPSTAR        !< AOA                    (deg)
  +    REAL(R8Ki),                               INTENT(IN   ) :: Chords         !< Chord Length
  +    REAL(R8Ki),                               INTENT(IN   ) :: U              !<
  +    REAL(R8Ki),                               INTENT(IN   ) :: d              !< element span
  +    REAL(R8Ki),                               INTENT(IN   ) :: RObs           !< distance to observer
  +    REAL(R8Ki),                               INTENT(IN   ) :: THETA          !<
  +    REAL(R8Ki),                               INTENT(IN   ) :: PHI            !< Spanwise directivity angle
  +    REAL(R8Ki),                               INTENT(IN   ) :: MeanVNoise     !<
  +    REAL(R8Ki),                               INTENT(IN   ) :: TINoise        !<
  +    integer(intKi),                           INTENT(IN   ) :: whichairfoil   !< whichairfoil
  +    TYPE(AA_ParameterType),                   INTENT(IN   ) :: p              !< Parameters
  +    REAL(R8Ki),DIMENSION(size(p%FreqList)),   INTENT(  OUT) :: SPLti          !<
  +    INTEGER(IntKi),                           INTENT(  OUT) :: errStat        !< Error status of the operation
  +    character(*),                             INTENT(  OUT) :: errMsgn        !< Error message if ErrStat /= ErrID_None
  +    ! local variables
  +    integer(intKi)                                                 :: ErrStat2       ! temporary Error status
  +    character(ErrMsgLen)                                           :: ErrMsg2        ! temporary Error message
  +    character(*), parameter                                        :: RoutineName = 'FullGuidati'
  +    integer(intKi)                                                 :: loop1       ! temporary 
  +    ErrStat = ErrID_None
  +    ErrMsgn  = "" 
  +
  +    rho     = p%AirDens
  +    co      = p%SpdSound
  +    nu      = p%KinVisc
  +    aofa    = ALPSTAR
  +    a_chord = Chords
  +    npath = 40         !   Number of Streamlines                (Guidati full model)
  +    dpath = 0.005 	   !   Distance between streamlines         (Guidati full model)
  +    mach_ti = U / co
  +    CALL INICON
  +    ! Instead of calling readin routine the necessary variables are assigned within this subroutine
  +    csound                      = co
  +    chord                       = a_chord
  +    alpha_in                    = aofa
  +    alfa                        = alpha_in(1) * pi2 / 360.0d0
  +    nfreq                       = size(p%FreqList)
  +    freq_in(1:size(p%FreqList)) = p%FreqList
  +    x_ti                        = 0.0d0
  +    y_ti                        = 0.0d0
  +    n_in                        = size(p%AFInfo(whichairfoil)%X_Coord)-1
  +    x_ti(1:n_in)=p%AFInfo(whichairfoil)%X_Coord(2:n_in+1) ! starts from 2 first value is aerod center
  +    y_ti(1:n_in)=p%AFInfo(whichairfoil)%Y_Coord(2:n_in+1) ! starts from 2 first value is aerod center
  +
  +    CALL DEFGEO
  +    CALL DRM_AER
  +    CALL DRM_ACU
   END SUBROUTINE FullGuidati	
  -
  -!==================================================================================================================================!
  -!==================================================================================================================================!
   !==================================================================================================================================!
   !===============================  Simplified Guidati Inflow Turbulence Noise Addition =============================================!
   !==================================================================================================================================!
  -!==================================================================================================================================!
  -!==================================================================================================================================!
  -!     Uses simple correction for turbulent inflow noise from Moriarty et. al 2005
  -
  +! Uses simple correction for turbulent inflow noise from Moriarty et. al 2005
   SUBROUTINE Simple_Guidati(U,Chord,thick_10p,thick_1p,p,SPLti,errStat,errMsg)
  -
  -	IMPLICIT NONE
  -  REAL(ReKi),           	                  INTENT(IN   )  :: U              ! Vrel
  -  REAL(ReKi),           	                  INTENT(IN   )  :: Chord          ! Chord Length
  -  REAL(ReKi),           	                  INTENT(IN   )  :: thick_10p      ! 
  -  REAL(ReKi),           	                  INTENT(IN   )  :: thick_1p       ! 
  -  TYPE(AA_ParameterType),                         INTENT(IN   )  :: p              ! Parameters
  -
  -  REAL(ReKi),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLti          !
  -  INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  -  character(*),                                   INTENT(  OUT)  :: errMsg         ! Error message if ErrStat /= ErrID_None
  -  integer(intKi)                                                 :: ErrStat2       ! temporary Error status
  -  character(ErrMsgLen)                                           :: ErrMsg2        ! temporary Error message
  -  character(*), parameter                                        :: RoutineName = 'Simple_Guidati'
  -
  -! local variables
  -  INTEGER(intKi)                                                 :: loop1       ! temporary 
  -  REAL(ReKi)                   					 :: TI_Param    ! Temporary variable thickness ratio dependent 
  -  REAL(ReKi)                   					 :: slope       ! Temporary variable thickness ratio dependent 
  -
  -
  -   ErrStat = ErrID_None
  -   ErrMsg  = "" 
  -
  -      TI_Param = thick_1p + thick_10p
  -      slope = 1.123*TI_Param + 5.317*TI_Param*TI_Param
  -      do loop1 =1,size(p%FreqList)
  -         SPLti(loop1) = -slope*(2*PI*p%FreqList(loop1)*chord/U + 5.0d0)
  -      enddo	
  -
  -RETURN
  +    REAL(ReKi),           	                  INTENT(IN   )  :: U              ! Vrel
  +    REAL(ReKi),           	                  INTENT(IN   )  :: Chord          ! Chord Length
  +    REAL(ReKi),           	                  INTENT(IN   )  :: thick_10p      ! 
  +    REAL(ReKi),           	                  INTENT(IN   )  :: thick_1p       ! 
  +    TYPE(AA_ParameterType),                   INTENT(IN   )  :: p              ! Parameters
  +    REAL(ReKi),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLti          !
  +    INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  +    character(*),                             INTENT(  OUT)  :: errMsg         ! Error message if ErrStat /= ErrID_None
  +    ! local variables
  +    integer(intKi)          :: ErrStat2       ! temporary Error status
  +    character(ErrMsgLen)    :: ErrMsg2        ! temporary Error message
  +    character(*), parameter :: RoutineName = 'Simple_Guidati'
  +    INTEGER(intKi)          :: loop1       ! temporary
  +    REAL(ReKi)              :: TI_Param    ! Temporary variable thickness ratio dependent
  +    REAL(ReKi)              :: slope       ! Temporary variable thickness ratio dependent
  +    ErrStat = ErrID_None
  +    ErrMsg  = "" 
  +
  +    TI_Param = thick_1p + thick_10p
  +    slope = 1.123*TI_Param + 5.317*TI_Param*TI_Param
  +    do loop1 =1,size(p%FreqList)
  +        SPLti(loop1) = -slope*(2*PI*p%FreqList(loop1)*chord/U + 5.0d0)
  +    enddo	
   END SUBROUTINE Simple_Guidati	
  -
  -!==================================================================================================================================!
  -!==================================================================================================================================!
   !==================================================================================================================================!
   !================================ Turbulent Boundary Layer Trailing Edge Noise ====================================================!
   !=================================================== TNO START ====================================================================!
  -!==================================================================================================================================!
  -!==================================================================================================================================!
  -
  -      SUBROUTINE TBLTE_TNO(ALPSTAR,C,U,THETA,PHI,D,R,Cfall,d99all,EdgeVelAll,p,SPLP,SPLS,SPLALPH,SPLTBL,errStat,errMsgn)
  -
  -	  	
  -	USE TNOConstants
  -	USE Atmosphere
  -	USE Wavenumber
  -	USE BLParams
  -	USE AirfoilParams
  -
  -	IMPLICIT NONE
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: ALPSTAR        ! AOA					(deg)
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: C              ! Chord Length       			(m)
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: U              ! Unoise					(m/s)
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: THETA          ! DIRECTIVITY ANGLE      			(deg)
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: PHI            ! DIRECTIVITY ANGLE      			(deg) 
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: D              ! SPAN					(m)
  -  REAL(R8Ki),           	                  INTENT(IN   )  :: R              ! SOURCE TO OBSERVER DISTANCE 		(m)
  -  REAL(R8Ki),DIMENSION(2),	  		  INTENT(IN   )  :: Cfall          ! Skin friction coefficient (-)
  -  REAL(R8Ki),DIMENSION(2),	  		  INTENT(IN   )  :: d99all         ! 
  -  REAL(R8Ki),DIMENSION(2),	  		  INTENT(IN   )  :: EdgeVelAll         ! 
  -  TYPE(AA_ParameterType),                         INTENT(IN   )  :: p              ! Noise Module Parameters
  -  REAL(R8Ki),DIMENSION(size(p%FreqList)),	  INTENT(IN   )  :: SPLALPH        ! SOUND PRESSURE LEVEL DUE TO ANGLE OF ATTACK CONTRIBUTION (db)
  -  REAL(R8Ki),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLP           ! SOUND PRESSURE LEVEL DUE TO PRESSURE SIDE OF AIRFOIL (db)
  -  REAL(R8Ki),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLS           ! SOUND PRESSURE LEVEL DUE TO SUCTION SIDE OF AIRFOIL  (db)
  -  REAL(R8Ki),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLTBL         ! TOTAL SOUND PRESSURE LEVEL DUE TO TBLTE MECHANISM    (db)
  -
  -  INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
  -  character(*),                                   INTENT(  OUT)  :: errMsgn         ! Error message if ErrStat /= ErrID_None
  - 
  -  integer(intKi)                                             :: ErrStat2       ! temporary Error status
  -  character(ErrMsgLen)                                       :: ErrMsg2        ! temporary Error message
  -  character(*), parameter                                    :: RoutineName = 'TBLTE_TNO'
  -  ! Local variables
  -      REAL (kind=4):: bound,a,b
  -      REAL (kind=4):: epsabs,epsrel
  -      REAL (kind=4):: answer
  -      REAL (kind=4):: abserr,resabs,resasc
  -      REAL (kind=4):: alist (limit),blist (limit),rlist (limit)
  -      REAL (kind=4):: elist (limit)      
  -     ! REAL (ReKi):: D
  -     ! REAL (ReKi):: R
  -      REAL (kind=4):: freq(size(p%FreqList))
  -     ! REAL (ReKi):: freq(NumBands)
  -     ! REAL (ReKi):: SPLP(NumBands),SPLS(NumBands)
  -     ! REAL (ReKi):: SPLALPH(NumBands),SPLTBL(NumBands)
  -      REAL (kind=4):: SPL_press,SPL_suction
  -      REAL (kind=4):: band_width,band_ratio
  -      REAL (kind=4):: Spectrum
  -!      REAL (ReKi):: THETA,PHI
  -      REAL (ReKi):: DBARH
  -      REAL (kind=4):: P1,P2,P4
  -    
  -      INTEGER (4) :: neval
  -      INTEGER (4) :: ier
  -      INTEGER (4) :: inf
  -      INTEGER (4) :: iord (limit)
  -      INTEGER (4) :: last
  -      INTEGER (4) :: n_freq,i_low,i_hi
  -
  -      REAL (kind=4), EXTERNAL :: int2
  -
  -	n_freq= size(p%FreqList)
  -	freq  = p%FreqList
  -
  -        ErrStat = ErrID_None
  -        ErrMsgn  = ""
  -
  -    
  -      ! Body of TNO 
  -      
  -      bound  = 0.0     !lower bound of integration
  -      inf    = 2       !-infinity to +infinity
  -      epsabs = 1e-10     !absolute accuracy
  -      epsrel = 1e-10     !relative accuracy
  -    
  - !     n_freq = NumBands
  - !     freq = Third_Octave
  -      band_ratio = 2.**(1./3.)
  -    
  -!      allocate(omega(n_freq))
  -
  -!!!      COMPUTE REYNOLDS NUMBER AND MACH NUMBER
  -!!!      ---------------------------------------
  -        Mach          = SNGL(U  / p%SpdSound)
  -	co            = SNGL(p%SpdSound)
  -!	co 	      = 337.75590e0		! delete this later NafNoise Check
  -!	Mach          = SNGL(U / 337.75590e0)	! delete this later NafNoise Check
  -!!!      COMPUTE DIRECTIVITY FUNCTION
  -!!!      ----------------------------
  -       CALL DIRECTH(REAL(Mach),THETA,PHI,DBARH,errStat2,errMsg2)
  -     CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsgn, RoutineName ) 
  -
  -	Cf  =SNGL(Cfall)
  -	d99 =SNGL(d99all)
  -	edgevel =SNGL(ABS(EdgeVelAll))
  -!	rho = 1.225000e0;	nu= 1.4529e-5
  - 	rho = SNGL(p%AirDens);	nu  = SNGL(p%KinVisc)
  -
  -   do i_omega = 1,n_freq
  -    
  -         omega = 2.*pi*freq(i_omega)
  -         
  -         !integration limits
  -         a = 0.0e0
  -         b = 10*omega/(Mach*co)
  -
  -
  -         ! Convert to third octave
  -         band_width = freq(i_omega)*(sqrt(band_ratio)-1./sqrt(band_ratio))
  -         
  -         ISSUCTION = .TRUE.
  -
  -         IF (Cf(1) .LT. 0.) THEN
  +SUBROUTINE TBLTE_TNO(ALPSTAR,C,U,THETA,PHI,D,R,Cfall,d99all,EdgeVelAll,p,SPLP,SPLS,SPLALPH,SPLTBL,errStat,errMsgn)
  +    USE TNOConstants
  +    USE Atmosphere
  +    USE Wavenumber
  +    USE BLParams
  +    USE AirfoilParams
  +    REAL(R8Ki),                               INTENT(IN   ) :: ALPSTAR    !< AOA                    (deg)
  +    REAL(R8Ki),                               INTENT(IN   ) :: C          !< Chord Length                   (m)
  +    REAL(R8Ki),                               INTENT(IN   ) :: U          !< Unoise                 (m/s)
  +    REAL(R8Ki),                               INTENT(IN   ) :: THETA      !< DIRECTIVITY ANGLE                  (deg)
  +    REAL(R8Ki),                               INTENT(IN   ) :: PHI        !< DIRECTIVITY ANGLE                  (deg)
  +    REAL(R8Ki),                               INTENT(IN   ) :: D          !< SPAN                   (m)
  +    REAL(R8Ki),                               INTENT(IN   ) :: R          !< SOURCE TO OBSERVER DISTANCE        (m)
  +    REAL(R8Ki),DIMENSION(2),                  INTENT(IN   ) :: Cfall      !< Skin friction coefficient (-)
  +    REAL(R8Ki),DIMENSION(2),                  INTENT(IN   ) :: d99all     !< 
  +    REAL(R8Ki),DIMENSION(2),                  INTENT(IN   ) :: EdgeVelAll !< 
  +    TYPE(AA_ParameterType),                   INTENT(IN   ) :: p          !< Noise Module Parameters
  +    REAL(R8Ki),DIMENSION(size(p%FreqList)),   INTENT(IN   ) :: SPLALPH    !< SOUND PRESSURE LEVEL DUE TO ANGLE OF ATTACK CONTRIBUTION (db)
  +    REAL(R8Ki),DIMENSION(size(p%FreqList)),   INTENT(  OUT) :: SPLP       !< SOUND PRESSURE LEVEL DUE TO PRESSURE SIDE OF AIRFOIL (db)
  +    REAL(R8Ki),DIMENSION(size(p%FreqList)),   INTENT(  OUT) :: SPLS       !< SOUND PRESSURE LEVEL DUE TO SUCTION SIDE OF AIRFOIL  (db)
  +    REAL(R8Ki),DIMENSION(size(p%FreqList)),   INTENT(  OUT) :: SPLTBL     !< TOTAL SOUND PRESSURE LEVEL DUE TO TBLTE MECHANISM    (db)
  +    INTEGER(IntKi),                           INTENT(  OUT) :: errStat    !< Error status of the operation
  +    character(*),                             INTENT(  OUT) :: errMsgn    !< Error message if ErrStat /= ErrID_None
  +    ! Local variables
  +    integer(intKi)          :: ErrStat2                                                                                  ! temporary Error status
  +    character(ErrMsgLen)    :: ErrMsg2                                                                                   ! temporary Error message
  +    character(*), parameter :: RoutineName                              = 'TBLTE_TNO'
  +    REAL(kind=4) :: bound,a,b
  +    REAL(kind=4) :: epsabs,epsrel
  +    REAL(kind=4) :: answer
  +    REAL(kind=4) :: abserr,resabs,resasc
  +    REAL(kind=4) :: alist (limit),blist (limit),rlist (limit)
  +    REAL(kind=4) :: elist (limit)
  +    REAL(kind=4) :: freq(size(p%FreqList))
  +    REAL(kind=4) :: SPL_press,SPL_suction
  +    REAL(kind=4) :: band_width,band_ratio
  +    REAL(kind=4) :: Spectrum
  +    REAL(ReKi)   :: DBARH
  +    REAL(kind=4) :: P1,P2,P4
  +    INTEGER (4)  :: neval
  +    INTEGER (4)  :: ier
  +    INTEGER (4)  :: inf
  +    INTEGER (4)  :: iord (limit)
  +    INTEGER (4)  :: last
  +    INTEGER (4)  :: n_freq,i_low,i_hi
  +    REAL(kind=4), EXTERNAL :: int2
  +    ! Init
  +    n_freq  = size(p%FreqList)
  +    freq    = p%FreqList
  +    ErrStat = ErrID_None
  +    ErrMsgn = ""
  +    ! Body of TNO 
  +    bound  = 0.0     !lower bound of integration
  +    inf    = 2       !-infinity to +infinity
  +    epsabs = 1e-10     !absolute accuracy
  +    epsrel = 1e-10     !relative accuracy
  +    !     n_freq = NumBands
  +    !     freq = Third_Octave
  +    band_ratio = 2.**(1./3.)
  +    ! Reynolds number and mach number
  +    Mach = SNGL(U  / p%SpdSound)
  +    co   = SNGL(p%SpdSound)
  +    ! Directivity function
  +    CALL DIRECTH(REAL(Mach),THETA,PHI,DBARH,errStat2,errMsg2)
  +    CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsgn, RoutineName ) 
  +
  +    Cf  =SNGL(Cfall)
  +    d99 =SNGL(d99all)
  +    edgevel =SNGL(ABS(EdgeVelAll))
  +    !	rho = 1.225000e0;	nu= 1.4529e-5
  +    rho = SNGL(p%AirDens);	nu  = SNGL(p%KinVisc)
  +
  +    do i_omega = 1,n_freq
  +        omega = 2.*pi*freq(i_omega)
  +
  +        !integration limits
  +        a = 0.0e0
  +        b = 10*omega/(Mach*co)
  +
  +        ! Convert to third octave
  +        band_width = freq(i_omega)*(sqrt(band_ratio)-1./sqrt(band_ratio))
  +
  +        ISSUCTION = .TRUE.
  +
  +        IF (Cf(1) .LT. 0.) THEN
               write(*,*) 'Suction Cf is less than zero, Cf = ',Cf(1)
               write(*,*) 'Using BPM'
  -         ELSE
  +        ELSE
               CALL qk61(int2,a,b,answer,abserr,resabs,resasc)
               Spectrum = D/(4.*pi*R**2.)*answer
   
               SPL_suction = 10*log10(Spectrum*DBARH/2.e-5/2.e-5)
               SPLS(i_omega) = SPL_suction + 10*log10(band_width)
  -         ENDIF
  -
  -
  -         ISSUCTION = .FALSE.
  -         
  -         IF (Cf(2) .LT. 0.) THEN
  +        ENDIF
  +
  +        ISSUCTION = .FALSE.
  +
  +        IF (Cf(2) .LT. 0.) THEN
               write(*,*) 'Pressure Cf is less than zero, Cf = ',Cf(1)
               write(*,*) 'Using BPM'
  -         ELSE
  +        ELSE
               CALL qk61(int2,a,b,answer,abserr,resabs,resasc)
  -                 
  +
               Spectrum = D/(4.*pi*R**2.)*answer
               SPL_press = 10*log10(Spectrum*DBARH/2.e-5/2.e-5)
               SPLP(i_omega) = SPL_press + 10*log10(band_width)
  -         ENDIF
  -         
  -         ! Sum the noise sources SPLALPH is BPM value
  -         IF (SPLP(i_omega)    .LT. -100.) SPLP(i_omega)    = -100.
  -         IF (SPLS(i_omega)    .LT. -100.) SPLS(i_omega)    = -100.
  -
  -         P1  = 10.**(SPLP(i_omega) / 10.)
  -         P2  = 10.**(SPLS(i_omega) / 10.)
  -         P4  = 10.**(SPLALPH(i_omega) / 10.)
  -
  -         SPLTBL(i_omega) = 10. * LOG10(P1 + P2 + P4)
  -!         SPLTBL(i_omega) = 10. * ALOG10(P1 + P2 + P4)
  -
  -      enddo
  -
  -!	DO  i_omega=1,size(p%FreqList)
  -!		print*, p%FreqList(i_omega),SPLP(i_omega),SPLS(i_omega),SPLALPH(i_omega)
  -!	ENDDO
  -
  -	
  -RETURN
  +        ENDIF
  +
  +        ! Sum the noise sources SPLALPH is BPM value
  +        IF (SPLP(i_omega)    .LT. -100.) SPLP(i_omega)    = -100.
  +        IF (SPLS(i_omega)    .LT. -100.) SPLS(i_omega)    = -100.
  +
  +        P1  = 10.**(SPLP(i_omega) / 10.)
  +        P2  = 10.**(SPLS(i_omega) / 10.)
  +        P4  = 10.**(SPLALPH(i_omega) / 10.)
  +        SPLTBL(i_omega) = 10. * LOG10(P1 + P2 + P4)
  +    enddo
  +    !	DO  i_omega=1,size(p%FreqList)
  +    !		print*, p%FreqList(i_omega),SPLP(i_omega),SPLS(i_omega),SPLALPH(i_omega)
  +    !	ENDDO
   END SUBROUTINE TBLTE_TNO
   
  -!==================================================================================================================================!
  -!==================================================================================================================================!
   !==================================================================================================================================!
   !================================================= XFOIL BL SINGLE RUN ============================================================!
  -!==================================================================================================================================!
  -!==================================================================================================================================!
  -!==================================================================================================================================!
  -!      SUBROUTINE XFOIL_BL_SINGLE(p,m,whichairfoil,ChordChord,Unoise,AlphaNoise)
  -!
  +!SUBROUTINE XFOIL_BL_SINGLE(p,m,whichairfoil,ChordChord,Unoise,AlphaNoise)
   !      USE XfoilAirfoilParams
   !      USE XfoilBLParams
  -!
  -!	IMPLICIT NONE
  -!
   !  TYPE(AA_ParameterType),                INTENT(IN   )  :: p              ! Parameters
   !  TYPE(AA_MiscVarType),                  INTENT(INOUT)  :: m              !< Initial misc/optimization variables
   !  integer(intKi),           	      	 INTENT(IN   )  :: whichairfoil   ! whichairfoil
   !  REAL(kind=8),           	     	 INTENT(IN   )  :: Unoise         ! Unoise 
   !  REAL(kind=8),           	         INTENT(IN   )  :: ChordChord     ! Chord Length
   !  REAL(kind=8),           	      	 INTENT(IN   )  :: AlphaNoise     ! deg
  -!	  
   !!   INTEGER(IntKi),              		  INTENT(  OUT)  :: ErrStat                !< Error status of the operation
   !!   CHARACTER(*),               		  INTENT(  OUT)  :: ErrMsg                 !< Error message if ErrStat /= ErrID_None
  -!
   !  INTEGER(intKi)                                                 :: ErrStat2           ! temporary Error status
   !  CHARACTER(ErrMsgLen)                                           :: ErrMsg2            ! temporary Error message
   !  character(*), parameter                                        :: RoutineName = 'XFOIL_BL_SINGLE'
  
positive.code: !	tinooisess=0.1
  	!Ums = (tinooisess*U)**2
  	!Ums = (tinooisess*8)**2
  
  	!print*, 'Lturb,TINoise', Lturb,TINoise	
              CALL DIRECTL(Mach,THETA,PHI,DBARL,errStat2,errMsg2) !yes, assume that noise is low-freq in nature because turbulence length scale is large
  	    CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) 	  
       	    CALL DIRECTH(Mach,THETA,PHI,DBARH,errStat2,errMsg2)
  	    CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) 
        IF (DBARH <= 0) THEN
  	    SPLti = 0.
            RETURN
        ENDIF
   
  !! Nafnoise source code version see belo 
  !     Frequency_cutoff = 10*U/PI/Chord
  !    
  !     Ke = 3.0/(4.0*LTurb) 
  !
  !     Beta2 = 1-Mach*Mach
  !     ALPSTAR = AlphaNoise*PI/180.
  !
  !     DO I=1,size(p%FreqList)
  !         IF (p%FreqList(I) <= Frequency_cutoff) THEN
  !            Directivity = DBARL
  
negative.code:          SPLLAM(I) = G1 + G2 + G3 + SCALE
  	!!!print*,p%FreqList(I),SPLLAM(I)
  	ENDDO
  END SUBROUTINE LBLVS
  !==================================================================================================================================!
  SUBROUTINE TBLTE(ALPSTAR,C,U,THETA,PHI,L,R,p,jj,ii,kk,d99Var2,dstarVar1,dstarVar2,StallVal,SPLP,SPLS,SPLALPH,SPLTBL,errStat,errMsg)
      REAL(ReKi),           	                  INTENT(IN   )  :: ALPSTAR        ! AOA					(deg)
      REAL(ReKi),           	                  INTENT(IN   )  :: C              ! Chord Length           (m)
      REAL(ReKi),           	                  INTENT(IN   )  :: U              ! Unoise					(m/s)
      REAL(ReKi),           	                  INTENT(IN   )  :: THETA          ! DIRECTIVITY ANGLE      (deg)
      REAL(ReKi),           	                  INTENT(IN   )  :: PHI            ! DIRECTIVITY ANGLE      (deg) 
      REAL(ReKi),           	                  INTENT(IN   )  :: L              ! SPAN					(m)
      REAL(ReKi),           	                  INTENT(IN   )  :: R              ! SOURCE TO OBSERVER DISTANCE (m)
      REAL(ReKi),           	                  INTENT(IN   )  :: d99Var2        !  
      REAL(ReKi),           	                  INTENT(IN   )  :: dstarVar1              !  
      REAL(ReKi),           	                  INTENT(IN   )  :: dstarVar2              !  
      REAL(ReKi),           	                  INTENT(IN   )  :: StallVal              !  
      INTEGER(IntKi),                   		  INTENT(  IN)  :: jj        ! Error status of the operation
      INTEGER(IntKi),                   		  INTENT(  IN)  :: ii        ! Error status of the operation
  
      INTEGER(IntKi),                   		  INTENT(  IN)  :: kk        ! Error status of the operation
      TYPE(AA_ParameterType),                         INTENT(IN   )  :: p              ! Noise Module Parameters
      REAL(ReKi),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLP           ! SOUND PRESSURE LEVEL DUE TO PRESSURE SIDE OF AIRFOIL (db)
      REAL(ReKi),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLS           ! SOUND PRESSURE LEVEL DUE TO SUCTION SIDE OF AIRFOIL  (db)
      REAL(ReKi),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLTBL         ! TOTAL SOUND PRESSURE LEVEL DUE TO TBLTE MECHANISM    (db)
      REAL(ReKi),DIMENSION(size(p%FreqList)),	  INTENT(  OUT)  :: SPLALPH        ! SOUND PRESSURE LEVEL DUE TO ANGLE OF ATTACK CONTRIBUTION (db)
      INTEGER(IntKi),                   		  INTENT(  OUT)  :: errStat        ! Error status of the operation
      character(*),                                   INTENT(  OUT)  :: errMsg         ! Error message if ErrStat /= ErrID_None
      integer(intKi)                                                 :: ErrStat2       ! temporary Error status
      character(ErrMsgLen)                                           :: ErrMsg2        ! temporary Error message
      character(*), parameter                                        :: RoutineName = 'TBLTE'
      ! Local variables
      real(ReKi)   :: STP        ! PRESSURE SIDE STROUHAL NUMBER          --- 
      real(ReKi)   :: STS        ! SUCTION SIDE STROUHAL NUMBER           ---
      real(ReKi)   :: DSTRS      ! SUCTION SIDE DISPLACEMENT THICKNESS   METERS
      real(ReKi)   :: DSTRP      ! PRESSURE SIDE DISPLACEMENT THICKNESS  METERS
      real(ReKi)   :: RDSTRS     ! REYNOLDS NUMBER BASED ON SUCTION  SIDE DISPLACEMENT THICKNESS 
      real(ReKi)   :: RDSTRP     ! REYNOLDS NUMBER BASED ON PRESSURE SIDE DISPLACEMENT THICKNESS
      real(ReKi)   :: ST1        ! PEAK STROUHAL NUMBER                   ---
      real(ReKi)   :: ST2        ! PEAK STROUHAL NUMBER                   ---
      real(ReKi)   :: ST1PRIM    ! PEAK STROUHAL NUMBER                   ---
      real(ReKi)   :: A0         ! FUNCTION USED IN 'A' CALCULATION
      real(ReKi)   :: A02        ! FUNCTION USED IN 'A' CALCULATION
      real(ReKi)   :: ARA0       ! INTERPOLATION FACTOR
      real(ReKi)   :: ARA02      ! INTERPOLATION FACTOR
      real(ReKi)   :: B0         ! FUNCTION USED IN 'B' CALCULATION
      real(ReKi)   :: BMINB0     ! MINIMUM 'B' EVALUATED AT B0            DB
      real(ReKi)   :: BMINB      ! MINIMUM 'B' EVALUATED AT B             DB
      real(ReKi)   :: BMAXB0     ! MAXIMUM 'B' EVALUATED AT B0            DB
      real(ReKi)   :: BMAXB      ! MAXIMUM 'B' EVALUATED AT B             DB
      real(ReKi)   :: BRB0       ! INTERPOLATION FACTOR                   DB
      real(ReKi)   :: STPEAK     ! PEAK STROUHAL NUMBER                   ---
      real(ReKi)   :: AMINA      ! MINIMUM 'A' CURVE EVALUATED AT STROUHAL NUMBER RATIO                DB
      real(ReKi)   :: AMINB      ! MINIMUM 'A' CURVE EVALUATED AT B       DB
      real(ReKi)   :: AMAXA      ! MAXIMUM 'A' CURVE EVALUATED AT STROUHAL NUMBER RATIO    (DB)
      real(ReKi)   :: AMAXB      ! MAXIMUM 'A' CURVE EVALUATED AT B       DB
      real(ReKi)   :: AMINA0     ! MAXIMUM 'B' EVALUATED AT B0            DB
      real(ReKi)   :: AMINA02    ! MINIMUM 'A' CURVE EVALUATED AT A02     DB
      real(ReKi)   :: AMAXA0     ! MAXIMUM 'A' CURVE EVALUATED AT A0      DB
      real(ReKi)   :: AMAXA02    ! MAXIMUM 'A' CURVE EVALUATED AT A02      DB
      real(ReKi)   :: A          ! STROUHAL NUMBER RATIO                 ---
      real(ReKi)   :: B          ! STROUHAL NUMBER RATIO                 ---
      real(ReKi)   :: AA         ! 'A' SPECTRUM SHAPE EVALUATED AT STROUHAL NUMBER RATIO         DB
      real(ReKi)   :: BB         ! 'B' SPECTRUM SHAPE EVALUATED AT STROUHAL NUMBER RATIO                DB
      real(ReKi)   :: DELK1      ! CORRECTION TO AMPLITUDE FUNCTION       DB
      real(ReKi)   :: GAMMA      ! USED IN 'B' COMPUTATION                ---
      real(ReKi)   :: BETA       ! USED IN 'B' COMPUTATION               ---
      real(ReKi)   :: GAMMA0     ! USED IN 'B' COMPUTATION                ---
      real(ReKi)   :: BETA0      ! USED IN 'B' COMPUTATION               ---
      real(ReKi)   :: K1         ! AMPLITUDE FUNCTION						 (DB)
      real(ReKi)   :: K2         ! AMPLITUDE FUNCTION						 (DB)
      real(ReKi)   :: P1         ! PRESSURE SIDE PRESSURE 					 (NT/M2)
      real(ReKi)   :: P2         ! SUCTION SIDE PRESSURE                      (NT/M2)
      real(ReKi)   :: P4         ! PRESSURE FROM ANGLE OF ATTACK CONTRIBUTION (NT/M2)
      real(ReKi)   :: M          ! MACH NUMBER
      real(ReKi)   :: RC         ! REYNOLDS NUMBER BASED ON  CHORD
      real(ReKi)   :: DELTAP     ! PRESSURE SIDE BOUNDARY LAYER THICKNESS METERS
      real(ReKi)   :: XCHECK     ! USED TO CHECK FOR ANGLE OF ATTACK CONTRIBUTION     
      real(ReKi)   :: DBARH      ! HIGH FREQUENCY DIRECTIVITY             ---
      real(ReKi)   :: DBARL      ! LOW FREQUENCY DIRECTIVITY              ---
  
      integer(intKi)				      :: I          ! I A generic index for DO loops.
  
      LOGICAL     :: SWITCH  !!LOGICAL FOR COMPUTATION OF ANGLE OF ATTACK CONTRIBUTION   
  
      ErrStat = ErrID_None
      ErrMsg  = ""
      ! Compute reynolds number and mach number
      M          = U  / p%SpdSound
      RC         = U  * C/p%KinVisc
      ! Compute boundary layer thicknesses
      IF (p%X_BLMethod .eq. 2) THEN
          DELTAP = d99Var2
          DSTRS  = dstarVar1
          DSTRP  = dstarVar2
      ELSE
          CALL THICK(C,M,RC,ALPSTAR,p,DELTAP,DSTRS,DSTRP,errStat2,errMsg2)
          CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) 
      ENDIF
      ! Compute directivity function
      CALL DIRECTL(M,THETA,PHI,DBARL,errStat2,errMsg2)
      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) 	  
      CALL DIRECTH(M,THETA,PHI,DBARH,errStat2,errMsg2)
      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) 
      !      IF (DBARH <= 0) THEN
      !          SPLP = 0.
      !          SPLS = 0.
      !          SPLALPH = 0.
      !          RETURN
      !      ENDIF
      ! Calculate the reynolds numbers based on pressure and suction displacement thickness
      RDSTRS = DSTRS * U  / p%KinVisc
      RDSTRP = DSTRP * U  / p%KinVisc
      ! Determine peak strouhal numbers to be used for 'a' and 'b' curve calculations
      ST1    = .02 * M ** (-.6)
      ! corrected with respect to the Suzlon document Contact Pat Moriarty for further. added 4 lines below.(EB_DTU)
      IF  (ALPSTAR .LE. 1.33)                          ST2 = ST1
      IF ((ALPSTAR .GT. 1.33).AND.(ALPSTAR .LE. 12.5)) ST2 = ST1*10.**(.0054*(ALPSTAR-1.33)**2.)
      IF (ALPSTAR .GT. 12.5)                           ST2 = 4.72 * ST1
      ST1PRIM = (ST1+ST2)/2.
      CALL A0COMP(RC,A0)
      CALL A0COMP(3.*RC,A02)
      ! Evaluate minimum and maximum 'a' curves at a0
      CALL AMIN(A0,AMINA0)
      CALL AMAX(A0,AMAXA0)
      CALL AMIN(A02,AMINA02)
      CALL AMAX(A02,AMAXA02)
      ! Compute 'a' max/min ratio
      ARA0  = (20. + AMINA0) / (AMINA0 - AMAXA0)
      ARA02 = (20. + AMINA02)/ (AMINA02- AMAXA02)
      ! Compute b0 to be used in 'b' curve calculations
      IF (RC .LT. 9.52E+04) B0 = .30
      IF ((RC .GE. 9.52E+04).AND.(RC .LT. 8.57E+05)) &
          B0 = (-4.48E-13)*(RC-8.57E+05)**2. + .56
      IF (RC .GE. 8.57E+05) B0 = .56
      ! Evaluate minimum and maximum 'b' curves at b0
      CALL BMIN(B0,BMINB0)
      CALL BMAX(B0,BMAXB0)
      ! Compute 'b' max/min ratio
      BRB0  = (20. + BMINB0) / (BMINB0 - BMAXB0)
  
      ! For each center frequency, compute an 'a' prediction for the pressure side
      STPEAK = ST1
      IF (RC .LT. 2.47E+05)                        K1 = -4.31 * LOG10(RC) + 156.3
      IF((RC .GE. 2.47E+05).AND.(RC .LE. 8.0E+05)) K1 = -9.0 * LOG10(RC) + 181.6
      IF (RC .GT. 8.0E+05)                         K1 = 128.5
      IF (RDSTRP .LE. 5000.) DELK1 = -ALPSTAR*(5.29-1.43*LOG10(RDSTRP))
      IF (RDSTRP .GT. 5000.) DELK1 = 0.0
  
      GAMMA   = 27.094 * M +  3.31
      BETA    = 72.650 * M + 10.74
      GAMMA0  = 23.430 * M +  4.651
      BETA0   =-34.190 * M - 13.820
  
      IF (ALPSTAR .LE. (GAMMA0-GAMMA)) K2 = -1000.0
      IF ((ALPSTAR.GT.(GAMMA0-GAMMA)).AND.(ALPSTAR.LE.(GAMMA0+GAMMA))) &
          K2=SQRT(BETA**2.-(BETA/GAMMA)**2.*(ALPSTAR-GAMMA0)**2.)+BETA0
      IF (ALPSTAR .GT. (GAMMA0+GAMMA)) K2 = -12.0
      K2 = K2 + K1
      ! Check for 'a' computation for suction side
      XCHECK = GAMMA0
      SWITCH = .FALSE.
      !older version:
      !      IF ((ALPSTAR .GE. XCHECK).OR.(ALPSTAR .GT. 12.5))SWITCH=.TRUE. 
      ! newer version
      IF ((ALPSTAR .GE. XCHECK).OR.(ALPSTAR .GT. StallVal))SWITCH=.TRUE. 
      DO  I=1,size(p%FreqList)
          STP= p%FreqList(I) * DSTRP / U
          A      = LOG10( STP / STPEAK )
          CALL AMIN(A,AMINA)
  