anchor.diff:                 
                  
                  DO j=1,p_FAST%SizeJac_ED_SD_HD_BD(4+nb) !call BD_CalcOutput            
  -                  i = i + 1 ! i = j + p_FAST%SizeJac_ED_SD_HD_BD(2:3+nb)
  +                  i = i + 1 ! i = j + sum(p_FAST%SizeJac_ED_SD_HD_BD(2:3+nb))
                     ! perturb u_BD:
                     CALL BD_CopyInput(  u_BD(nb), u_BD_perturb, MESH_UPDATECOPY, ErrStat2, ErrMsg2 )
                        CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName  )
  
positive.code:                   ! calculate outputs with perturbed inputs:
                    CALL BD_CalcOutput( this_time, u_BD_perturb, p_BD(nb), x_BD(nb), xd_BD(nb), z_BD(nb), OtherSt_BD(nb), y_BD_perturb(nb), ErrStat2, ErrMsg2 )
                       CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName  )
                    
                    CALL U_ED_SD_HD_BD_Residual(y_ED, y_SD, y_HD, y_BD_perturb, u_perturb, Fn_U_perturb) ! get this perturbation  
                 
                    IF ( ErrStat >= AbortErrLev ) THEN
  
negative.code:    REAL(ReKi)                        , INTENT(IN   ) :: u_in(:)
     REAL(ReKi)                        , INTENT(  OUT) :: U_Resid(:)
  
     INTEGER(IntKi)                                    :: i                      ! counter for ice leg and beamdyn loops
     
     !..................
     ! Set mooring line and ice inputs (which don't have acceleration fields and aren't used elsewhere in this routine, thus we're using the actual inputs (not a copy) 
  