anchor.diff:              CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
         END IF
   
  +      if (ErrStat >= AbortErrLev) then
  +         call cleanup()
  +         return
  +      end if
  +      
      !---------------------- GEOMETRY PARAMETER --------------------------------------
      CALL ReadCom(UnIn,InputFile,'Section Header: Geometry Parameter',ErrStat2,ErrMsg2,UnEc)
         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +      
      CALL ReadVar(UnIn,InputFile,InputFileData%member_total,"member_total", "Total number of member",ErrStat2,ErrMsg2,UnEc)
         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +      
      CALL ReadVar(UnIn,InputFile,InputFileData%kp_total,"kp_total", "Total number of key point",ErrStat2,ErrMsg2,UnEc)
         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -   CALL AllocAry(InputFileData%kp_member,InputFileData%member_total,'Number of key point in each member',ErrStat2,ErrMsg2)
  -      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -   CALL AllocAry(InputFileData%kp_coordinate,InputFileData%kp_total,4,'Key point coordinates input array',ErrStat2,ErrMsg2)
  -      CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  -      if (ErrStat >= AbortErrLev) return
  +      
  +      CALL AllocAry(InputFileData%kp_member,InputFileData%member_total,'Number of key point in each member',ErrStat2,ErrMsg2)
  +         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +      
  +      CALL AllocAry(InputFileData%kp_coordinate,InputFileData%kp_total,4,'Key point coordinates input array',ErrStat2,ErrMsg2)
  +         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +         if (ErrStat >= AbortErrLev) then
  +            call cleanup()
  +            return
  +         end if
  +         
      InputFileData%kp_member(:) = 0
      InputFileData%kp_coordinate(:,:) = 0.0D0
      temp_int = 0
      DO i=1,InputFileData%member_total
  -       READ(UnIn,*) j,InputFileData%kp_member(j) !bjj: fix me!
  -   ENDDO
  +      ! bjj: we cannot read j, InputFileData%kp_member(j) because j could be outside the valid range:
  +      READ(UnIn,*,IOSTAT=IOS) j,temp_int 
  +         CALL CheckIOS ( IOS, InputFile, 'Member number; Number of key points in this member', NumType, ErrStat2, ErrMsg2 )
  +         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +         if (ErrStat >= AbortErrLev) then
  +            call cleanup()
  +            return
  +         end if
  +         
  +         if (j>0 .and. j<= InputFileData%member_total) then
  +            InputFileData%kp_member(j) = temp_int
  +         end if
  +         
  +         !bjj: what happens if the user enters a member number multiple times? or if not each member is accounted for?
  +         !    I'm going to force them to be entered 1-InputFileData%kp_member to avoid this issue for now.
  +         if (j /= i) then
  +            call SetErrStat(ErrID_Warn, "Member numbers must be entered in monotonic increasing order, starting with 1.",ErrStat,ErrMsg,RoutineName)
  +         end if
  +         
  +   ENDDO
  +   
  +   
      CALL ReadCom(UnIn,InputFile,'key point x,y,z locations and initial twist angles',ErrStat2,ErrMsg2,UnEc)
         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +      
      CALL ReadCom(UnIn,InputFile,'key point and initial twist units',ErrStat2,ErrMsg2,UnEc)
         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +      
      DO i=1,InputFileData%kp_total
  -       READ(UnIn,*) InputFileData%kp_coordinate(i,2),InputFileData%kp_coordinate(i,3),&
  -                    InputFileData%kp_coordinate(i,1),InputFileData%kp_coordinate(i,4)
  -       IF(UnEc>0) THEN
  -           IF(i==1) WRITE(UnEc,'(/,A,/)') 'Key points coordinates and initial twist angle'
  -           WRITE(UnEc,'(/,A,/)') InputFileData%kp_coordinate(i,2),InputFileData%kp_coordinate(i,3),&
  -                                 InputFileData%kp_coordinate(i,1),InputFileData%kp_coordinate(i,4)
  -       ENDIF
  -   ENDDO
  -   InputFileData%kp_coordinate(:,4) = -InputFileData%kp_coordinate(:,4)
  +       CALL ReadAry( UnIn, InputFile, TmpReAry, 4, 'kp_coordinate', 'Key point coordinates and initial twist', ErrStat2, ErrMsg2, UnEc )       
  +          CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  +       InputFileData%kp_coordinate(i,2) =  TmpReAry(1)
  +       InputFileData%kp_coordinate(i,3) =  TmpReAry(2)
  +       InputFileData%kp_coordinate(i,1) =  TmpReAry(3)
  +       InputFileData%kp_coordinate(i,4) = -TmpReAry(4)
  +   ENDDO
  +   
      !---------------------- MESH PARAMETER -----------------------------------------
      CALL ReadCom(UnIn,InputFile,'Section Header: Mesh Parameter',ErrStat2,ErrMsg2,UnEc)
         CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
  
positive.code:                                   ,INode   = temp_id      &
                                    ,Pos     = TmpPos       &
                                    ,ErrStat = ErrStat2      &
                                    ,ErrMess = ErrMsg2       )
              CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
         ENDDO
     ENDDO
  
negative.code: 
     END SUBROUTINE BD_StaticElementMatrixForce
  
  SUBROUTINE BD_GA2(t,n,u,utimes,p,x,xd,z,OtherState,ErrStat,ErrMsg)
  
     REAL(DbKi),                        INTENT(IN   )  :: t           ! Current simulation time in seconds
     INTEGER(IntKi),                    INTENT(IN   )  :: n           ! time step number
  