Commit a0cc0ec6 authored by Pierre Cazenave's avatar Pierre Cazenave
Browse files

Minor clean up of the code to read in the grid bathymetry.

parent 9746fd02
function [h] = read_fvcom_bath(bathfile)
function [h] = read_fvcom_bath(bathfile)
% Read fvcom bathymetry file
% Read fvcom bathymetry file
%
% [h] = function read_fvcom_bath(bathfile)
%
% DESCRIPTION:
% Read FVCOM Bathymetry file
% Read FVCOM Bathymetry file
%
% INPUT [keyword pairs]:
% 'bathfile' = fvcom bathymetry file
% INPUT:
% bathfile = fvcom bathymetry file
%
% OUTPUT:
% h = bathymetry vector
......@@ -16,13 +16,15 @@ function [h] = read_fvcom_bath(bathfile)
% EXAMPLE USAGE
% Mobj = read_fvcom_bath('tst_dep.dat')
%
% Author(s):
% 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.
%
%==============================================================================
global ftbverbose
......@@ -34,25 +36,24 @@ end
%------------------------------------------------------------------------------
% read in the FVCOM bathymetry data
%------------------------------------------------------------------------------
fid = fopen(bathfile,'r');
if(fid < 0)
error(['file: ' bathfile ' does not exist']);
end;
fid = fopen(bathfile, 'r');
assert(fid > 0, 'file: %s does not exist', bathfile);
C = textscan(fid, '%s %s %s %d', 1);
Nverts = C{4};
h = zeros(Nverts,1);
fprintf('reading bathymetry file\n');
fprintf('# nodes %d\n',Nverts);
if ftbverbose
fprintf('reading bathymetry file\n');
fprintf('# nodes %d\n',Nverts);
end
C = textscan(fid,' %f %f %f',Nverts);
h = C{3};
fprintf('min depth %f max depth %f\n',min(h),max(h));
fprintf('bathymetry reading complete\n');
fclose(fid);
if ftbverbose
fprintf('min depth %f max depth %f\n',min(h),max(h));
fprintf('bathymetry reading complete\n');
end
if(ftbverbose)
fprintf(['end : ' subname '\n'])
end;
if ftbverbose
fprintf('end : %s\n', subname)
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment