Commit 78a7a888 authored by Pierre Cazenave's avatar Pierre Cazenave
Browse files

Actually write the supplied title to the netCDF file. Also tidy up the syntax/formatting.

parent a00ddb57
function write_FVCOM_bedflag(bedflag,filename,mytitle)
% Dump spatially-variable flag (bedflag) to FVCOM forcing file
function write_FVCOM_bedflag(bedflag,filename,mytitle)
% Write spatially-variable flag (bedflag) to FVCOM forcing file
%
% function write_FVCOM_bedflag(bedflag,filename,mytitle)
%
% DESCRIPTION:
% Generate a NetCDF file containing spatially variable bedflag for FVCOM
% Generate a netCDF file containing spatially variable bedflag for FVCOM
%
% INPUT
% bedflag = user defined bed flag (=0, no erosion/bedosition, =1, erosion/bedosition)
% INPUT
% bedflag = user defined bed flag (=0, no erosion/bedosition, =1, erosion/bedosition)
% on the nodes
% filename = filename to dump to
% mytitle = title of the case (set as global attribute)
% mytitle = title of the case (set as global attribute)
%
% OUTPUT:
% NetCDF file: filename
% netCDF file: filename
%
% EXAMPLE USAGE
% write_FVCOM_bedflag(bedflag, 'tst_bedflag.nc', 'no bedosition/erosion in Skagit river')
%
% Author(s):
% Author(s):
% Geoff Cowles (University of Massachusetts Dartmouth)
% Pierre Cazenave (Plymouth Marine Laboratory)
%
% Revision history
% 2016-02-18 Updated the code to use the MATLAB netCDF routines.
%
%==============================================================================
% 2017-03-23 Add the supplied title to the generated netCDF file.
%
%==========================================================================
global ftbverbose
subname = 'write_FVCOM_bedflag';
......@@ -34,16 +34,16 @@ if ftbverbose
fprintf('\nbegin : %s\n', subname)
end
%------------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Parse input arguments
%------------------------------------------------------------------------------
if(~exist('bedflag'))
%--------------------------------------------------------------------------
if ~exist('bedflag', 'var')
error('incorrect usage of gen_bedflag_file, must provide bedflag field')
end
if(~exist('filename'))
if ~exist('filename', 'var')
error('incorrect usage of gen_bedflag_file, must provide filename')
end
if(~exist('title'))
if ~exist('mytitle', 'var')
error('incorrect usage of gen_bedflag_file, must provide title field')
end
......@@ -53,16 +53,19 @@ if(nVerts == 0)
error('dimension of bedflag is 0, something is wrong ')
end;
%------------------------------------------------------------------------------
% Dump to bedflag NetCDF file
%------------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Dump to bedflag netCDF file
%--------------------------------------------------------------------------
if ftbverbose
fprintf('Dumping to bedflag NetCDF file: %s\m', filename);
fprintf('Dumping to bedflag netCDF file: %s\n', filename);
fprintf('Size of bedflag array: %d\n', nVerts);
end
nc = netcdf.create(filename, 'clobber');
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'title', mytitle)
% define dimensions
node_dimid=netcdf.defDim(nc, 'node', numel(bedflag));
......@@ -81,5 +84,5 @@ netcdf.putVar(nc, node_varid, bedflag);
netcdf.close(nc)
if ftbverbose
fprintf('end : %s', subname)
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