function reportloopprogress( iter, maxIters, freq )
    % Print the progress as a percentage of completion of a loop,
    % periodically.
    %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % DETAILS
    %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % CHANGELOG
    % 21.10.2014 - copied from old version.
    %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    if nargin < 2,
        error('Insufficient arguments!')
    end
    if nargin < 3,
        freq = 1/ 100;
    end

    prog = iter / maxIters;
    
%     condition = rem(prog, freq) == 0;
    condition = floor((iter - 1) / maxIters / freq) < floor(iter / maxIters / freq);

    if condition,
        sprintf('%.1f %% complete', 100 * prog)
    end
end