anchor.diff:    
     
     
  -CONTAINS
  -
  -LOGICAL FUNCTION SwapElementNodes(n1, n2)
  -! The local element coordinate system requires that Z1 <= Z2, and if Z1=Z2 then X1 <= X2, and if Z1=Z2, X1=X2 then Y1<Y2
  -USE NWTC_Library
  -
  -   REAL(ReKi),   INTENT(IN) :: n1(:)
  -   REAL(ReKi),   INTENT(IN) :: n2(:)
  -   
  -   SwapElementNodes = .FALSE.
  -   IF ( EqualRealNos( n1(4), n2(4) ) ) THEN       ! Z1 = Z2    
  -      IF ( EqualRealNos(n1(2), n2(2) ) ) THEN     ! X1 = X2
  -         IF   ( n1(3) > n2(3) ) THEN
  -            SwapElementNodes = .TRUE.                                   ! Y1 > Y2
  -         END IF         
  -      ELSE IF ( n1(2) > n2(2) ) THEN
  -         SwapElementNodes = .TRUE.                                      ! X1 > X2            
  -      END IF
  -   ELSE IF    ( n1(4) > n2(4) ) THEN
  -      SwapElementNodes = .TRUE.                                         ! Z1 > Z2
  -   END IF
  -
  -
  -END FUNCTION SwapElementNodes
  -
  +    CONTAINS
       
   SUBROUTINE NodeCon(Init,p, ErrStat, ErrMsg)
     
  
positive.code:          DirCos(1, 1) = 1.0
           DirCos(2, 3) = 1.0
           DirCos(3, 2) = -1.0
  
        ENDIF
     ELSE
        DirCos(1, 1) = -(z1-z2)/xz
        DirCos(1, 2) = -(x1-x2)*(y1-y2)/(xz*xyz)
        DirCos(1, 3) = (x2-x1)/xyz
  
  
negative.code: 
     TempCoeff = 1.0/12.0*g*L*L*rho*A  !RRD : I am changing this to >0 sign 6/10/13
        
     !F(4) = TempCoeff*( DirCos(1, 3)*DirCos(2, 1) - DirCos(1, 1)*DirCos(2, 3) ) !These do not work if convnetion on z2>z1, x2>x1, y2>y1 are not followed as I have discovered 7/23
     !F(5) = TempCoeff*( DirCos(1, 3)*DirCos(2, 2) - DirCos(1, 2)*DirCos(2, 3) ) 
     
     !RRD attempt at new dircos which keeps x in the X-Y plane
           F(4) = -TempCoeff * SQRT(1-DirCos(3,3)**2) * DirCos(1,1)
           F(5) = -TempCoeff * SQRT(1-DirCos(3,3)**2) * DirCos(2,1)
      !RRD ends
     F(10) = -F(4)
     F(11) = -F(5)
     !F(12) is 0 for g along z alone
  
     
  END SUBROUTINE ElemG
  
  END MODULE SD_FEM
  