function n = main_read_size ( file_main )

%*****************************************************************************80
%
%% MAIN_READ_SIZE reads the problem size N from the main file.
%
%  Discussion:
%
%    The problem size is N, the number of cities.
%
%    There should always be a record in the main file of the form
%
%    "size  7"
%
%    I did NOT enjoy trying to work out how to use sscanf() for this task!
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    19 May 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, string FILE_MAIN, the name of the file to read.
%
%    Output, int N, the problem size.
%
  input_unit = fopen ( file_main );

  if ( input_unit < 0 ) 
    fprintf ( 1, '\n' );
    fprintf ( 1, 'MAIN_READ_SIZE - Error!\n' );
    fprintf ( 1, '  Could not open the file "%s".\n', file_main );
    error ( 'MAIN_READ_SIZE - Error!' );
  end

  n = 0;

  while ( 1 )
%
%  Read the next line from the file.
%
    line = fgets ( input_unit );

    if ( line == -1 )
      break;
    end
%
%  Skip blank lines and comment lines.
%
    if ( s_len_trim ( line ) == 0 )

    elseif ( line(1) == '#' )

    else

      [ w, count ] = sscanf ( line, '%4s' );

      if ( count ~= 2 )
        continue;
      end

      if ( ~ s_eqi ( w(1:4), 'size' ) )
        continue;
      end

      [ w, count ] = sscanf ( line, '%4s%d' );
      n = w(5);
      break

    end

  end

  fclose ( input_unit );

  return
end