anchor.diff:         p%OutParam(p%NumOuts+1:p%NumOuts+p%OutAllDims)%Indx= MaxOutPts+(/(J, J=1, p%OutAllDims)/) 
      ENDIF
   
  -   RETURN
   END SUBROUTINE SDOut_ChkOutLst
  -
  -
   !====================================================================================================
   
   
  
positive.code:        
            !Find the joint forces
               DO J=1,SIZE(p%MOutLst3(I)%ElmIDs(1,:))  !for all the elements connected (normally 1)
                  
                  K=p%MOutLst3(I)%ElmIDs(1,J)  !element number
                  K2=p%MOutLst3(I)%ElmNds(1,J)  !first or second node of the element to be considered
                  
                  !Assign the sign depending on whether it is the 1st or second node                
                  K3=p%Elems(K,2:3)  !first and second node ID associated with element K 
                  
                  L =p%IDY((K3(1)-1)*6+1)! starting index for node K3(1) within yout
                  L2=p%IDY((K3(2)-1)*6+1)! starting index for node K3(2) within yout
                  
                  DIRCOS=tranSpose(p%elemprops(K)%DirCos)! global to local
                  
                  CALL CALC_LOCAL( DIRCOS,p%MOutLst3(I)%Me(:,:,1,J),p%MOutLst3(I)%Ke(:,:,1,J),(/uddout( L : L+5  ),uddout( L2 : L2+5 )/), &
                                   (/yout( L : L+5 ),       yout( L2 : L2+5 )/),  p%MoutLst3(I)%Fg(:,1,J),   K2,FM_elm,FK_elm) 
                  
                  !transform back to global, need to do 3 at a time since cosine matrix is 3x3
                  DO L=1,2  
                     FM_elm2((L-1)*3+1:L*3) = FM_elm2((L-1)*3+1:L*3) + matmul(p%elemprops(K)%DirCos,FM_elm((L-1)*3+1:L*3))  !sum forces at joint in GLOBAL REF
                     FK_elm2((L-1)*3+1:L*3) = FK_elm2((L-1)*3+1:L*3) + matmul(p%elemprops(K)%DirCos,FK_elm((L-1)*3+1:L*3))  !signs may be wrong, we will fix that later;  
                  ! I believe this is all fixed in terms of signs now ,RRD 5/20/13
                  ENDDO           
                  
               ENDDO
               !junk= FK_elm2 ! + FM_elm2  !removed the inertial component 12/13 !Not sure why I need an intermediate step here, but the sum would not work otherwise
               
               !NEED TO ADD HYDRODYNAMIC FORCES AT THE RESTRAINT NODES
               !   The joind iD of the reaction, i.e. thre reaction node ID is within p%MOutLst3(I)%Noutcnt
               !The index in Y2mesh is? 
               !Since constrained nodes are ordered as given in the input file and so as in the order of y2mesh, i Can do:
               junk =  (/u%LMesh%Force(:,p%NNodes_I+p%NNodes_L+I),u%LMesh%Moment(:,p%NNodes_I+p%NNodes_L+I)/)
                  
               ReactNs((I-1)*6+1:6*I)=FK_elm2 - junk  !Accumulate reactions from all nodes in GLOBAL COORDINATES
         ENDDO
         
            !NOW HERE I WOULD NEED TO PUT IT INTO AllOuts
                  
        AllOuts( ReactSS(1:TPdofL) ) = matmul(p%TIreact,ReactNs)
    ENDIF
  
     if (allocated(ReactNs)) deallocate(ReactNs)
     
  END SUBROUTINE SDOut_MapOutputs
  
  !====================================================================================================
     SUBROUTINE CALC_LOCAL(DIRCOS,Me,Ke,Udotdot,Y2,Fg, K2,FM_elm,FK_elm)
     !This function calculates for the given element the static and dynamic forces, given K and M of the element, and 
     !output quantities Udotdot and Y2 containing the 
     !and K2 indicating wheter the 1st (1) or 2nd (2) node is to be picked
  
negative.code:               L=p%IDY( (p%MOutLst(I)%NodeIDs(J)-1)*6 +1 )! starting index for nodeID(J) within yout
                AllOuts(MNTDss (:,J,I))      = yout(L:L+2)
                !Displacement- Rotational - I need to get the direction cosine matrix to tranform rotations  - In Local reference Element Ref Sys
                AllOuts(MNRDe (:,J,I))        = matmul(DIRCOS,yout(L+3:L+5)  ) !local ref
                !Accelerations- I need to get the direction cosine matrix to tranform displacement and rotations
                AllOuts(MNTRAe (1:3,J,I))     = matmul(DIRCOS,uddout(L:L+2)  )   !translational accel local ref
                AllOuts(MNTRAe (4:6,J,I))     = matmul(DIRCOS,uddout(L+3:L+5) )  !rotational accel  local ref
                
          ENDDO  ! J, Loop on requested nodes for that member
          
       ENDDO ! I, Loop on member outputs
     END IF
    
    IF (p%OutAll) THEN  !NEED TO CALCULATE TOTAL FORCES
           DO I=1,p%NMembers    !Cycle on all members
                DO J=1,2 !Iterate on requested nodes for that member (first and last)  
                  K=p%MOutLst2(I)%ElmID2s(J)  !element number
                  K2=p%MOutLst2(I)%ElmNd2s(J)  !first or second node of the element to be considered
                  !Assign the sign depending on whether it is the 1st or second node
                  sgn=-1
                  IF (K2 .EQ. 2) sgn= +1
                  K3=p%Elems(K,2:3)  !first and second node ID associated with element K 
                  L =p%IDY((K3(1)-1)*6+1)! starting index for node K3(1) within yout ! TODO different DOF order
                  L2=p%IDY((K3(2)-1)*6+1)! starting index for node K3(2) within yout
                  DIRCOS=transpose(p%elemprops(K)%DirCos)! global to local
                  CALL CALC_NODE_FORCES( DIRCOS,p%MOutLst2(I)%Me2(:,:,J),p%MOutLst2(I)%Ke2(:,:,J),(/uddout( L : L+5  ),uddout( L2 : L2+5 )/), &
                                   (/yout( L : L+5 ),       yout( L2 : L2+5 )/), p%MoutLst2(I)%Fg2(:,J),  K2,FM_elm,FK_elm) 
                   ! Store in All Outs
                   L=MaxOutPts+(I-1)*24+(J-1)*12+1!start index
                   L2=L+11
                   AllOuts( L:L2 ) =sgn* (/FK_elm,FM_elm/)
                ENDDO !J, nodes 1 and 2
           ENDDO ! I, Loop on members
    ENDIF
    
    !Assign interface forces and moments 
    AllOuts(IntfSS(1:TPdofL))= - (/y%Y1Mesh%Force (:,1), y%Y1Mesh%Moment(:,1)/) !-y%Y1  !Note this is the force that the TP applies to the Jacket, opposite to what the GLue Code needs thus "-" sign
    !Assign interface translations and rotations at the TP ref point  
    AllOuts(IntfTRss(1:TPdofL))=m%u_TP 
    !Assign interface translations and rotations accelerations
    AllOuts(IntfTRAss(1:TPdofL))= m%udotdot_TP 
  
    ! Assign all SSqm, SSqmdot, SSqmdotdot
    ! We only have space for the first 99 values
    maxOutModes = min(p%Nmodes,99)
    IF ( maxOutModes > 0 ) THEN 
       !BJJ: TODO: is there a check to see if we requested these channels but didn't request the modes? (i.e., retain 2 modes but asked for 75th mode?)
       Allouts(SSqm01  :SSqm01  +maxOutModes-1) = x%qm      (1:maxOutModes)
       Allouts(SSqmd01 :SSqmd01 +maxOutModes-1) = x%qmdot   (1:maxOutModes)
       Allouts(SSqmdd01:SSqmdd01+maxOutModes-1) = m%qmdotdot(1:maxOutModes)
    END IF
     
    !Need to Calculate Reaction Forces Now, but only if requested
    IF (p%OutReact) THEN 
  