anchor.diff:        ErrStat = ErrID_None
         ErrMsg  = ""
   
  -      CALL IceD_CopyContState(x, x_pred, 0, ErrStat, ErrMsg)
  +      CALL IceD_CopyContState(x, x_pred, MESH_NEWCOPY, ErrStat, ErrMsg)
   
         CALL IceD_AB4( t, n, u, utimes, p, x_pred, xd, z, OtherState, ErrStat, ErrMsg )
   
         if (n .gt. 2) then
   
  +         CALL IceD_CopyInput( u(1), u_interp, MESH_NEWCOPY, ErrStat, ErrMsg) ! bjj: need to allocate space for u_interp so that IceD_Input_ExtrapInterp works
            CALL IceD_Input_ExtrapInterp(u, utimes, u_interp, t + p%dt, ErrStat, ErrMsg)
   
            CALL IceD_CalcContStateDeriv(t + p%dt, u_interp, p, x_pred, xd, z, OtherState, xdot_pred, ErrStat, ErrMsg )
  
positive.code: 
        x%q    = x%q    +  ( k1%q    + 2. * k2%q    + 2. * k3%q    + k4%q    ) / 6.
        x%dqdt = x%dqdt +  ( k1%dqdt + 2. * k2%dqdt + 2. * k3%dqdt + k4%dqdt ) / 6.
  
  END SUBROUTINE IceD_RK4
  !----------------------------------------------------------------------------------------------------------------------------------
  SUBROUTINE IceD_AB4( t, n, u, utimes, p, x, xd, z, OtherState, ErrStat, ErrMsg )
  
negative.code:          x%q    = x_pred%q
           x%dqdt = x_pred%dqdt
  
        endif
  
        CALL Cleanup()
  
  CONTAINS
  SUBROUTINE Cleanup()
     
     CALL IceD_DestroyInput( u_interp, ErrStat, ErrMsg) 
     CALL IceD_DestroyContState( x_pred , ErrStat, ErrMsg) 
     CALL IceD_DestroyContState( xdot_pred, ErrStat, ErrMsg) 
                                 
  END SUBROUTINE Cleanup
        
  END SUBROUTINE IceD_ABM4
  !----------------------------------------------------------------------------------------------------------------------------------
  !..................................................................................................................................
  