function analyze_this(info,dirs)

%define runs
runs = {'sb_m3n1','sb_m3n3','nonh_m3n1','nonh_m3n3'};

success_zs0 = {'\\ding{51}','\\ding{51}'; '\\ding{51}','\\ding{51}'};
success_avalanching = {'\\ding{51}','\\ding{51}'; '\\ding{51}','\\ding{51}'};

for iRun = 1:length(runs)
    %% load data
    %dimensions
    dirin = [pwd '\' runs{iRun} '\'] ;
    mpidims = xb_read_mpi_dims(dirin);
    dims = xb_read_dims(dirin);  

    xx = dims.x;
    yy = dims.y;
    zb = nc_varget([dirin 'xboutput.nc'], 'zb'); 
    zb0 = squeeze(zb(1,:,:)); %this is how the imposed bedlevel has been interpreted by xbeach
    zs = nc_varget([dirin 'xboutput.nc'], 'zs'); %waterlevels
    zs0 = squeeze(zs(1,:,:)); %initial waterlevel

    %check waterlevels
        %imposed waterlevel
        params = xb_read_params([dirin 'params.txt']);
        loc = strfind({params.data.name},'zs0');
        loc = find(~cellfun(@isempty,loc));
        zs0_imposed = params.data(loc).value;
        %water levels used by XBeach
        zs0_used = mean(zs0(:,1));
        if zs0_imposed-zs0_used ~= 0; success_zs0{ceil(iRun/2), 2-mod(iRun,2)} = '\\ding{55}';end %read: 'Imposed and used zs0 are not equal'
    %check wave heights

    %check velocities 

    %check bathymetry 
        zbEnd = squeeze(zb(end,:,:));
        transect = round(size(zbEnd,1)/2); %choose central transect for now....can be extended to more transects
        loc2 = mpidims(size(mpidims,1),2)+3; %Note: The overlap of the mpi domains is 3 cells
        loc1 = loc2-4;
        zbmpidomain2_tstart = zb0(transect,loc2);
        zbmpidomain1_tstart = zb0(transect,loc1);
        zbmpidomain2_tend = zbEnd(transect,loc2);
        zbmpidomain1_tend = zbEnd(transect,loc1);
        delta1 = abs(zbmpidomain1_tend-zbmpidomain1_tstart);
        delta2 = abs(zbmpidomain2_tend-zbmpidomain2_tstart);
        % Following statement says: If either the changes in mpidomain1 are smaller 
        % than X meters (2m) through the simulation OR the difference between 
        % mpidomain2 and mpidomain1 is too large (more than 20% difference in 
        % bottom level at the end of the simulation), something goes wrong in the
        % avalanching over that mpi boundary. Note: The overlap of the mpi domains
        % is 3 cells
    if delta1 < 2 || delta2/delta1 > 1.2; success_avalanching{ceil(iRun/2), 2-mod(iRun,2)} = '\\ding{55}';end %read: 'Avalanching doesn''t pass mpi boundary correctly'
end


%% Write results 2 LaTeX table
TableName_Avalanche = fullfile(dirs.output, 'FunctionalTests_Avalanching_Results.tex');
fid1 = fopen(TableName_Avalanche, 'w');
fprintf(fid1, '\\caption{Results functional test - MPI avalanching} \n');
fprintf(fid1, '\\begin{tabular}{lll}\\hline\\hline \n');
fprintf(fid1, ' & m3n1 & m3n3 \\\\ \n');
fprintf(fid1, '\\hline \n');
fprintf(fid1, ['surfbeat & ' success_avalanching{1,1} ' & ' success_avalanching{1,2} ' \\\\ \n']);
fprintf(fid1, ['non-hydrostatic & ' success_avalanching{2,1} ' & ' success_avalanching{2,2} ' \\\\ \n']);
fprintf(fid1, '\\hline \n');
fprintf(fid1, '\\end{tabular} \n');
fclose(fid1);

TableName_Waterlevel = fullfile(dirs.output, 'FunctionalTests_Waterlevel_Results.tex');
fid2 = fopen(TableName_Waterlevel, 'w');
fprintf(fid2, '\\caption{Results functional test - MPI waterlevels} \n');
fprintf(fid2, '\\begin{tabular}{lll}\\hline\\hline \n');
fprintf(fid2, ' & m3n1 & m3n3 \\\\ \n');
fprintf(fid2, '\\hline \n');
fprintf(fid2, ['surfbeat & ' success_zs0{1,1} ' & ' success_zs0{1,2} ' \\\\ \n']);
fprintf(fid2, ['non-hydrostatic & ' success_zs0{2,1} ' & ' success_zs0{2,2} ' \\\\ \n']);
fprintf(fid2, '\\hline \n');
fprintf(fid2, '\\end{tabular} \n');
fclose(fid2);
