function [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,ifield,varargin) % [data,ib,jb,kb,nxl,nyl,nzl,ighost] = read_field_chunk_ucf(file,ifield,varargin) % Reads single field from one processor chunk. % Input % file file to be read % ifield field to be read % 'uvwp': 1:u, 2:v, 3:w, 4:p % 'scal': 1:s1, 2:s2, ... % Optional input (key/value pair) % ghost keep ghost cells? (default: yes) % verbosity verbose output? (default: no) % debug debug output? (default: no) % Output % data partial field with dim(nxl+2*ighost,nyl+2*ighost,nzl+2*ighost) % ib,jb,kb global index of first grid point of the partial field w/o ghost cells % nxl,nyl,nzl local field size w/o ghost cells % ighost ghost cell flag % Parse optional input arguments par = inputParser; addOptional(par,'timestep',1,@isnumeric); addOptional(par,'ghost',1,@isnumeric); addOptional(par,'verbosity',0,@isnumeric); addOptional(par,'debug',0,@isnumeric); parse(par,varargin{:}); istep = par.Results.timestep; keepghost = par.Results.ghost; % Open file obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj.open(file); % Read raw data if ~obj.validateType('field') error('read error: no field data.'); end [data,params] = obj.readSet(istep,ifield); params = cast(params,'double'); ighost = params(1); ib = params(2); jb = params(3); kb = params(4); nxl = params(5); nyl = params(6); nzl = params(7); nx = params(8); ny = params(9); nz = params(10); data = reshape(data,nxl+2*ighost,nyl+2*ighost,nzl+2*ighost); if ighost && ~keepghost data = data(2:end-1,2:end-1,2:end-1); ighost = 0; end % Close UCF file obj.close(); end