diff --git a/mex/sources/riccati_update/mexFunction.f08 b/mex/sources/riccati_update/mexFunction.f08
index 68d66e9c69151ef054819bf4f1843a26886b103a..7443a604c7320117c6d3bd497858ba6e42034394 100644
--- a/mex/sources/riccati_update/mexFunction.f08
+++ b/mex/sources/riccati_update/mexFunction.f08
@@ -36,7 +36,7 @@ subroutine mexFunction(nlhs, plhs, nrhs, prhs) bind(c, name='mexFunction')
 
    real(real64), dimension(:,:), pointer, contiguous :: P, T, K, Z, Q, Pnew
    real(real64), dimension(:,:), allocatable :: tmp1, tmp2
-   integer :: i, j, n, r
+   integer :: i, n, r
    character(kind=c_char, len=2) :: num2str 
 
    ! 0. Checking the consistency and validity of input arguments