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