function bOK = tide2netcdf(strOutFile, vDate, vLevel);
% function bOK = tide2netcdf(strOutFile, vDate, vLevel);
%
% Converts ASCII files with tide time series data into netCDF
% format. The data has been prepared for the MICORE 
% project: www.micore.eu
%
% #INPUTS:  -strOutFile: string with the name of the output file in format
%            netCDF
%           -vDate
%           -vLevel
%
% #OUTPUTS: -bOK: Boolean with the result of the conversion from ASCII to netCDF
%
% #REMARKS: * This function calls functions from the OpenEarth Matlab
%             library
%

% International Marine and Dredging Consultants, IMDC
% www.imdc.be
% Antwerp, Belgium
%
% Written by: Fernando Toro, Piet Haerens
%             fto@imdc.be
% Date: November 2009
% Modified: April 2011
% Date:

% Create output netCDF file
% strPathOut = fullfile(strOutFile);
strPathOut = strOutFile;
nc_create_empty(strPathOut);
nc_add_dimension(strPathOut, 'time', length(vDate));
timeVariable = struct(...
    'Name', 'Time', ...
    'Nctype', 'double', ...
    'Dimension', {{'time'}}, ...
    'Attribute', struct('Name', 'unit', 'Value', 'days') ...
    );
nc_addvar(strPathOut, timeVariable);
tideVariable = struct(...
    'Name', 'tide', ...
    'Nctype', 'float', ...
    'Dimension', {{'time'}}, ...
    'Attribute', struct('Name', 'unit', 'Value', 'metre') ...
    );
nc_addvar(strPathOut, tideVariable);
nc_varput(strPathOut, 'Time', vDate);
nc_varput(strPathOut, 'tide', vLevel);
nc_dump(strPathOut);
bOK = 1;
