%testNcWithManyVariables - create netCDF test files
%
% Create test files for Matlab performance issue wioth OPeNDAP as reported
% in:
% on http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg12002.html
%
% for testing, these files are placed in:
%  http://opendap.deltares.nl/thredds/catalog/opendap/test/testNcWithManyVariables/catalog.html
%
%See also: ncwriteschema

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2014 Gerben J. de Boer - Van Oord
%
%   This library is free software: you can redistribute it and/or
%   modify it under the terms of the GNU Lesser General Public
%   License as published by the Free Software Foundation, either
%   version 2.1 of the License, or (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%   Lesser General Public License for more details.
%
%   You should have received a copy of the GNU Lesser General Public
%   License along with this library. If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------
% $Id$ $HeadURL$

clear all
close all
for nvar=[10 100 1000 2000 3000]
    disp(['processing ',num2str(nvar)])

    mySchema.Name   = '/';
    mySchema.Format = 'classic';
    %mySchema.Attributes = struct('Name','comment','Value','Performance test on many variables in one netCDF file via OPeNDAP');

    for idim=1:1
    mySchema.Dimensions(idim).Name   = ['diminsion',num2str(idim)]; % type, but leave it, to kepe it same as ones on server
    mySchema.Dimensions(idim).Length = idim;
    end

    for ivar=1:nvar
        mySchema.Variables(ivar).Name       = ['variable',num2str(ivar,'%0.4d')];
        mySchema.Variables(ivar).Dimensions = mySchema.Dimensions(1);
        mySchema.Variables(ivar).Datatype   = 'double';
        mySchema.Variables(ivar).Attributes = struct('Name','_FillValue','Value',netcdf.getConstant('NC_FILL_DOUBLE'));
    end
    
    ncfile = ['test',num2str(nvar,'%0.4d'),'.nc'];
    ncwriteschema(ncfile, mySchema);
    
    clear mySchema
    
end    
