function write_binary(fldFile,fld,prec,append)

% Function to write data to a binary file (ieee-be)
% USAGE: write_binary(fldFile,fld,prec)
% Default precision is float32

% Samar Khatiwala (spk@ldeo.columbia.edu)

if nargin<3
  prec='float32';
end
if nargin<4
  append=0;
end

if append==0
  fid=fopen(fldFile,'wb','ieee-be'); 
else
  fid=fopen(fldFile,'ab','ieee-be'); 
end
fwrite(fid,fld,prec); 
fclose(fid);
