function plotdata(info,dirs)

dr  = dir(pwd);
idx = find([dr.isdir]&~ismember({dr.name},{'.' '..'}));

sx = ceil(sqrt(length(idx)));
sy = ceil(length(idx)/sx);

f1 = figure;
f2 = figure;

col  = 'rgbcymk';
vars = {'zs' 'zb' 'H' 'thetamean' 'ue' 've' 'k' 'ee' 'theta'};

for i = 1:length(idx)
    fname = dr(idx(i)).name;
    dname = strrep(fname,'deg','^o');
    
    d    = xb_read_dims(fname);
    xbo1 = xs_peel(xb_read_output(fname,'vars',vars,'start',d.nt-1,'length',1));
    
    % derivatives
    dx    = d.x(2)-d.x(1);
    h     = squeeze(xbo1.zs-xbo1.zb);
    g     = 9.81;
    w     = 2*pi/8;
    kh    = squeeze(xbo1.k).*h;
    c     = squeeze(w./xbo1.k);
    cg    = c.*(0.5+kh./sinh(2*kh));
    dir0  = (270-xbo1.thetamean(1,1,1))*pi/180;
    dirsn = 270-asin(c.*sin(dir0)/c(1))*180/pi;
    
    dhdx = zeros(size(h));
    dhdx(2:end) = (h(2:end)-h(1:end-1))/dx;
    ctheta = w./sinh(2*squeeze(xbo1.k).*h).*dhdx;
    
    dirint = zeros(size(dirsn));
    dirint(1) = dir0;
    for j=2:d.nx
        dirint(j) = dirint(j-1)+1/(cg(j-1)*cos(dirint(j-1)))*dx*sin(dirint(j-1))*ctheta(j-1);
    end
    dirint = 270-dirint*180/pi;
    dirint = min(dirint,270);

    % plot #1
    figure(f1);

    subplot(5,1,1); hold on;
    plot(d.x,squeeze(xbo1.zb),'-k','LineWidth',2);
    plot(d.x,squeeze(xbo1.zs),'-b','LineWidth',2);
    set(gca,'YLim',[-20 3]); box on;
    ylabel('bathymetry [m]');

    subplot(5,1,2); hold on;
    plot(d.x,dirsn,'--k','LineWidth',2);
    plot(d.x,dirint,'--b','LineWidth',2);
    plot(d.x,squeeze(xbo1.thetamean),'-','Color',col(i),'LineWidth',2);
    set(gca,'YLim',[200 280]); box on;
    ylabel('direction [^o]');
    
    subplot(5,1,3); hold on;
    plot(d.x,sqrt(2)*squeeze(xbo1.H),'-','Color',col(i),'LineWidth',2);
    set(gca,'YLim',[0 3.5]); box on;
    ylabel('H [m]');
    
    subplot(5,1,4); hold on;
    plot(d.x,squeeze(xbo1.ue),'-','Color',col(i),'LineWidth',2);
    set(gca,'YLim',[-.2 .2]); box on;
    ylabel('ue [m]');
    
    subplot(5,1,5); hold on;
    plot(d.x,squeeze(xbo1.ve),'-','Color',col(i),'LineWidth',2,'DisplayName',dname);
    set(gca,'YLim',[-.3 2]); box on;
    ylabel('ve [m]');
    
	% plot #2
    figure(f2);
    subplot(sy,sx,i); hold on;
    if length(xbo1.theta)>1
        pcolor(xbo1.theta/pi*180,d.x,squeeze(xbo1.ee)');
    end
    plot(270-dirsn,d.x,'--r','LineWidth',2)
    shading interp;
    colormap gray;
    caxis([0 16000]);
    axis([-10 90 -80 1000]);
    colorbar;
    
    if i>length(idx)-sy
        xlabel('direction [^o]');
    end
    
    if mod(i,sx)==1
        ylabel('distance [m]');
    end
    
    title(dname);
end

set(findobj(f1,'Type','axes'),'XLim',[0 1000]);

figure(f1);
subplot(5,1,5);
legend show;
set(legend('show'),'Location','NorthWest');
xlabel('distance [m]');

xb_write_plot(f1,dirs.output,'crosssection');
xb_write_plot(f2,dirs.output,'refraction');