clear all
close all
clc

red_flag = 1;
while (red_flag)
    fprintf('\n');
    fprintf('Please, select :\n');
    fprintf(' [1] - import results from TEXT output files\n');
    fprintf(' [2] - import results from MAT workspace files\n');
    fprintf('\n');
    what_import = str2num(input(' Enter your choice: ','s'));
    if((what_import<1) | (what_import>2) | isempty(what_import))
        red_flag = 1;
    else
        red_flag = 0;
    end
end

red_flag = 1;
while (red_flag)
    fprintf('\n');
    fprintf('Please, select what do you want to compare:\n');
    fprintf(' [1] - NOMAD, DENCON, DENPAR as stand-alone solvers\n');
    fprintf(' [2] - NOMAD.ALONE, NOMAD.DENCON, NOMAD.DENPAR solvers\n');
    fprintf(' [3] - Both choices 1 and 2\n');
    fprintf(' [4] - NOMAD.DENCON with 500, 1000, 2000, 3000, 4000, 5000 eval/iter\n');
    fprintf(' [5] - NOMAD.DENPAR with 500, 1000, 2000, 3000, 4000, 5000 eval/iter\n');
    fprintf(' [6] - Both choices 4 and 5\n');
    fprintf(' [7] - All choices 1, 2, 4 and 5\n');
    fprintf('\n');
    what_solver = str2num(input(' Enter your choice: ','s'));
    if((what_solver<1) | (what_solver>7) | isempty(what_solver))
        red_flag = 1;
    else
        red_flag = 0;
    end
end


red_flag = 1;
while (red_flag)
    fprintf('\n');
    fprintf('Please, select the number of processors:\n');
    fprintf(' [1] - Single processor\n');
    fprintf(' [2] - 64 processors\n');
    fprintf(' [3] - Both the choices\n');
    fprintf('\n');
    what_proc = str2num(input(' Enter your choice: ','s'));
    if((what_proc<1) | (what_proc>3) | isempty(what_proc))
        red_flag = 1;
    else
        red_flag = 0;
    end
end

%if((what_solver > 1) & (what_solver < 4))
if((what_solver == 2) | (what_solver == 3) | (what_solver == 7))
    red_flag = 1;
    while (red_flag)
        fprintf('\n');
        fprintf('Please, select the number of evaluations for each iterative repetition:\n');
        fprintf(' [0] - 500\n');
        fprintf(' [1] - 1000\n');
        fprintf(' [2] - 2000\n');
        fprintf(' [3] - 3000\n');
        fprintf(' [4] - 4000\n');
        fprintf(' [5] - 5000\n');
        fprintf(' [6] - All of the choices\n');
        fprintf('\n');
        what_eval = str2num(input(' Enter your choice: ','s'));
        if((what_eval<0) | (what_eval>6) | isempty(what_eval))
            red_flag = 1;
        else
            red_flag = 0;
        end
    end
end

%keyboard

if((what_solver == 1) | (what_solver == 3) | (what_solver == 7))
    if((what_proc == 1) | (what_proc == 3))
        solvers = {'NOMAD.ALONE', 'DENCON.ALONE', 'DENPAR.ALONE'};
        filename = './nomad.alone.dencon.alone.denpar.alone.noproc.50000.n500.mat';
        if(what_import==1)
            [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'dencon.alone', 'denpar.alone'},'NOPROC','');
            %Save the imported results to MAT file
            fprintf('The imported results are to be saved to the matlab .MAT file\n');
            fprintf('  %s\n',filename)
            save_to_file = input('Is this OK? y/[N] ','s');
            if(isempty(save_to_file))
                save_to_file = 'N';
            end

            if(strcmp(save_to_file,'y'))
                save(filename,'H*','N*');
            end
        else
            load(filename);
        end
        FID = fopen('area_history.NOPROC.STANDALONE.tex','w');
        stampa_2(H,N,solvers,'NOPROC.STANDALONE.alln',FID);
        stampa_2(H10,N10,solvers,'NOPROC.STANDALONE.n10',FID);
        stampa_2(H20,N20,solvers,'NOPROC.STANDALONE.n20',FID);
        stampa_2(H30,N30,solvers,'NOPROC.STANDALONE.n30',FID);
        fclose(FID);
    end
    if((what_proc == 2) | (what_proc == 3))
        solvers = {'NOMAD.ALONE', 'DENCON.ALONE', 'DENPAR.ALONE'};
        filename = './nomad.alone.dencon.alone.denpar.alone.64proc.50000.n500.mat';
        if(what_import == 1)
            [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'dencon.alone', 'denpar.alone'},'proc.64','');
            %Save the imported results to MAT file
            fprintf('The imported results are to be saved to the matlab .MAT file\n');
            fprintf('  %s\n',filename)
            save_to_file = input('Is this OK? y/[N] ','s');
            if(isempty(save_to_file))
                save_to_file = 'N';
            end

            if(strcmp(save_to_file,'y'))
                save(filename,'H*','N*');
            end
        else
            load(filename);
        end
        FID = fopen('area_history.64PROC.STANDALONE.tex','w');
        stampa_2(H,N,solvers,'64PROC.STANDALONE.alln',FID);
        stampa_2(H10,N10,solvers,'64PROC.STANDALONE.n10',FID);
        stampa_2(H20,N20,solvers,'64PROC.STANDALONE.n20',FID);
        stampa_2(H30,N30,solvers,'64PROC.STANDALONE.n30',FID);
        fclose(FID);
    end
end
if((what_solver == 2) | (what_solver == 3) | (what_solver == 7))
    if((what_proc == 1) | (what_proc == 3))
        if((what_eval == 0) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.500.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'NOPROC','500');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.NOPROC.500.tex','w');
            stampa_2(H,N,solvers,'NOPROC.500.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.500.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.500.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.500.n30',FID);
            fclose(FID);
        end
        if((what_eval == 1) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.1000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'NOPROC','1000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.NOPROC.1000.tex','w');
            stampa_2(H,N,solvers,'NOPROC.1000.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.1000.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.1000.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.1000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 2) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.2000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'NOPROC','2000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.NOPROC.2000.tex','w');
            stampa_2(H,N,solvers,'NOPROC.2000.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.2000.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.2000.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.2000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 3) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.3000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'NOPROC','3000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.NOPROC.3000.tex','w');
            stampa_2(H,N,solvers,'NOPROC.3000.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.3000.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.3000.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.3000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 4) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.4000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'NOPROC','4000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.NOPROC.4000.tex','w');
            stampa_2(H,N,solvers,'NOPROC.4000.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.4000.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.4000.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.4000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 5) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.5000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'NOPROC','5000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.NOPROC.5000.tex','w');
            stampa_2(H,N,solvers,'NOPROC.5000.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.5000.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.5000.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.5000.n30',FID);
            fclose(FID);
        end
    end
    if((what_proc == 2) | (what_proc == 3))
        if((what_eval == 0) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.500.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'proc.64','500');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.64PROC.500.tex','w');
            stampa_2(H,N,solvers,'64PROC.500.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.500.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.500.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.500.n30',FID);
            fclose(FID);
        end
        if((what_eval == 1) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.1000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'proc.64','1000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.64PROC.1000.tex','w');
            stampa_2(H,N,solvers,'64PROC.1000.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.1000.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.1000.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.1000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 2) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.2000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'proc.64','2000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.64PROC.2000.tex','w');
            stampa_2(H,N,solvers,'64PROC.2000.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.2000.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.2000.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.2000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 3) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.3000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'proc.64','3000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.64PROC.3000.tex','w');
            stampa_2(H,N,solvers,'64PROC.3000.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.3000.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.3000.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.3000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 4) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.4000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'proc.64','4000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.64PROC.4000.tex','w');
            stampa_2(H,N,solvers,'64PROC.4000.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.4000.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.4000.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.4000.n30',FID);
            fclose(FID);
        end
        if((what_eval == 5) | (what_eval == 6))
            solvers = {'NOMAD.ALONE', 'NOMAD.DENCON', 'NOMAD.DENPAR'};
            filename = './nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.5000.n500.mat';
            if(what_import==1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.alone', 'nomad.dencon', 'nomad.denpar'},'proc.64','5000');
                %Save the imported results to MAT file
                fprintf('The imported results are to be saved to the matlab .MAT file\n');
                fprintf('  %s\n',filename)
                save_to_file = input('Is this OK? y/[N] ','s');
                if(isempty(save_to_file))
                    save_to_file = 'N';
                end

                if(strcmp(save_to_file,'y'))
                    save(filename,'H*','N*');
                end
            else
                load(filename);
            end
            FID = fopen('area_history.64PROC.5000.tex','w');
            stampa_2(H,N,solvers,'64PROC.5000.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.5000.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.5000.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.5000.n30',FID);
            fclose(FID);
        end
    end
end
if((what_solver == 4) | (what_solver == 6) | (what_solver == 7))
    % comapre NOMAD.DENCON with 500, 1000, 2000, 3000, 4000, 5000
    if((what_proc == 1) | (what_proc == 3))
            if(what_import == 1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'NOPROC','500');
                G(:,:,1) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'NOPROC','1000');
                G(:,:,2) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'NOPROC','2000');
                G(:,:,3) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'NOPROC','3000');
                G(:,:,4) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'NOPROC','4000');
                G(:,:,5) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'NOPROC','5000');
                G(:,:,6) = H(:,:,1);
            else
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.500.n500.mat');
                G(:,:,1) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.1000.n500.mat');
                G(:,:,2) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.2000.n500.mat');
                G(:,:,3) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.3000.n500.mat');
                G(:,:,4) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.4000.n500.mat');
                G(:,:,5) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.5000.n500.mat');
                G(:,:,6) = H(:,:,2);
            end
            H = G;
            ind = find(N~=10);
            N10 = N;
            N10(ind) = [];
            H10 = H;
            H10(:,ind,:) = [];

            ind = find(N~=20);
            N20 = N;
            N20(ind) = [];
            H20 = H;
            H20(:,ind,:) = [];

            ind = find(N~=30);
            N30 = N;
            N30(ind) = [];
            H30 = H;
            H30(:,ind,:) = [];

            solvers = {'NOMAD.DENCON.500', 'NOMAD.DENCON.1000', 'NOMAD.DENCON.2000', 'NOMAD.DENCON.3000', 'NOMAD.DENCON.4000', 'NOMAD.DENCON.5000'};
            FID = fopen('area_history.nomad.dencon.NOPROC.tex','w');
            stampa_2(H,N,solvers,'NOPROC.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.n30',FID);
            fclose(FID);
    end
    if((what_proc == 2) | (what_proc == 3))
            if(what_import == 1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'proc.64','500');
                G(:,:,1) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'proc.64','1000');
                G(:,:,2) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'proc.64','2000');
                G(:,:,3) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'proc.64','3000');
                G(:,:,4) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'proc.64','4000');
                G(:,:,5) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.dencon'},'proc.64','5000');
                G(:,:,6) = H(:,:,1);
            else
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.500.n500.mat');
                G(:,:,1) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.1000.n500.mat');
                G(:,:,2) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.2000.n500.mat');
                G(:,:,3) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.3000.n500.mat');
                G(:,:,4) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.4000.n500.mat');
                G(:,:,5) = H(:,:,2);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.5000.n500.mat');
                G(:,:,6) = H(:,:,2);
            end
            H = G;
            ind = find(N~=10);
            N10 = N;
            N10(ind) = [];
            H10 = H;
            H10(:,ind,:) = [];

            ind = find(N~=20);
            N20 = N;
            N20(ind) = [];
            H20 = H;
            H20(:,ind,:) = [];

            ind = find(N~=30);
            N30 = N;
            N30(ind) = [];
            H30 = H;
            H30(:,ind,:) = [];

            solvers = {'NOMAD.DENCON.500', 'NOMAD.DENCON.1000', 'NOMAD.DENCON.2000', 'NOMAD.DENCON.3000', 'NOMAD.DENCON.4000', 'NOMAD.DENCON.5000'};
            FID = fopen('area_history.nomad.dencon.64PROC.tex','w');
            stampa_2(H,N,solvers,'64PROC.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.n30',FID);
            fclose(FID);
    end
end

if((what_solver == 5) | (what_solver == 6) | (what_solver == 7))
    % comapre NOMAD.DENPAR with 500, 1000, 2000, 3000, 4000, 5000
    if((what_proc == 1) | (what_proc == 3))
            if(what_import == 1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'NOPROC','500');
                G(:,:,1) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'NOPROC','1000');
                G(:,:,2) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'NOPROC','2000');
                G(:,:,3) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'NOPROC','3000');
                G(:,:,4) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'NOPROC','4000');
                G(:,:,5) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'NOPROC','5000');
                G(:,:,6) = H(:,:,1);
            else
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.500.n500.mat');
                G(:,:,1) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.1000.n500.mat');
                G(:,:,2) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.2000.n500.mat');
                G(:,:,3) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.3000.n500.mat');
                G(:,:,4) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.4000.n500.mat');
                G(:,:,5) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.noproc.50000.5000.n500.mat');
                G(:,:,6) = H(:,:,3);
            end
            H = G;
            ind = find(N~=10);
            N10 = N;
            N10(ind) = [];
            H10 = H;
            H10(:,ind,:) = [];

            ind = find(N~=20);
            N20 = N;
            N20(ind) = [];
            H20 = H;
            H20(:,ind,:) = [];

            ind = find(N~=30);
            N30 = N;
            N30(ind) = [];
            H30 = H;
            H30(:,ind,:) = [];

            solvers = {'NOMAD.DENPAR.500', 'NOMAD.DENPAR.1000', 'NOMAD.DENPAR.2000', 'NOMAD.DENPAR.3000', 'NOMAD.DENPAR.4000', 'NOMAD.DENPAR.5000'};
            FID = fopen('area_history.nomad.denpar.NOPROC.tex','w');
            stampa_2(H,N,solvers,'NOPROC.alln',FID);
            stampa_2(H10,N10,solvers,'NOPROC.n10',FID);
            stampa_2(H20,N20,solvers,'NOPROC.n20',FID);
            stampa_2(H30,N30,solvers,'NOPROC.n30',FID);
            fclose(FID);
    end
    if((what_proc == 2) | (what_proc == 3))
            if(what_import == 1)
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'proc.64','500');
                G(:,:,1) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'proc.64','1000');
                G(:,:,2) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'proc.64','2000');
                G(:,:,3) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'proc.64','3000');
                G(:,:,4) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'proc.64','4000');
                G(:,:,5) = H(:,:,1);
                [H,H10,H20,H30,N,N10,N20,N30] = load_textdata({'nomad.denpar'},'proc.64','5000');
                G(:,:,6) = H(:,:,1);
            else
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.500.n500.mat');
                G(:,:,1) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.1000.n500.mat');
                G(:,:,2) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.2000.n500.mat');
                G(:,:,3) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.3000.n500.mat');
                G(:,:,4) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.4000.n500.mat');
                G(:,:,5) = H(:,:,3);
                load('./nomad.nomad.nomad.dencon.nomad.denpar.64proc.50000.5000.n500.mat');
                G(:,:,6) = H(:,:,3);
            end
            H = G;
            ind = find(N~=10);
            N10 = N;
            N10(ind) = [];
            H10 = H;
            H10(:,ind,:) = [];

            ind = find(N~=20);
            N20 = N;
            N20(ind) = [];
            H20 = H;
            H20(:,ind,:) = [];

            ind = find(N~=30);
            N30 = N;
            N30(ind) = [];
            H30 = H;
            H30(:,ind,:) = [];

            solvers = {'NOMAD.DENPAR.500', 'NOMAD.DENPAR.1000', 'NOMAD.DENPAR.2000', 'NOMAD.DENPAR.3000', 'NOMAD.DENPAR.4000', 'NOMAD.DENPAR.5000'};
            FID = fopen('area_history.nomad.denpar.64PROC.tex','w');
            stampa_2(H,N,solvers,'64PROC.alln',FID);
            stampa_2(H10,N10,solvers,'64PROC.n10',FID);
            stampa_2(H20,N20,solvers,'64PROC.n20',FID);
            stampa_2(H30,N30,solvers,'64PROC.n30',FID);
            fclose(FID);
    end
end
