1 |
function err=write_bat(z,fname) |
---|
2 |
%WRITE_BAT Write a bathymetry list to disk in .bat format. |
---|
3 |
% WRITE_BAT writes an element list to a file, in the .bat |
---|
4 |
% format as specified in the Dartmouth/Thayer School/NML |
---|
5 |
% File Standards for the Gulf of Maine projects. |
---|
6 |
% |
---|
7 |
% WRITE_BAT(Z,FNAME) opens a file named FNAME in "write" mode and |
---|
8 |
% writes the 1-column bathymetry list Z to the filename in FNAME, |
---|
9 |
% including the node counter as the first column of the output |
---|
10 |
% file. The user should include the .bat file extension in the |
---|
11 |
% filename string FNAME. Both arguments are REQUIRED. |
---|
12 |
% |
---|
13 |
% WRITE_BAT returns a 0 if successful and a -1 if not. |
---|
14 |
% |
---|
15 |
|
---|
16 |
if nargin==0 & nargout==0 |
---|
17 |
disp('Call as: write_bat(z,fname)') |
---|
18 |
return |
---|
19 |
end |
---|
20 |
|
---|
21 |
|
---|
22 |
if nargin~=2,error('WRITE_BAT requires 2 input arguments.'),end |
---|
23 |
|
---|
24 |
[fid,mesg]=fopen(fname,'w'); |
---|
25 |
% Check for open error |
---|
26 |
if(fid<0) |
---|
27 |
errstr=sprintf('Filename %s could not be opened;\n%s\n',fname,mesg); |
---|
28 |
disp(errstr); |
---|
29 |
err=-1 |
---|
30 |
else |
---|
31 |
i=1:length(z); |
---|
32 |
out=[i(:) z(:)]; |
---|
33 |
fprintf(fid,'%d %f\n',out'); |
---|
34 |
fclose(fid); |
---|
35 |
err=0; |
---|
36 |
end |
---|
37 |
|
---|
38 |
|
---|
39 |
% |
---|
40 |
% Brian O. Blanton |
---|
41 |
% Department of Marine Sciences |
---|
42 |
% Ocean Processes Numerical Modeling Laboratory |
---|
43 |
% 12-7 Venable Hall |
---|
44 |
% CB# 3300 |
---|
45 |
% University of North Carolina |
---|
46 |
% Chapel Hill, NC |
---|
47 |
% 27599-3300 |
---|
48 |
% |
---|
49 |
% 919-962-4466 |
---|
50 |
% blanton@marine.unc.edu |
---|
51 |
% |
---|
52 |
% Summer 1998 |
---|
53 |
% |
---|