1 |
heimbach |
1.1 |
function writebin(fnam,fld,typ,prec) |
2 |
|
|
|
3 |
|
|
% Function writebin(fnam,fld,typ,prec) |
4 |
|
|
% write N-D binary field |
5 |
|
|
% |
6 |
|
|
% INPUTS |
7 |
|
|
% fnam input path and file name |
8 |
|
|
% fld input array |
9 |
|
|
% typ 0: sequential FORTRAN (default); 1: plain binary |
10 |
|
|
% prec numeric precision (default 'real*4') |
11 |
|
|
% |
12 |
|
|
% SEE ALSO |
13 |
|
|
% readbin |
14 |
|
|
|
15 |
|
|
if nargin < 4, prec='real*4'; end |
16 |
|
|
if nargin < 3, typ=0; end |
17 |
|
|
if nargin < 2, error('please specify array and output file name'); end |
18 |
|
|
|
19 |
|
|
fid=fopen(fnam,'w','ieee-be'); |
20 |
|
|
switch typ |
21 |
|
|
case 0 |
22 |
|
|
write_record(fid,fld,prec); |
23 |
|
|
case 1 |
24 |
|
|
fwrite(fid,fld,prec); |
25 |
|
|
end |
26 |
|
|
fid=fclose(fid); |