Home > fvcom_prepro > read_fvcom_bath.m

read_fvcom_bath

PURPOSE ^

Read fvcom bathymetry file

SYNOPSIS ^

function [h] = read_fvcom_bath(bathfile)

DESCRIPTION ^

 Read fvcom bathymetry file 

 [h] = function read_fvcom_bath(bathfile)

 DESCRIPTION:
    Read FVCOM Bathymetry file 

 INPUT [keyword pairs]:  
   '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)

 Revision history
   
==============================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE 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 [keyword pairs]:
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 %
0022 % Revision history
0023 %
0024 %==============================================================================
0025 
0026 subname = 'read_fvcom_bath';
0027 global ftbverbose
0028 if(ftbverbose)
0029   fprintf('\n')
0030   fprintf(['begin : ' subname '\n'])
0031 end;
0032 
0033 %------------------------------------------------------------------------------
0034 % read in the FVCOM bathymetry data
0035 %------------------------------------------------------------------------------
0036 fid = fopen(bathfile,'r');
0037 if(fid  < 0)
0038   error(['file: ' bathfile ' does not exist']);
0039 end;
0040 C = textscan(fid, '%s %s %s %d', 1);
0041 Nverts = C{4};
0042 h = zeros(Nverts,1);
0043 fprintf('reading bathymetry file\n');
0044 fprintf('# nodes %d\n',Nverts);
0045 for i=1:Nverts
0046   C = textscan(fid, '%f %f %f', 1);
0047   h(i) = C{3};
0048 end;
0049 fprintf('min depth %f max depth %f\n',min(h),max(h));
0050 fprintf('bathymetry reading complete\n');
0051 fclose(fid);
0052 
0053 
0054 
0055 if(ftbverbose)
0056   fprintf(['end   : ' subname '\n'])
0057 end;
0058 
0059

Generated on Tue 18-Dec-2012 12:37:31 by m2html © 2005