function jarkus_tests(filename)
    filename = 'jarkus23-Jul-2009.nc';
 
    function check(vname, options)
        % check time variable
        v = nc_varget(filename, vname);
        % no data before 1960
        if isfield(options,'min')
            assert(min(v(:)) >= options.min);
        end
        if isfield(options, 'max')
            assert(max(v(:)) <= options.max);
        end
        if isfield(options, 'range')
            assert(range(v(:)) >= options.range(1));
            assert(range(v(:)) <= options.range(2));
        end
        if isfield(options, 'diffrange')
            assert(min(diff(v(:))) >= options.diffrange(1));
            assert(max(diff(v(:))) <= options.diffrange(2));
        end
        if isfield(options, 'lengthrange')
            assert(length(v) >= options.lengthrange(1));
            assert(length(v) <= options.lengthrange(2));
        end
        if isfield(options, 'lengthuniquerange')
            assert(length(unique(v)) >= options.lengthuniquerange(1));
            assert(length(unique(v)) <= options.lengthuniquerange(2));
        end
        if isfield(options, 'nonan')
            assert(~any(isnan(v(:))));
        end
    end

%'id'    'areacode'    'areaname'    'alongshore'    'cross_shore'    'time'    'crs'    'x'    'y'    'lat'    'lon'
%'angle'    'mean_high_water'    'mean_low_water',    'max_cross_shore_measurement',    'min_cross_shore_measurement',    'rsp_x'    'rsp_y'    'rsp_lat'
%'rsp_lon'    'time_topo'    'time_bathy'    'origin'    'altitude'

check('id',  struct('lengthrange', [2000 2300], 'min',1e6, 'max', 18e6, 'nonan', 1));
check('areacode', struct('lengthrange', [2000 2300], 'min', 1, 'max', 17, 'lengthuniquerange', [15 17]));
check('areaname', struct('lengthrange', [2000 2300]));
check('alongshore', struct('lengthrange', [2000 2300], 'min', 0, 'max', 20e3));
check('cross_shore', struct('lengthrange', [1900 2100], 'min', -3e3, 'max', 8e3, 'diffrange', [5 5]));
check('time', struct('lengthrange', [40 50], 'diffrange', [365 366], 'min',datenum('1960-1-1') - datenum('1970-1-1'),'nonan',1));
check('x',  struct('lengthrange', [2000 2300], 'min',0, 'range', [2e5,3e5], 'nonan', 1));
check('y',  struct('lengthrange', [2000 2300], 'min',3e5, 'range', [2e5,3e5], 'nonan', 1));
check('lat',  struct('lengthrange', [2000 2300], 'min',51, 'max', 54, 'range', [2,3], 'nonan', 1));
check('lon',  struct('lengthrange', [2000 2300], 'min',3, 'max', 7, 'range', [3,4], 'nonan', 1));
check('angle',  struct('lengthrange', [2000 2300], 'min',0, 'max', 359, 'nonan', 1));
check('rsp_x',  struct('lengthrange', [2000 2300], 'min',0, 'range', [2e5,3e5], 'nonan', 1));
check('rsp_y',  struct('lengthrange', [2000 2300], 'min',3e5, 'range', [2e5,3e5], 'nonan', 1));
check('mean_high_water',  struct('lengthrange', [2000 2300], 'min',-10, 'max', 10));
check('mean_low_water',  struct('lengthrange', [2000 2300], 'min',-10, 'max', 10));
check('rsp_lon',  struct('lengthrange', [2000 2300], 'min',3, 'max', 7, 'range', [2,4], 'nonan', 1));
check('rsp_lat',  struct('lengthrange', [2000 2300], 'min',51, 'max', 54, 'range', [2,3], 'nonan', 1));
check('time_topo', struct('lengthrange', [2000 2300],'min',datenum('1960-1-1') - datenum('1970-1-1'),'max',datenum('2030-1-1') - datenum('1970-1-1')));
check('time_bathy', struct('lengthrange', [2000 2300],'min',datenum('1960-1-1') - datenum('1970-1-1'),'max',datenum('2030-1-1') - datenum('1970-1-1')));
years = nc_varget(filename, 'time');
for i = 1:length(years)
    info = nc_getvarinfo(filename,'origin');
    o = nc_varget(filename, 'origin', [i-1 0 0], [1 info.Size(2:3)/10], [1 10 10]);
    info = nc_getvarinfo(filename,'altitude');
    h = nc_varget(filename, 'altitude', [i-1 0 0], [1 info.Size(2:3)/10], [1 10 10]);
    nansequal = ((o == 0) == isnan(h));
    assert(all(nansequal(:)));
    assert(min(h(:)) >= -40);
    assert(max(h(:)) <= 40);
    assert(length(unique(o(:))) <= 4);
end
end