anchor.diff:  !----------------------------------------------------------------------------------------------------------------------------------
   !----------------------------------------------------------------------------------------------------------------------------------
   !----------------------------------------------------------------------------------------------------------------------------------
  -!----------------------------------------------------------------------------------------------------------------------------------
  -
   SUBROUTINE REadTICalcTables( InputFile,InputFileData,  ErrStat, ErrMsg )
  -! This routine reads in the primary Noise input file and places the values it reads in the InputFileData structure.
  -!   It opens and prints to an echo file if requested.
  -!..................................................................................................................................
  -
  -
  -   implicit none
  -
  -      ! Passed variables
  -   integer(IntKi),     intent(out)     :: ErrStat                             ! Error status
  -   character(*),       intent(out)     :: ErrMsg                              ! Error message
  -   type(AA_InputFile), intent(inout)   :: InputFileData                       ! All the data in the Noise input file
  -   character(*),       intent(in)      :: InputFile                           ! Name of the file containing the primary input data
  -
  -      ! Local variables:
  -   integer(IntKi)                :: I                                         ! loop counter
  -   integer(IntKi)                :: UnIn,UnIn2                                ! Unit number for reading file
  -   integer(IntKi)                :: loop1                                     ! loop counter
  -   character(1024)               :: FileName                              ! name of the files containing obesever location
  -   integer(IntKi)                :: ErrStat2, IOS,cou                             ! Temporary Error status
  -   logical                       :: Echo                                      ! Determines if an echo file should be written
  -   character(ErrMsgLen)          :: ErrMsg2                                   ! Temporary Error message
  -   character(1024)               :: PriPath                                   ! Path name of the primary file
  -   character(1024)               :: FTitle                                    ! "File Title": the 2nd line of the input file, which contains a description of its contents
  -   character(200)                :: Line                                      ! Temporary storage of a line from the input file (to compare with "default")
  -   character(*), parameter       :: RoutineName = 'REadTICalcTables'
  -   integer(IntKi)                :: GridY                                     ! 
  -   integer(IntKi)                :: GridZ                                    !    
  -   integer(IntKi)                :: cou1,UnEc                                  ! loop counter  
  -      ! Initialize some variables:
  -   ErrStat = ErrID_None
  -   ErrMsg  = ""
  -   
  -
  -   CALL GetPath( InputFile, PriPath )     ! Input files will be relative to the path where the primary input file is located.
  -
  -	FileName = TRIM(PriPath)//'TIGrid_In.txt'
  - 
  - 
  -     CALL GetNewUnit( UnIn, ErrStat2, ErrMsg2 )
  -      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -
  -     CALL OpenFInpFile ( UnIn, FileName, ErrStat2, ErrMsg2 )
  -      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -
  -      IF ( ErrStat2 >= AbortErrLev ) THEN
  -         print*, 'File Not Found ', FileName
  -         print*, 'Aborting due to missing file AeroAcoustics require for TI Grid because interpolation is on in Aeroacoustics.dat '
  - 	 call abort
  -         RETURN
  -      END IF
  -
  -
  -      CALL ReadCom( UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )   
  -      CALL ReadVar( UnIn, FileName, GridY, 'GridY',   'Echo flag', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -		 
  -      CALL ReadCom( UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )   
  -      CALL ReadVar( UnIn, FileName, GridZ, 'GridZ',   'Echo flag', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -
  -      CALL ReadCom( UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )   
  -      CALL ReadVar( UnIn, FileName, InputFileData%dy_turb_in, 'InputFileData%dy_turb_in',   'Echo flag', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -
  -      CALL ReadCom( UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )   
  -      CALL ReadVar( UnIn, FileName, InputFileData%dz_turb_in, 'InputFileData%dz_turb_in',   'Echo flag', ErrStat2, ErrMsg2, UnEc )
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -		 
  -      CALL AllocAry( InputFileData%TI_Grid_In,GridZ,GridY,'InputFileData%TI_Grid_In', ErrStat2, ErrMsg2)
  -         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -		 print*, size(InputFileData%TI_Grid_In,1),size(InputFileData%TI_Grid_In,2)
  -     DO cou1=1,size(InputFileData%TI_Grid_In,1)
  - 		read(UnIn,*)  InputFileData%TI_Grid_In(cou1,:)
  -     ENDDO		 
  -
  -		 
  -      ! Return on error at end of section
  -   IF ( ErrStat >= AbortErrLev ) THEN
  -      CALL Cleanup()
  -      RETURN
  -   END IF            
  - 
  -   !---------------------- END OF FILE -----------------------------------------
  -      
  -   CALL Cleanup( )
  -   RETURN
  -
  +    ! Passed variables
  +    integer(IntKi),     intent(out)     :: ErrStat                             ! Error status
  +    character(*),       intent(out)     :: ErrMsg                              ! Error message
  +    type(AA_InputFile), intent(inout)   :: InputFileData                       ! All the data in the Noise input file
  +    character(*),       intent(in)      :: InputFile                           ! Name of the file containing the primary input data
  +    ! Local variables:
  +    integer(IntKi)                :: I                                         ! loop counter
  +    integer(IntKi)                :: UnIn,UnIn2                                ! Unit number for reading file
  +    integer(IntKi)                :: loop1                                     ! loop counter
  +    character(1024)               :: FileName                              ! name of the files containing obesever location
  +    integer(IntKi)                :: ErrStat2, IOS,cou                             ! Temporary Error status
  +    logical                       :: Echo                                      ! Determines if an echo file should be written
  +    character(ErrMsgLen)          :: ErrMsg2                                   ! Temporary Error message
  +    character(1024)               :: PriPath                                   ! Path name of the primary file
  +    character(1024)               :: FTitle                                    ! "File Title": the 2nd line of the input file, which contains a description of its contents
  +    character(200)                :: Line                                      ! Temporary storage of a line from the input file (to compare with "default")
  +    character(*), parameter       :: RoutineName = 'REadTICalcTables'
  +    integer(IntKi)                :: GridY                                     ! 
  +    integer(IntKi)                :: GridZ                                    !    
  +    integer(IntKi)                :: cou1,UnEc                                  ! loop counter  
  +    ! Initialize some variables:
  +    ErrStat = ErrID_None
  +    ErrMsg  = ""
  +
  +    CALL GetPath( InputFile, PriPath )     ! Input files will be relative to the path where the primary input file is located.
  +
  +    FileName = TRIM(PriPath)//'TIGrid_In.txt'
  +
  +    CALL GetNewUnit( UnIn, ErrStat2, ErrMsg2); call check()
  +    CALL OpenFInpFile ( UnIn, FileName, ErrStat2, ErrMsg2 ); if(Failed()) return
  +
  +    CALL ReadCom(UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc); call check
  +    CALL ReadVar(UnIn, FileName, GridY, 'GridY',   'Echo flag', ErrStat2, ErrMsg2, UnEc); call check
  +    CALL ReadCom(UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc );call check
  +    CALL ReadVar(UnIn, FileName, GridZ, 'GridZ',   'Echo flag', ErrStat2, ErrMsg2, UnEc); call check
  +    CALL ReadCom(UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc); call check
  +    CALL ReadVar(UnIn, FileName, InputFileData%dy_turb_in, 'InputFileData%dy_turb_in',   'Echo flag', ErrStat2, ErrMsg2, UnEc); call check
  +    CALL ReadCom(UnIn, FileName, 'Text Line', ErrStat2, ErrMsg2, UnEc); call check
  +    CALL ReadVar(UnIn, FileName, InputFileData%dz_turb_in, 'InputFileData%dz_turb_in',   'Echo flag', ErrStat2, ErrMsg2, UnEc); call check
  +    if(Failed()) return
  +
  +    CALL AllocAry( InputFileData%TI_Grid_In,GridZ,GridY,'InputFileData%TI_Grid_In', ErrStat2, ErrMsg2); 
  +    if(Failed()) return
  +    DO cou1=1,size(InputFileData%TI_Grid_In,1)
  +        read(UnIn,*)  InputFileData%TI_Grid_In(cou1,:)
  +    ENDDO		 
  +    !---------------------- END OF FILE -----------------------------------------
  +    CALL Cleanup( )
   
   CONTAINS
  -   !...............................................................................................................................
  +    logical function Failed()
  +        call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) 
  +        Failed =  ErrStat >= AbortErrLev
  +        if(Failed) call cleanup()
  +    end function Failed
  +   SUBROUTINE Check()
  +       CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
  +   END SUBROUTINE Check
      SUBROUTINE Cleanup()
  -   ! This subroutine cleans up any local variables and closes input files
  -   !...............................................................................................................................
  -
  -   IF (UnIn > 0) CLOSE ( UnIn )
  -
  +       IF (UnIn > 0) CLOSE ( UnIn )
      END SUBROUTINE Cleanup
  -   !...............................................................................................................................
   END SUBROUTINE REadTICalcTables
   
  -
  -!----------------------------------------------------------------------------------------------------------------------------------
  -!----------------------------------------------------------------------------------------------------------------------------------
   !----------------------------------------------------------------------------------------------------------------------------------
   SUBROUTINE AA_PrintSum( InputFileData, p, u, y, ErrStat, ErrMsg )
  -! This routine generates the summary file, which contains a summary of input file options.
  -
  -      ! passed variables
  -   TYPE(AA_InputFile),        INTENT(IN)  :: InputFileData                        ! Input-file data
  -   TYPE(AA_ParameterType),    INTENT(IN)  :: p                                    ! Parameters
  -   TYPE(AA_InputType),        INTENT(IN)  :: u                                    ! inputs 
  -   TYPE(AA_OutputType),       INTENT(IN)  :: y                                    ! outputs
  -   INTEGER(IntKi),            INTENT(OUT) :: ErrStat
  -   CHARACTER(*),              INTENT(OUT) :: ErrMsg
  -
  -
  -      ! Local variables.
  -
  -   INTEGER(IntKi)               :: I                                               ! Index for the nodes.
  -   INTEGER(IntKi)               :: UnSu                                            ! I/O unit number for the summary output file
  -
  -   CHARACTER(*), PARAMETER      :: FmtDat    = '(A,T35,1(:,F13.3))'                ! Format for outputting mass and modal data.
  -   CHARACTER(*), PARAMETER      :: FmtDatT   = '(A,T35,1(:,F13.8))'                ! Format for outputting time steps.
  -
  -   CHARACTER(30)                :: OutPFmt                                         ! Format to print list of selected output channels to summary file
  -   CHARACTER(100)               :: Msg                                             ! temporary string for writing appropriate text to summary file
  -
  -   ! Open the summary file and give it a heading.
  -
  -
  -RETURN
  +    ! This routine generates the summary file, which contains a summary of input file options.
  +    ! passed variables
  +    TYPE(AA_InputFile),        INTENT(IN)  :: InputFileData                        ! Input-file data
  +    TYPE(AA_ParameterType),    INTENT(IN)  :: p                                    ! Parameters
  +    TYPE(AA_InputType),        INTENT(IN)  :: u                                    ! inputs 
  +    TYPE(AA_OutputType),       INTENT(IN)  :: y                                    ! outputs
  +    INTEGER(IntKi),            INTENT(OUT) :: ErrStat
  +    CHARACTER(*),              INTENT(OUT) :: ErrMsg
  +    ! Local variables.
  +    INTEGER(IntKi)               :: I                                               ! Index for the nodes.
  +    INTEGER(IntKi)               :: UnSu                                            ! I/O unit number for the summary output file
  +    CHARACTER(*), PARAMETER      :: FmtDat    = '(A,T35,1(:,F13.3))'                ! Format for outputting mass and modal data.
  +    CHARACTER(*), PARAMETER      :: FmtDatT   = '(A,T35,1(:,F13.8))'                ! Format for outputting time steps.
  +    CHARACTER(30)                :: OutPFmt                                         ! Format to print list of selected output channels to summary file
  +    CHARACTER(100)               :: Msg                                             ! temporary string for writing appropriate text to summary file
  +    ! Open the summary file and give it a heading.
  +    RETURN
   END SUBROUTINE AA_PrintSum
   
  -!----------------------------------------------------------------------------------------------------------------------------------
   !----------------------------------------------------------------------------------------------------------------------------------
   SUBROUTINE Calc_WriteOutput( p, u, m, y, ErrStat, ErrMsg )
  -   
      TYPE(AA_ParameterType),    INTENT(IN   )  :: p                                 ! The module parameters
      TYPE(AA_InputType),        INTENT(IN   )  :: u                                 ! inputs
      TYPE(AA_MiscVarType),      INTENT(INOUT)  :: m                                 ! misc variables
      TYPE(AA_OutputType),       INTENT(INOUT)  :: y                                 ! outputs
  -!!   integer,                   intent(in   )  :: indx                              ! index into m%BEMT_u(indx) array; 1=t and 2=t+dt (but not checked here)
      INTEGER(IntKi),            INTENT(  OUT)  :: ErrStat                           ! The error status code
      CHARACTER(*),              INTENT(  OUT)  :: ErrMsg                            ! The error message, if an error occurred
  -
  -      ! local variables
  +   ! local variables
      CHARACTER(*), PARAMETER                   :: RoutineName = 'Calc_WriteOutput'
      INTEGER(intKi)                            :: ErrStat2
      CHARACTER(ErrMsgLen)                      :: ErrMsg2
  -   
      INTEGER(IntKi)                            :: j,k,counter,i,oi
  -      ! start routine:
  +   ! start routine:
      ErrStat = ErrID_None
      ErrMsg  = ""
  -
  -!!!! FOR THE FIRST OUTPUT FILE
  -    IF  (p%NrOutFile .gt. 0) THEN 
  -  ! This loop order has to be kept even though not the most efficient unless OASPL size and loop is changed in subtoutine CalcOutput  in AeroAcousitcs.f90 
  - y%WriteOutput(1:p%NrObsLoc)=y%DirectiviOutput
  -
  -	counter=p%NrObsLoc
  -do k=1,p%NrObsLoc
  - do i=1,p%NumBlades
  -    do j=1,p%NumBlNds
  -		counter=counter+1
  -             y%WriteOutput(counter) = y%OASPL(k,j,i)                        
  -	    !  InitOut%WriteOutputHdr(i) = "Bl "//trim(num2lstr(m))//" Nd "//trim(num2lstr(k))//" Obs "//trim(num2lstr(j))
  -	    !  InitOut%WriteOutputUnt(i) = "SPL"
  -        enddo
  -    enddo	
  -   enddo
  -    ENDIF
  -!!!! FOR THE SECOND OUTPUT FILE
  -    IF  (p%NrOutFile .gt. 1) THEN 
  -	counter=0
  +   ! FOR THE FIRST OUTPUT FILE
  +   IF  (p%NrOutFile .gt. 0) THEN 
  +       ! This loop order has to be kept even though not the most efficient unless OASPL size and loop is changed in subtoutine CalcOutput  in AeroAcousitcs.f90 
  +       y%WriteOutput(1:p%NrObsLoc)=y%DirectiviOutput
  +
  +       counter=p%NrObsLoc
  +       do k=1,p%NrObsLoc
  +           do i=1,p%NumBlades
  +               do j=1,p%NumBlNds
  +                   counter=counter+1
  +                   y%WriteOutput(counter) = y%OASPL(k,j,i)                        
  +                   !  InitOut%WriteOutputHdr(i) = "Bl "//trim(num2lstr(m))//" Nd "//trim(num2lstr(k))//" Obs "//trim(num2lstr(j))
  +                   !  InitOut%WriteOutputUnt(i) = "SPL"
  +               enddo
  +           enddo	
  +       enddo
  +   endif
  +   ! FOR THE SECOND OUTPUT FILE
  +   IF  (p%NrOutFile .gt. 1) THEN 
  +       counter=0
          DO J = 1, size(p%FreqList)
  -	    DO K = 1,p%NrObsLoc
  -              	    DO I = 1,p%NumBlades
  -	     counter=counter+1
  -             y%WriteOutputforPE(counter) = y%SumSpecNoise(J,K,I)                        
  -              	      DO oi = 1,3
  -	    		counter=counter+1
  -            		y%WriteOutputforPE(counter) = y%OutLECoords(oi,J,K,I)  
  -		      ENDDO                      
  -                    END DO ! 
  -             END DO ! 
  -	ENDDO
  -    ENDIF
  -!!!! FOR THE THIRD OUTPUT FILE
  -    IF  (p%NrOutFile .gt. 2) THEN 
  -	counter=0
  +           DO K = 1,p%NrObsLoc
  +               DO I = 1,p%NumBlades
  +                   counter=counter+1
  +                   y%WriteOutputforPE(counter) = y%SumSpecNoise(J,K,I)                        
  +                   DO oi = 1,3
  +                       counter=counter+1
  +                       y%WriteOutputforPE(counter) = y%OutLECoords(oi,J,K,I)  
  +                   ENDDO                      
  +               END DO ! 
  +           END DO ! 
  +       ENDDO
  +   ENDIF
  +   ! FOR THE THIRD OUTPUT FILE
  +   IF  (p%NrOutFile .gt. 2) THEN 
  +       counter=0
          do k=1,p%NrObsLoc
  -	 do i=1,p%NumBlades
  -	    do j=1,p%NumBlNds
  -		do oi=1,size(y%OASPL_Mech,1)
  -		counter=counter+1
  -                y%WriteOutputSep(counter) = y%OASPL_Mech(oi,k,j,i)                        
  -		enddo
  -       	    enddo
  -	 enddo	
  +           do i=1,p%NumBlades
  +               do j=1,p%NumBlNds
  +                   do oi=1,size(y%OASPL_Mech,1)
  +                       counter=counter+1
  +                       y%WriteOutputSep(counter) = y%OASPL_Mech(oi,k,j,i)                        
  +                   enddo
  +               enddo
  +           enddo	
          enddo
  -    ENDIF
  - !!!! FOR THE FOURTH OUTPUT FILE
  -    IF  (p%NrOutFile .gt. 3) THEN 
  -	counter=0
  +   ENDIF
  +   ! FOR THE FOURTH OUTPUT FILE
  +   IF  (p%NrOutFile .gt. 3) THEN 
  +       counter=0
          DO J = 1, size(p%FreqList)
  -	    DO K = 1,p%NrObsLoc
  -		do oi=1,size(y%OASPL_Mech,1)
  -	     counter=counter+1
  -             y%WriteOutputSepFreq(counter) = y%SumSpecNoiseSep(oi,K,J)                        
  +           DO K = 1,p%NrObsLoc
  +               do oi=1,size(y%OASPL_Mech,1)
  +                   counter=counter+1
  +                   y%WriteOutputSepFreq(counter) = y%SumSpecNoiseSep(oi,K,J)                        
  +               END DO ! 
              END DO ! 
  -      END DO ! 
  -	ENDDO
  -    ENDIF            
  -   
  -   
  +       ENDDO
  +   ENDIF            
   END SUBROUTINE Calc_WriteOutput
   !----------------------------------------------------------------------------------------------------------------------------------
  -
   END MODULE AeroAcoustics_IO
  
positive.code: !      lines should be modified in the Matlab script and/or Excel worksheet as necessary. 
  ! ===================================================================================================
  ! This code was generated by Write_ChckOutLst.m at 11-Mar-2016 14:45:58.
  
  
  
       ! Indices for computing output channels:
       ! NOTES: 
  
negative.code:  
     use NWTC_Library
     use AeroAcoustics_Types
     
     implicit none
     
  