anchor.diff:          Real(ReKi), DIMENSION (12,12), INTENT(IN)  :: Me,Ke    !element M and K matrices (12x12) in GLOBAL REFERENCE (DIRCOS^T K DIRCOS)
           Real(ReKi), DIMENSION (12),    INTENT(IN)  :: Udotdot, Y2, Fg     !acceleration and velocities, gravity forces
           Integer(IntKi),                INTENT(IN)  :: K2   !1 or 2 depending on node of interest
  -        REAL(ReKi), DIMENSION (6),    INTENT(OUT)  :: FM_elm, FK_elm  !output static and dynamic forces and moments
  -        
  -       !Locals
  -        INTEGER(IntKi)  ::L !counter
  -        REAL(DbKi), DIMENSION(12)                    ::Junk,Junk1,Junk3,Junk4      ! temporary storage for output stuff
  +        REAL(ReKi), DIMENSION (6),    INTENT(OUT)  :: FM_nod, FK_nod  !output static and dynamic forces and moments
  +        !Locals
  +        INTEGER(IntKi) :: L !counter
  +        REAL(DbKi), DIMENSION(12)                    :: FM_glb, FF_glb, FM_elm, FF_elm  ! temporary storage 
              
  -        Junk=matmul(Me,Udotdot)     !GLOBAL REFERENCE
  -        Junk1=matmul(Ke,Y2) !GLOBAL REFERENCE 
  -        Junk1=Junk1- Fg     !GLOBAL REFERENCE  
  -        DO L=1,4  
  -            Junk3((L-1)*3+1:L*3)=  matmul(DIRCOS, Junk(  (L-1)*3+1:L*3 ) )
  -            Junk4((L-1)*3+1:L*3) = matmul(DIRCOS, Junk1( (L-1)*3+1:L*3 ) ) 
  +        FM_glb = matmul(Me,Udotdot)   ! GLOBAL REFERENCE
  +        FF_glb = matmul(Ke,Y2)        ! GLOBAL REFERENCE
  +        FF_glb = FF_glb - Fg          ! GLOBAL REFERENCE
  +        DO L=1,4 ! Transforming coordinates 3 at a time
  +            FM_elm((L-1)*3+1:L*3) =  matmul(DIRCOS, FM_glb( (L-1)*3+1:L*3 ) )
  +            FF_elm((L-1)*3+1:L*3) =  matmul(DIRCOS, FF_glb( (L-1)*3+1:L*3 ) ) 
           ENDDO
  -        
  -        
  -        FM_elm=Junk3(6*(k2-1)+1:k2*6) 
  -        FK_elm=Junk4(6*(k2-1)+1:k2*6) 
  -        
  -   
  -   END SUBROUTINE CALC_LOCAL 
  -
  -   !====================================================================================================
  +        FM_nod=FM_elm(6*(k2-1)+1:k2*6) ! k2=1, 1:6,  k2=2  7:12 
  +        FK_nod=FF_elm(6*(k2-1)+1:k2*6) 
  +   
  +   END SUBROUTINE CALC_NODE_FORCES 
  +
  +!====================================================================================================
   SUBROUTINE SDOut_CloseSum( UnSum, ErrStat, ErrMsg )
  -
  -
  -      ! Passed variables
  -      
      INTEGER,                 INTENT( IN    )   :: UnSum                ! the unit number for the SubDyn summary file          
      INTEGER,                 INTENT(   OUT )   :: ErrStat              ! returns a non-zero value when an error occurs  
      CHARACTER(*),            INTENT(   OUT )   :: ErrMsg               ! Error message if ErrStat /= ErrID_None
  -  
  -
  -      ! Local variables
  +   ! Local variables
      INTEGER                                     :: Stat                 ! status from I/) operation 
  -
  -      ! Initialize ErrStat
  -         
      ErrStat = ErrID_None         
      ErrMsg  = ""
  -   
  -      ! Write any closing information in the summary file
  -      
  +   ! Write any closing information in the summary file
      IF ( UnSum > 0 ) THEN
  -      
         WRITE (UnSum,'(/,A/)', IOSTAT=Stat)  'This summary file was closed on '//CurDate()//' at '//CurTime()//'.'
         IF (Stat /= 0) THEN
            ErrStat = ErrID_FATAL
            ErrMsg  = ' Problem writing to summary file.'
         END IF
  -   
         ! Close the file
  -   
         CLOSE( UnSum, IOSTAT=Stat )
         IF (Stat /= 0) THEN
            ErrStat = ErrID_FATAL
            ErrMsg  = TRIM(ErrMsg)//' Problem closing summary file.'
         END IF
  -   
         IF ( ErrStat /= ErrID_None ) ErrMsg = 'SDOut_CloseSum'//TRIM(ErrMsg)
  -      
      END IF                      
  -                      
   END SUBROUTINE SDOut_CloseSum            
   
   !====================================================================================================
   SUBROUTINE SDOut_OpenSum( UnSum, SummaryName, SD_Prog, ErrStat, ErrMsg )
  -
  -
  -      ! Passed variables
  -      
      INTEGER,                 INTENT(   OUT )   :: UnSum                ! the unit number for the SubDyn summary file          
      CHARACTER(*),            INTENT( IN    )   :: SummaryName          ! the name of the SubDyn summary file
      TYPE(ProgDesc),          INTENT( IN    )   :: SD_Prog              ! the name/version/date of the  program
      INTEGER,                 INTENT(   OUT )   :: ErrStat              ! returns a non-zero value when an error occurs  
      CHARACTER(*),            INTENT(   OUT )   :: ErrMsg               ! Error message if ErrStat /= ErrID_None
  -           
      integer                                    :: ErrStat2
  -       ! Initialize ErrStat
  -         
      ErrStat = ErrID_None         
      ErrMsg  = ""       
  -      
   
      CALL GetNewUnit( UnSum )
      CALL OpenFOutFile ( UnSum, SummaryName, ErrStat, ErrMsg ) 
  
positive.code: ! name, and units of the output channels). 
  ! NOTE OutParam is populated here
  !----------------------------------------------------------------------------------------------------    
     
     
     
        ! Passed variables
        
     TYPE(SD_ParameterType),   INTENT( INOUT ) :: p                    ! SubDyn module parameter data
     CHARACTER(ChanLen),       INTENT( IN    ) :: OutList (:)          ! An array holding the names of the requested output channels.         
     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                                   :: I,J,K                                         ! Generic loop-counting index.
     INTEGER                                   :: INDX                                      ! Index for valid arrays
     
     CHARACTER(ChanLen)                        :: OutListTmp                                ! A string to temporarily hold OutList(I).
     !CHARACTER(28), PARAMETER               :: OutPFmt    = "( I4, 3X,A 10,1 X, A10 )"   ! Output format parameter output list.
     CHARACTER(ChanLen), DIMENSION(24)         :: ToTUnits,ToTNames,ToTNames0
     
     LOGICAL                  :: InvalidOutput(0:MaxOutPts)                        ! This array determines if the output channel is valid for this configuration
  
     LOGICAL                  :: CheckOutListAgain
     
     InvalidOutput            = .FALSE.
  
  !End of code generated by Matlab script
     
        ! mark invalid output channels:
     
     DO k=p%Nmodes+1,99
        InvalidOutput(SSqm01  +k-1) = .true.
        InvalidOutput(SSqmd01 +k-1) = .true.
  
negative.code: END SUBROUTINE SDOut_Init
  
  !------------------------------------------------------------------------------------------------------
  !>This subroutine allocates and calculated TIreact, Matrix to go from local reactions at constrained nodes to single point reactions
  SUBROUTINE ReactMatx(Init, p, WtrDpth, ErrStat, ErrMsg)
     TYPE(SD_InitType),      INTENT(  IN)  :: Init         ! Input data for initialization routine
     TYPE(SD_ParameterType), INTENT(  INOUT)  :: p         ! Parameter data
     REAL(ReKi),                   INTENT(IN)     :: WtrDpth
     INTEGER(IntKi),               INTENT(  OUT)  :: ErrStat     ! Error status of the operation
     CHARACTER(*),                 INTENT(  OUT)  :: ErrMsg      ! Error message if ErrStat /= ErrID_None
     ! local variables
     INTEGER                             :: I !counter
     INTEGER                             :: rmndr !type-column index
     INTEGER                             ::  n  !node ID
     INTEGER(IntKi)                      :: DOFC !  DOFC = Init%NReact*6
     REAL(ReKi)                          :: x, y, z !coordinates
     ErrStat=ErrID_None
     ErrMsg=""
     
     DOFC = p%NReact*6 ! bjj, this is p%DOFC    !Total DOFs at the base of structure 
     
     CALL AllocAry(p%TIreact, 6,DOFC, 'p%TIReact', ErrStat, ErrMsg )
     if ( ErrStat /= ErrID_None ) return
     
     p%TIreact=0 !Initialize
     
     DO I=1,3  !Take care of first three rows
        p%TIreact(I,I:DOFC:6)=1
     ENDDO 
  
      !Other rows done per column actually  
     DO I = 1, DOFC
        
        n = p%Reacts(ceiling(I/6.0),1)  !Constrained Node ID (this works in the reordered/renumbered p%Reacts) ! TODO different DOF ordering
        
        x = Init%Nodes(n, 2)
        y = Init%Nodes(n, 3)
  