


Read fvcom bathymetry file
[h] = function read_fvcom_bath(bathfile)
DESCRIPTION:
Read FVCOM Bathymetry file
INPUT:
bathfile = fvcom bathymetry file
OUTPUT:
h = bathymetry vector
EXAMPLE USAGE
Mobj = read_fvcom_bath('tst_dep.dat')
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Rory O'Hara Murray (Marine Scotland Science)
Pierre Cazenave (Plymouth Marine Laboratory)
Revision history
2014-11-19 Remove loops to speed up reading in the file.
2017-04-11 Minor clean up of the code.
==============================================================================

0001 function [h] = read_fvcom_bath(bathfile) 0002 0003 % Read fvcom bathymetry file 0004 % 0005 % [h] = function read_fvcom_bath(bathfile) 0006 % 0007 % DESCRIPTION: 0008 % Read FVCOM Bathymetry file 0009 % 0010 % INPUT: 0011 % bathfile = fvcom bathymetry file 0012 % 0013 % OUTPUT: 0014 % h = bathymetry vector 0015 % 0016 % EXAMPLE USAGE 0017 % Mobj = read_fvcom_bath('tst_dep.dat') 0018 % 0019 % Author(s): 0020 % Geoff Cowles (University of Massachusetts Dartmouth) 0021 % Rory O'Hara Murray (Marine Scotland Science) 0022 % Pierre Cazenave (Plymouth Marine Laboratory) 0023 % 0024 % Revision history 0025 % 2014-11-19 Remove loops to speed up reading in the file. 0026 % 2017-04-11 Minor clean up of the code. 0027 % 0028 %============================================================================== 0029 0030 global ftbverbose 0031 [~, subname] = fileparts(mfilename('fullpath')); 0032 if ftbverbose 0033 fprintf('\nbegin : %s\n', subname) 0034 end 0035 0036 %------------------------------------------------------------------------------ 0037 % read in the FVCOM bathymetry data 0038 %------------------------------------------------------------------------------ 0039 fid = fopen(bathfile, 'r'); 0040 assert(fid > 0, 'file: %s does not exist', bathfile); 0041 0042 C = textscan(fid, '%s %s %s %d', 1); 0043 Nverts = C{4}; 0044 if ftbverbose 0045 fprintf('reading bathymetry file\n'); 0046 fprintf('# nodes %d\n',Nverts); 0047 end 0048 C = textscan(fid,' %f %f %f',Nverts); 0049 h = C{3}; 0050 fclose(fid); 0051 0052 if ftbverbose 0053 fprintf('min depth %f max depth %f\n',min(h),max(h)); 0054 fprintf('bathymetry reading complete\n'); 0055 end 0056 0057 if ftbverbose 0058 fprintf('end : %s\n', subname) 0059 end