anchor.diff:             other%LineList(I)%PropsIdNum = J
              EXIT
              IF (J == p%NTypes) THEN   ! call an error if there is no match
  -             ErrMsg = 'Unable to find matching line type name for Line '//trim(Num2LStr(I))
  -             ErrStat = ErrID_Severe
  +               CALL SetErrStat( ErrID_Severe, 'Unable to find matching line type name for Line '//trim(Num2LStr(I)), ErrStat, ErrMsg, RoutineName )
              END IF
            END IF
          END DO
   
  -       IF ( ErrStat /= ErrID_None ) THEN
  -          ErrMsg  = ' Failed to read line data for Line '//trim(Num2LStr(I))  ! would be nice to specify which line
  -          CALL CleanUp()
  -          RETURN
  -       END IF
   
          IF ( InitInp%Echo ) THEN
             WRITE( UnEc, '(A)' ) TRIM(Line)
  
positive.code:     FileName = TRIM(InitInp%FileName)
  
      CALL GetNewUnit( UnIn )
      CALL OpenFInpFile( UnIn, FileName, ErrStat )
  
      IF ( ErrStat /= ErrID_None ) THEN
         CALL SetErrStat(ErrID_Fatal, ' Failed to open MoorDyn input file: '//FileName, ErrStat,ErrMsg,'MDIO_ReadInput')
         CALL CleanUp()
         RETURN
      END IF
  
  
      !CALL WrScr( '  MD_Init: Opening MoorDyn input file:  '//FileName )
  
  
      !-------------------------------------------------------------------------------------------------
      ! File header
      !-------------------------------------------------------------------------------------------------
  
      CALL ReadCom( UnIn, FileName, 'MoorDyn input file header line 1', ErrStat )
  
      IF ( ErrStat /= ErrID_None ) THEN
  !       ErrMsg  = ' Failed to read MoorDyn input file header line 1.'
         CALL SetErrStat(ErrID_Fatal, 'Failed to read MoorDyn input file header line 1.',ErrStat,ErrMsg,'MDIO_ReadInput')
         CALL CleanUp()
         RETURN
      END IF
  
  
      CALL ReadCom( UnIn, FileName, 'MoorDyn input file header line 2', ErrStat )
  
      IF ( ErrStat /= ErrID_None ) THEN
         ErrMsg  = ' Failed to read MoorDyn input file header line 2.'
         CALL CleanUp()
         RETURN
      END IF
  
  
      ! Echo Input Files.
      CALL ReadVar ( UnIn, FileName, InitInp%Echo, 'Echo', 'Echo Input', ErrStat )
      IF ( ErrStat /= ErrID_None ) THEN
         ErrMsg  = ' Failed to read Echo parameter.'
         CALL CleanUp()
         RETURN
      END IF
  
  
      ! If we are Echoing the input then we should re-read the first three lines so that we can echo them
      ! using the NWTC_Library routines.  The echoing is done inside those routines via a global variable
      ! which we must store, set, and then replace on error or completion.
  
        IF ( InitInp%Echo ) THEN
  
           !print *, 'gonna try to open echo file'
  
           EchoFile = TRIM(p%RootName)//'.ech'                      ! open an echo file for writing
  
           !print *, 'name is ', EchoFile
  
           CALL GetNewUnit( UnEc )
           CALL OpenEcho ( UnEc, EchoFile, ErrStat, ErrMsg )
           IF ( ErrStat /= ErrID_None ) THEN
     !           ErrMsg  = ' Failed to open Echo file.'
              !print *, 'got an error in opening it'
              CALL SetErrStat(ErrID_Fatal, ' Failed to open Echo file', ErrStat,ErrMsg,'MDIO_ReadInput')
              CALL CleanUp()
              RETURN
           END IF
  
           REWIND(UnIn)      ! rewind to start of input file to re-read the first few lines
  
  
  
  
         CALL ReadCom( UnIn, FileName, 'MoorDyn input file header line 1', ErrStat, ErrMsg, UnEc )
  
         IF ( ErrStat /= ErrID_None ) THEN
            ErrMsg  = ' Failed to read MoorDyn input file header line 1.'
            CALL CleanUp()
            RETURN
         END IF
  
  
         CALL ReadCom( UnIn, FileName, 'MoorDyn input file header line 2', ErrStat, ErrMsg, UnEc )
  
         IF ( ErrStat /= ErrID_None ) THEN
            ErrMsg  = ' Failed to read MoorDyn input file header line 2.'
            CALL CleanUp()
            RETURN
         END IF
  
  
         ! Echo Input Files. Note this line is prevented from being echoed by the ReadVar routine.
         CALL ReadVar ( UnIn, FileName, InitInp%Echo, 'Echo', 'Echo the input file data', ErrStat, ErrMsg, UnEc )
         !WRITE (UnEc,Frmt      ) InitInp%Echo, 'Echo', 'Echo input file'
         IF ( ErrStat /= ErrID_None ) THEN
            ErrMsg  = ' Failed to read Echo parameter.'
            CALL CleanUp()
            RETURN
         END IF
  
        !print *, 'at end of echo if statement'
  
      END IF
  
     !print *, 'past echo bit'
  
  
      !-------------------------------------------------------------------------------------------------
      !  Line Types Properties Section
      !-------------------------------------------------------------------------------------------------
  
      CALL ReadCom( UnIn, FileName, 'Line types header', ErrStat, ErrMsg, UnEc )
  
      IF ( ErrStat /= ErrID_None ) THEN
         ErrMsg  = ' Failed to read line types header line.'
         CALL CleanUp()
         RETURN
      END IF
  
  
      CALL ReadVar ( UnIn, FileName, p%NTypes, 'NTypes', 'Number of line types', ErrStat, ErrMsg, UnEc )
  
      IF ( ErrStat /= ErrID_None ) THEN
         ErrMsg  = ' Failed to read NTypes parameter.'
         CALL CleanUp()
         RETURN
      END IF
  
  
      ! Table header
      DO I = 1, 2
         CALL ReadCom( UnIn, FileName, 'Line types table header', ErrStat, ErrMsg, UnEc )
  
         IF ( ErrStat /= ErrID_None ) THEN
            ErrMsg  = ' Failed to read Line types table header line.'
            CALL CleanUp()
            RETURN
         END IF
      END DO
  
      ! make sure NTypes isn't zero
      IF ( p%NTypes < 1 ) THEN
         ErrMsg  = ' NTypes parameter must be greater than zero.'
         CALL CleanUp()
         RETURN
      END IF
  
      ! Allocate memory for LineTypeList array to hold line type properties
      ALLOCATE ( other%LineTypeList(p%NTypes), STAT = ErrStat )
      IF ( ErrStat /= ErrID_None ) THEN
         ErrMsg  = ' Error allocating space for LineTypeList array.'
         CALL CleanUp()
         RETURN
      END IF
  
      ! read each line
      DO I = 1,p%NTypes
            ! read the table entries   Name      Diam    MassDenInAir    EA        cIntDamp     Can     Cat    Cdn     Cdt     in the MoorDyn input file
         READ(UnIn,'(A)',IOSTAT=ErrStat) Line      !read into a line
  
         IF (ErrStat == 0) THEN
            READ(Line,*,IOSTAT=ErrStat) other%LineTypeList(I)%name, other%LineTypeList(I)%d,  &
               other%LineTypeList(I)%w, other%LineTypeList(I)%EA, other%LineTypeList(I)%BA, &
               other%LineTypeList(I)%Can, other%LineTypeList(I)%Cat, other%LineTypeList(I)%Cdn, other%LineTypeList(I)%Cdt
         END IF
  
negative.code:     CHARACTER(20)                :: OptValue             ! String to temporarially hold value of options variable input
      CHARACTER(1024)              :: FileName             !
  
      INTEGER(IntKi)               :: ErrStat2
      CHARACTER(ErrMsgLen)         :: ErrMsg2
      CHARACTER(*), PARAMETER      :: RoutineName = 'MDIO_ReadInput'
      
      
      !
      UnEc = -1
  
  