function [a, b] = fdot (x, t)

  persistent state_ref_persistent;

  persistent state_copy_persistent;

  global state_ref_global;

  global state_copy_global;

  ## return values of persistent variables if called with no arguments
  if (nargin == 0)

    a = state_ref_persistent;

    b = state_copy_persistent;

    return;

  endif

  global count;
  count++;

  ## persistent variable will be a reference to state
  state_ref_persistent = x;

  ## hack to force a copy of 'x' into a persistent variable
  state_copy_persistent = x;
  t_x2 = x(2);
  state_copy_persistent(2) = t_x2;

### Only these 3 lines are the actual code of the differential equations.

  a = zeros (2, 1);

  a(1) = - x(1)^2 * x(2);

  a(2) = - x(2)^2 * x(1)^2;

###

  if (count == 3)
    printf ("Within the third call to 'fdot()' by lsode.\nState of this third call has _not_yet_\nbeen written to 'state_ref_global' by the code of 'fdot()'.\nBut the content of 'state_ref_global' has already changed with\nrespect to the second call to 'fdot()':\n");
    state_ref_global
  endif

  ## global variable will be a reference to state
  state_ref_global = x;

  ## hack to force a copy of 'x' into a global variable
  state_copy_global = x;
  t_x2 = x(2);
  state_copy_global(2) = t_x2;

  if (count == 2)
    printf ("Within the second call to 'fdot()' by lsode.\nState of this second call _has_already_\nbeen written to 'state_ref_global' by the code of 'fdot()'.\nContent of 'state_ref_global' is:\n");
    state_ref_global
  endif

  wtime = 5;
  if (count == 185)
    printf ("Within the last call to 'fdot()' by lsode.\nWill pause %i seconds so a debugger can be attached.\n\n", ...
            wtime);
    pause (wtime);
  endif

endfunction
