function index = scip_index_read ( filename )

%*****************************************************************************80
%
%% SCIP_INDEX_READ reads the solution index ordering from an SCIP file.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    13 June 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, string FILENAME, the name of the input file.
%
%    Output, integer INDEX(X_NUM), the reordering imposed by SCIP.
%
  debug = false;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'SCIP_INDEX_READ:\n' );
  fprintf ( 1, '  Extract solution index ordering from a SCIP solution file.\n' );

  input_unit = fopen ( filename );

  var_num = 0;

  line_text = fgetl ( input_unit );
 
  word_num = s_word_count ( line_text );

  if ( debug )
    fprintf ( 1, '\n' );
    fprintf ( 1, '  First line word count = %d\n', word_num );
  end

  x_dim = word_num - 2;

  if ( debug )
    fprintf ( 1, '  Number of variables   = %d\n', x_dim );
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Words in the first line:\n' );
    fprintf ( 1, '\n' );
  end

  index = zeros ( x_dim, 1 );

  for word_index = 1 : word_num
    [ w, line_text ] = s_word_extract_first ( line_text );
 
    if ( 1 < word_index && word_index < word_num )
      i = str2num ( w(2:end-1) );
      index(word_index-1) = i;
    end
    if ( debug )
      fprintf ( 1, ' %s', w );
    end
  end

  if ( debug )
    fprintf ( 1, '\n' );
  end

  fclose ( input_unit );

  return
end
