function [iproc,nmaster,nslave,stime] = read_particle_balancing_ucf(file,varargin) % [pp,col] = read_particles_ucf(file,varargin) % Reads particle data from UCF file % Input % file file to be read % Optional input (key/value pair) % timestep timestep to be read (default: all) % verbosity verbose output? (default: no) % debug debug output? (default: no) % Output % pp particle balancing data % stime simulation time with dim(1,nt) % Parse optional input arguments par = inputParser; addParamValue(par,'timestep',1,@isnumeric); addParamValue(par,'verbosity',0,@isnumeric); addParamValue(par,'debug',0,@isnumeric); parse(par,varargin{:}); istep = par.Results.timestep; % Open file obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj.open(file); % Get range of steps to be read if istep>obj.getNumTimesteps() error('Timestep out of range.'); end % Get simulation time stime = obj.getSimulationTime(istep); % Read data [data,params] = obj.readSet(istep,1); params = cast(params,'double'); nxprocs = params(1); nyprocs = params(2); nzprocs = params(3); data = cast(reshape(data,3,nxprocs*nyprocs*nzprocs),'double'); iproc = data(1,:); nmaster = data(2,:); nslave = data(3,:); % Close file obj.close(); end