anchor.diff:                                                         
      INTEGER(IntKi)                         :: ErrStat2                                                                    
      CHARACTER(LEN(ErrMsg))                 :: ErrMsg2
  +   CHARACTER(*), PARAMETER                :: RoutineName = 'CBMatrix'
                                                          
      ErrStat = ErrID_None 
      ErrMsg  = ''
  
positive.code:       IF (p%IntMethod .EQ. 4) THEN       ! Allocate Jacobian if AM2 is requested & if there are states (p%qmL > 0)
           n=2*p%qmL
           CALL AllocAry( p%AM2Jac, n, n, 'p%AM2InvJac', ErrStat2, ErrMsg2 ) ! This will be the Jacobian
              CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,'SetParameters')
           CALL AllocAry( p%AM2JacPiv, n, 'p%AM2JacPiv', ErrStat2, ErrMsg2 )                         
              CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,'SetParameters')         
              IF ( ErrStat >= AbortErrLev ) RETURN 
           
                 ! First we calculate the Jacobian:
  
negative.code:                ! Now need to factor it:        
           !I think it could be improved and made more efficient if we can say the matrix is positive definite
           CALL LAPACK_getrf( n, n, p%AM2Jac, p%AM2JacPiv, ErrStat2, ErrMsg2)
              CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
              IF ( ErrStat >= AbortErrLev ) RETURN
                  
        END IF     
  