function [S_size U_size V_size C_size svd_power Z_flag sigma_A sigma_B C_axes rows2use cols2use S U V] = read_tmp_file(tmp_fname)
% read temp file (as written -- to store info about covariance matrices too
% big to calculate in memory -- by covar.m)

temp_file_in = fopen(tmp_fname, 'r'); 
S_size = round(fread(temp_file_in, 2, 'float32'));
U_size = round(fread(temp_file_in, 2, 'float32'));
V_size = round(fread(temp_file_in, 2, 'float32'));
C_size = round(fread(temp_file_in, 2, 'float32'));

svd_power = fread(temp_file_in, 1, 'float32');
Z_flag = fread(temp_file_in, 1, 'float32');
sigma_A = fread(temp_file_in, 1, 'float32');
sigma_B = fread(temp_file_in, 1, 'float32');

C_axes = fread(temp_file_in, C_size', 'float32'); % actually do not need this as C_axes passed in

rows2use = round(fread(temp_file_in, 2, 'float32'));
cols2use = round(fread(temp_file_in, 2, 'float32'));	
	
S = fread(temp_file_in, S_size', 'float32'); 
S = diag(S)'; % S is a diagonal matrix, so only have the non-zero elements in memory

U = fread(temp_file_in, U_size', 'float32'); 

if(nargout > 13) % don't even read V unless we will need it
    V = fread(temp_file_in, V_size', 'float32'); 
end

fclose(temp_file_in);