anchor.diff:    !----------------------------------------------
     ! Start iterations
     !----------------------------------------------
  +  S_steps = 0
     do while (iteration < n_iterations)
   
        !--------------------------------------------
  
positive.code:         end if
  
       else
          if (wasunstable) then
             print*, 'Switched back to implicit mode!'
             s%Mdot(n_cell) = s%Mdot(n_cell) / 4._x_precision
  
negative.code:         ! Mdot kick
          ! Increase Mdot at r_max if S is stalled
          !
          ! we give an mdot kick when the relative variation is below delta_S_max
          ! and when the mean over last 10 iterations does not evolve anymore
          !----------------------------------------------
          S_rel_diff = (prev_S - s%S) / s%S / dt_nu
          S_rel_diff_max = maxval(dabs(S_rel_diff))
  
          p = mod(S_steps, mean_size)
          if (S_rel_diff_max < delta_S_max * mean_size) then
             ! - - - - - - - - - - - - - - - - - - - - - - -
             ! compute the rolling mean of the latest S when getting
             ! close to the convergence
             ! - - - - - - - - - - - - - - - - - - - - - - -
             if (S_rel_diff_max < delta_S_max) then
                s%Mdot(n_cell) = s%Mdot(n_cell) * 2._x_precision
                print*, 'Converged lately!'
                print*, 'Mdot kick! YOLOOOOO', s%Mdot(n_cell), S_steps
             else
                mean = S_rel_diff / mean_size + &
                     (mean_size - 1._x_precision) / mean_size * mean
                
                if (maxval(dabs(mean)) < delta_S_max) then
                   s%Mdot(n_cell) = s%Mdot(n_cell) * 2._x_precision
                   print*, 'Converged in mean!', maxval(dabs(mean)), S_rel_diff_max
                   print*, 'Mdot kick! YOLOOOOO', s%Mdot(n_cell)
                else
                   if (mod(iteration, output_freq) < 10) then
                      print*, maxval(dabs(mean)), S_rel_diff_max
                   end if
                end if
             end if
          end if
          
       end if
  
       ! Recompute variables when the system is stable
  