% Test case for assessing OPeNDAP acces of files with many (small) variables: load info structure + 1 variable
% Mark's report: http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg12002.html
% http://www.unidata.ucar.edu/software/netcdf/docs/dap_support.html
% $Id$ $HeadURL$
%
% Note that Matlab-OPeNDAP does not support proxy servers:
% http://www.mathworks.nl/help/matlab/import_export/importing-network-common-data-form-netcdf-files-and-opendap-data.html
%
% ncdisp
% n = 0010 toc=   0.179 url=.\test0010.nc
% n = 0100 toc=   0.167 url=.\test0100.nc
% n = 1000 toc=   1.399 url=.\test1000.nc
% n = 2000 toc=   2.752 url=.\test2000.nc
% n = 3000 toc=   4.182 url=.\test3000.nc
%              
% n = 0010 toc=   0.251 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test0010.nc
% n = 0100 toc=   0.403 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test0100.nc
% n = 1000 toc=   6.309 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test1000.nc
% n = 2000 toc=  36.544 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test2000.nc
% n = 3000 toc= 124.358 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test3000.nc
%              
% ncinfo       
% n = 0010 toc=   0.117 url=.\test0010.nc
% n = 0100 toc=   0.040 url=.\test0100.nc
% n = 1000 toc=   0.324 url=.\test1000.nc
% n = 2000 toc=   0.639 url=.\test2000.nc
% n = 3000 toc=   0.957 url=.\test3000.nc
%              
% n = 0010 toc=   0.217 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test0010.nc
% n = 0100 toc=   0.301 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test0100.nc
% n = 1000 toc=   4.909 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test1000.nc
% n = 2000 toc=  34.612 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test2000.nc
% n = 3000 toc= 116.540 url=http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test3000.nc
%
% ...#noprefetch failed
% [noprefetch]... failed

disp(netcdf.inqLibVers) % 4.1.3

clear all
close all
clc
root{1} = '.\';
root{2} = 'http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/';
n = [10,100,1000,2000,3000];

%%
for ir=1:length(root)
    for in=1:length(n)
        tic
        url = [root{ir},'test',num2str(n(in),'%.4d'),'.nc'];
        disp(url)
        ncdisp(url);
        %ncinfo(url);
        ncread(url,'variable0001');
        tocs(ir,in) = toc;
        urls{ir,in} = url;
    end
end
disp(' ')
for ir=1:length(root)
    for in=1:length(n)
        disp([num2str(n(in),'n = %.4d'),' dt=',num2str(tocs(ir,in)),' url=',urls{ir,in}])
    end
end
disp(' ')

%% noprefetch does not work in matlab R2014ab where netcdf.inqLibVers=4.1.3 [2011-06-17]
% http://www.unidata.ucar.edu/software/netcdf/docs/release_notes.html
try
D0 = nc2struct('http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test1000.nc#noprefetch')
catch
    disp('...#noprefetch failed')
end
try
D0 = nc2struct('[noprefetch]http://opendap.deltares.nl/thredds/dodsC/opendap/test/testNcWithManyVariables/test1000.nc')
catch
    disp('[noprefetch]... failed')
end


