anchor.diff:  !> This subroutine initializes the output module, checking if the output parameter list (OutList)
   ! contains valid names, and opening the output file if there are any requested outputs
   SUBROUTINE SDOut_Init( Init, y,  p, misc, InitOut, WtrDpth, ErrStat, ErrMsg )
  - TYPE(SD_InitType),        INTENT( INOUT ) :: Init                 ! data needed to initialize the output module     
  - TYPE(SD_OutputType),      INTENT( INOUT ) :: y                    ! SubDyn module's output data
  - TYPE(SD_ParameterType),   INTENT( INOUT ), target :: p                    ! SubDyn module paramters
  - TYPE(SD_MiscVarType),     INTENT( INOUT ) :: misc                 ! SubDyn misc/optimization variables
  - TYPE(SD_InitOutputType ), INTENT( INOUT ) :: InitOut              ! SubDyn module initialization output data
  - REAL(ReKi),               INTENT( IN    ) :: WtrDpth              ! water depth from initialization routine  
  - INTEGER,                       INTENT(   OUT ) :: ErrStat              ! a non-zero value indicates an error occurred           
  - CHARACTER(*),                  INTENT(   OUT ) :: ErrMsg               ! Error message if ErrStat /= ErrID_None
  -! Local variables
  - INTEGER(IntKi)       :: ErrStat2      ! Error status of the operation
  - CHARACTER(ErrMsgLen) :: ErrMsg2       ! Error message if ErrStat /= ErrID_None
  - INTEGER(IntKi)                                   :: I,J,K,K2,L,NconEls   !Counters
  - INTEGER(IntKi)                                   :: Junk  !Temporary Holders
  - INTEGER(IntKi), Dimension(2)                     :: M   !counter for two nodes at a time
  - INTEGER(IntKi)                                   :: eType
  - TYPE(ElemPropType), pointer :: eP  !< Element Property, Alias to shorten notations
  - REAL(ReKi) :: FCe(12) ! Pretension force from cable element
  -!-------------------------------------------------------------------------------------------------      
  -! Initialize local variables
  -!-------------------------------------------------------------------------------------------------      
  -ErrStat = 0      
  -ErrMsg=""
  -
  -p%OutAllDims=12*p%Nmembers*2    !size of AllOut Member Joint forces
  -
  -!-------------------------------------------------------------------------------------------------      
  -! Check that the variables in OutList are valid      
  -!-------------------------------------------------------------------------------------------------      
  -
  -!   SDOut_Data%NumOuts = HDO_InitData%NumOuts   
  -  CALL SDOut_ChkOutLst( Init%SSOutList, p,  ErrStat, ErrMsg )
  -  IF ( ErrStat /= 0 ) RETURN
  -
  -!-------------------------------------------------------------------------------------------------      
  -! INITIALIZE FAST-TYPE OUTPUT  (y)
  -!-------------------------------------------------------------------------------------------------      
  -  !ALLOCATE( y%Y1(TPdofL), STAT = ErrStat )
  -  !IF ( ErrStat/= 0 ) THEN
  -  !    ErrStat = ErrID_Fatal
  -  !    ErrMsg  = 'Error allocating output Y1 array in SDOut_Init'
  -  !    RETURN
  -  !END IF
  -
  -!-------------------------------------------------------------------------------------------------      
  -! Open the output file, if necessary, and write the header
  -!-------------------------------------------------------------------------------------------------      
  -
  -  IF ( ALLOCATED( p%OutParam ) .AND. p%NumOuts > 0 ) THEN           ! Output has been requested           
  -
  -    
  +   TYPE(SD_InitType),        INTENT( INOUT ) :: Init                 ! data needed to initialize the output module     
  +   TYPE(SD_OutputType),      INTENT( INOUT ) :: y                    ! SubDyn module's output data
  +   TYPE(SD_ParameterType),   INTENT( INOUT ), target :: p                    ! SubDyn module paramters
  +   TYPE(SD_MiscVarType),     INTENT( INOUT ) :: misc                 ! SubDyn misc/optimization variables
  +   TYPE(SD_InitOutputType ), INTENT( INOUT ) :: InitOut              ! SubDyn module initialization output data
  +   REAL(ReKi),               INTENT( IN    ) :: WtrDpth              ! water depth from initialization routine  
  +   INTEGER,                       INTENT(   OUT ) :: ErrStat              ! a non-zero value indicates an error occurred           
  +   CHARACTER(*),                  INTENT(   OUT ) :: ErrMsg               ! Error message if ErrStat /= ErrID_None
  +   ! Local variables
  +   INTEGER(IntKi)       :: ErrStat2      ! Error status of the operation
  +   CHARACTER(ErrMsgLen) :: ErrMsg2       ! Error message if ErrStat /= ErrID_None
  +   INTEGER(IntKi)                                   :: I,J,K,K2,L,NconEls   !Counters
  +   INTEGER(IntKi)                                   :: Junk  !Temporary Holders
  +   INTEGER(IntKi), Dimension(2)                     :: M   !counter for two nodes at a time
  +   INTEGER(IntKi)                                   :: eType
  +   TYPE(ElemPropType), pointer :: eP  !< Element Property, Alias to shorten notations
  +   REAL(ReKi) :: FCe(12) ! Pretension force from cable element
  +   ErrStat = 0      
  +   ErrMsg=""
  +
  +   p%OutAllDims=12*p%Nmembers*2    !size of AllOut Member Joint forces
  +
  +   ! Check that the variables in OutList are valid      
  +   CALL SDOut_ChkOutLst( Init%SSOutList, p,  ErrStat2, ErrMsg2 ); if(Failed()) return
  +
  +   IF ( ALLOCATED( p%OutParam ) .AND. p%NumOuts > 0 ) THEN           ! Output has been requested           
      ! Allocate SDWrOuput which is used to store a time step's worth of output channels, prior to writing to a file.
  -   ALLOCATE( misc%SDWrOutput( p%NumOuts +p%OutAllInt*p%OutAllDims),  STAT = ErrStat )
  -   IF ( ErrStat /= ErrID_None ) THEN
  -    ErrMsg  = ' Error allocating space for SDWrOutput array.'
  -    ErrStat = ErrID_Fatal
  -    RETURN
  -   END IF
  +   CALL AllocAry(misc%SDWrOutput, p%NumOuts +p%OutAllInt*p%OutAllDims, 'SDWrOutupt', ErrStat2, ErrMsg2) ; if(Failed()) return
      misc%SDWrOutput  = 0.0_ReKi
      misc%LastOutTime = 0.0_DbKi
      misc%Decimat     = 0
      
      !Allocate WriteOuput  
  -   ALLOCATE( y%WriteOutput( p%NumOuts +p%OutAllInt*p%OutAllDims),  STAT = ErrStat )
  -   IF ( ErrStat /= 0 ) THEN
  -    ErrMsg  = ' Error allocating space for WriteOutput array.'
  -    ErrStat = ErrID_Fatal
  -    RETURN
  -   END IF
  +   CALL AllocAry(y%WriteOutput, p%NumOuts +p%OutAllInt*p%OutAllDims, 'WriteOutput', ErrStat2, ErrMsg2); if(Failed()) return
      y%WriteOutput = 0
   
  -   !Do some final mapping and carry out housekeeping to calculate some of the output variable
  -   
  -  
  - !Store mapping between nodes and elements      
  -  CALL NodeCon(Init,p,ErrStat, ErrMsg)
  -  IF ( ErrStat /=0) RETURN
  +  !Store mapping between nodes and elements      
  +  CALL NodeCon(Init,p,ErrStat2, ErrMsg2); if(Failed()) return
     
     DO I=1,p%NMOutputs
  -   CALL AllocAry(p%MOutLst(I)%NodeIDs, p%MoutLst(I)%NoutCnt, 'MOutLst(I)%NodeIDs', ErrStat2, ErrMsg2) ; if(Failed()) return
  +   CALL AllocAry(p%MOutLst(I)%NodeIDs,    p%MoutLst(I)%NoutCnt           , 'MOutLst(I)%NodeIDs', ErrStat2, ErrMsg2); if(Failed()) return
  +   CALL AllocAry(p%MOutLst(I)%ElmIDs,     p%MoutLst(I)%NoutCnt, p%NAvgEls, 'MOutLst(I)%ElmIDs' , ErrStat2, ErrMsg2); if(Failed()) return
  +   CALL AllocAry(p%MOutLst(I)%ElmNds,     p%MoutLst(I)%NoutCnt, p%NAvgEls, 'MOutLst(I)%ElmNds' , ErrStat2, ErrMsg2); if(Failed()) return
  +   CALL AllocAry(p%MOutLst(I)%Me, 12, 12, p%MoutLst(I)%NoutCnt, p%NAvgEls, 'MOutLst(I)%Me'     , ErrStat2, ErrMsg2); if(Failed()) return
  +   CALL AllocAry(p%MOutLst(I)%Ke, 12, 12, p%MoutLst(I)%NoutCnt, p%NAvgEls, 'MOutLst(I)%Ke'     , ErrStat2, ErrMsg2); if(Failed()) return
  +   CALL AllocAry(p%MOutLst(I)%Fg,     12, p%MoutLst(I)%NoutCnt, p%NAvgEls, 'MOutLst(I)%Fg'     , ErrStat2, ErrMsg2); if(Failed()) return
  +
      p%MOutLst(I)%NodeIDs=Init%MemberNodes(p%MoutLst(I)%MemberID,p%MOutLst(I)%NodeCnt)  !We are storing the actual node numbers corresponding to what the user ordinal number is requesting
  -
  -   ALLOCATE( p%MOutLst(I)%ElmIDs(p%MoutLst(I)%NoutCnt,p%NAvgEls), STAT = ErrStat ) !ElmIDs has for each selected node within the member, several element numbers to refer to for averaging (max 2 elements)
  -   IF ( ErrStat/= 0 ) THEN
  -      ErrStat = ErrID_Fatal
  -      ErrMsg  = 'Error allocating p%MOutLst(I)%ElmIDs arrays in SDOut_Init'
  -      RETURN
  -   END IF 
      p%MOutLst(I)%ElmIDs=0  !Initialize to 0
  -
  -   ALLOCATE( p%MOutLst(I)%ElmNds(p%MoutLst(I)%NoutCnt,p%NAvgEls), STAT = ErrStat ) !ElmNds has for each selected node within the member, for each element number to refer to for averaging, the flag 1 or 2 depending on whether it is the 1st or last node of that element
  -   IF ( ErrStat/= 0 ) THEN
  -      ErrStat = ErrID_Fatal
  -      ErrMsg  = 'Error allocating p%MOutLst(I)%ElmNds arrays in SDOut_Init'
  -      RETURN
  -   END IF 
  -
  -   ALLOCATE( p%MOutLst(I)%Me(12,12,p%MoutLst(I)%NoutCnt,p%NAvgEls), STAT = ErrStat ) !Me has for each selected node within the member, and for each element attached to that node for averaging (max 2) a 12x12 matrix
  -   IF ( ErrStat/= 0 ) THEN
  -      ErrStat = ErrID_Fatal
  -      ErrMsg  = 'Error allocating p%MOutLst(I)%Me arrays in SDOut_Init'
  -      RETURN
  -   END IF 
  -   ALLOCATE( p%MOutLst(I)%Ke(12,12,p%MoutLst(I)%NoutCnt,p%NAvgEls), STAT = ErrStat ) !Ke has for each selected node within the member, and for each element attached to that node for averaging (max 2) a 12x12 matrix
  -   IF ( ErrStat/= 0 ) THEN
  -      ErrStat = ErrID_Fatal
  -      ErrMsg  = 'Error allocating p%MOutLst(I)%Ke arrays in SDOut_Init'
  -      RETURN
  -   END IF 
  -    ALLOCATE( p%MOutLst(I)%Fg(12,p%MoutLst(I)%NoutCnt,p%NAvgEls), STAT = ErrStat ) !Fg has for each selected node within the member, and for each element attached to that node for averaging (max 2) a 12x1 vector
  -   IF ( ErrStat/= 0 ) THEN
  -      ErrStat = ErrID_Fatal
  -      ErrMsg  = 'Error allocating p%MOutLst(I)%Fg arrays in SDOut_Init'
  -      RETURN
  -   END IF 
  -
  -
  +   p%MOutLst(I)%ElmNds=0  !Initialize to 0
   
      DO J=1,p%MoutLst(I)%NoutCnt !Iterate on requested nodes for that member
         !I need to get at most 2 elements that belong to the same MoutLst(I)%MemberID
  
positive.code:       
        rmndr = MOD(I, 6)  !It gives me the column index among the 6 different kinds
        SELECT CASE (rmndr)
           CASE (1)
              p%TIreact(4:6, I) = (/0.0_ReKi, z, -y/)
              
           CASE (2)
              p%TIreact(4:6, I) = (/-z, 0.0_ReKi, x/)
              
           CASE (3)
              p%TIreact(4:6, I) = (/y, -x, 0.0_ReKi/)
           
           CASE (4)
              p%TIreact(4:6, I) = (/1.0_ReKi, 0.0_ReKi, 0.0_ReKi/)
              
           CASE (5)
              p%TIreact(4:6, I) = (/0.0_ReKi, 1.0_ReKi, 0.0_ReKi/)
              
           CASE (0)
              p%TIreact(4:6, I) = (/0.0_ReKi, 0.0_ReKi, 1.0_ReKi/)
              
           CASE DEFAULT
              ErrStat = ErrID_Fatal
              ErrMsg  = 'Error calculating transformation matrix TIreact '
              RETURN
           END SELECT
        
     ENDDO
     
     
  END SUBROUTINE ReactMatx
  
  !====================================================================================================
  
negative.code:              IF (M(1) .EQ. p%MoutLst2(I)%NodeIDs(J)) Junk=M(2)
               
               IF (ANY(Init%MemberNodes(p%MoutLst2(I)%MemberID,:) .EQ. Junk)) THEN  !This means we are in the selected member
                    p%MoutLst2(I)%ElmID2s(K2)=L     !This array has for each node requested NODEID(J), for each member I, the element to get results for 
                    p%MoutLst2(I)%ElmNd2s(K2)=1                        !store whether first or second node of element  
                    IF (M(2) .EQ. p%MoutLst2(I)%NodeIDs(J) ) p%MoutLst2(I)%ElmNd2s(K2)=2 !store whether first or second node of element  
                          
  