function [] = write_scal_chunk_ucf(file,s,ib,jb,kb,nx,ny,nz,time,ighost,varargin) % [] = write_scal_chunk_ucf(file,s,ibp,jbp,kbp,nxp,nyp,nzp,time,ighost,varargin) % Writes a partial uvwp field to UCF chunk. % Input % file file to be written (the extension will be replaced by the proc rank) % s partial scalar fields with dim(nx,ny,nz,nscal) % ib,jb,kb global index of first data point of field w/o ghost cells % nx,ny,nz global grid size % time simulation time % ighost does partial field contain ghost cells? % Optional input (key/value pair) % rank processor rank as array [myid,my_col,my_row,my_pln] % endian endianess of the file as used by fopen (default: 'n') % verbosity verbose output? (default: no) % debug debug output? (default: no) % Parse variable input par = inputParser; addParamValue(par,'rank',[0,0,0,0],@(x)isnumeric(x)&&numel(x)==4); addParamValue(par,'endian','n',@ischar); addParamValue(par,'verbosity',0,@isnumeric); addParamValue(par,'debug',0,@isnumeric); parse(par,varargin{:}); % Determine number of scalar fields nscal = size(s,4); % Create file and write to it obj = ucf('verbosity',par.Results.verbosity,'debug',par.Results.debug); obj.create(file,'type','field','rank',par.Results.rank,'endian',par.Results.endian); obj.appendStep(time); % Write scalar field by field for iscal=1:nscal nxl = size(s,1)-2*ighost; nyl = size(s,2)-2*ighost; nzl = size(s,3)-2*ighost; params = int64([ighost,ib,jb,kb,nxl,nyl,nzl,nx,ny,nz]); obj.appendSet(s(:,:,:,iscal),params); end % Close file obj.close(); end