


Write bathymetry to FVCOM format bathymetry file
function write_FVCOM_bath(Mobj, filename)
DESCRIPTION:
Generate a bathymetry file from a Mesh object
INPUT
Mobj = Mesh object
filename = FVCOM bathymetry file name
OUTPUT:
FVCOM bathymetry file: filename
EXAMPLE USAGE
write_FVCOM_bath(Mobj,'tst_dep.dat')
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Rory O'Hara Murray (Marine Scotland Science)
Revision history
2014-10-07 Removed loops to speed up writing the file
==============================================================================

0001 function write_FVCOM_bath(Mobj,filename) 0002 % Write bathymetry to FVCOM format bathymetry file 0003 % 0004 % function write_FVCOM_bath(Mobj, filename) 0005 % 0006 % DESCRIPTION: 0007 % Generate a bathymetry file from a Mesh object 0008 % 0009 % INPUT 0010 % Mobj = Mesh object 0011 % filename = FVCOM bathymetry file name 0012 % 0013 % OUTPUT: 0014 % FVCOM bathymetry file: filename 0015 % 0016 % EXAMPLE USAGE 0017 % write_FVCOM_bath(Mobj,'tst_dep.dat') 0018 % 0019 % Author(s): 0020 % Geoff Cowles (University of Massachusetts Dartmouth) 0021 % Rory O'Hara Murray (Marine Scotland Science) 0022 % 0023 % Revision history 0024 % 2014-10-07 Removed loops to speed up writing the file 0025 % 0026 %============================================================================== 0027 0028 [~, subname] = fileparts(mfilename('fullpath')); 0029 0030 global ftbverbose 0031 if ftbverbose 0032 fprintf('\nbegin : %s\n', subname); 0033 end 0034 0035 %------------------------------------------------------------------------------ 0036 % Parse input arguments 0037 %------------------------------------------------------------------------------ 0038 if exist('Mobj')*exist('filename') == 0 0039 error('arguments to write_FVCOM_cor are incorrect') 0040 end 0041 0042 %------------------------------------------------------------------------------ 0043 % Dump the file 0044 %------------------------------------------------------------------------------ 0045 if(lower(Mobj.nativeCoords(1:3)) == 'car') 0046 x = Mobj.x; 0047 y = Mobj.y; 0048 else 0049 x = Mobj.lon; 0050 y = Mobj.lat; 0051 end 0052 if(Mobj.have_bath) 0053 if(ftbverbose); fprintf('writing FVCOM bathymetry file %s\n',filename); end; 0054 fid = fopen(filename,'w'); 0055 fprintf(fid,'Node Number = %d\n',Mobj.nVerts); 0056 fprintf(fid, '%f %f %f\n', [x y Mobj.h]'); 0057 fclose(fid); 0058 else 0059 error('can''t write bathymetry to file, mesh object has no bathymetry') 0060 end 0061 0062 if(ftbverbose) 0063 fprintf('end : %s\n', subname) 0064 end 0065 0066