function [AFS2, totalpoin2, calls2, bisec2, dimP2, tim, suc] = computelockedAFS2(MaxLang, MaxFunC, epsFun, epsKante, epsRand, noiseC, noiseA, s, U, S, V, InitT, calcp)

k = size(U,1);
n = size(V,1);

actpwd = pwd;
cd(calcp);

dlmwrite('wrap/allg.txt',[k;n;s;MaxLang;MaxFunC],'precision','%d');
dlmwrite('wrap/allg.txt',[epsFun;epsKante;epsRand;noiseC;noiseA],'-append','precision','%e');
dlmwrite('wrap/L.txt',U*S(:,1:s),'precision','%15.15e','delimiter',' ');
dlmwrite('wrap/R.txt',V(:,1:s)','precision','%15.15e','delimiter',' ');
dlmwrite('wrap/InitT.txt',InitT,'precision','%15.15e','delimiter',' ');
dlmwrite('wrap/tim.txt',0,'precision','%d');

arch = computer('arch');

set(gcf,'Pointer','Watch');
pause(0.5);
if (strcmp(arch,'maci64') == 1) || (strcmp(arch,'maca64') == 1)
    system('./AFScomputationMAC64.exe 8');
elseif strcmp(arch,'win32') == 1
    system('AFScomputationWINDOWS32.exe 8');
elseif strcmp(arch,'win64') == 1
    system('AFScomputationWINDOWS64.exe 8');
elseif strcmp(arch,'glnx86') == 1
    system('./AFScomputationUNIX32.exe 8');
elseif strcmp(arch,'glnxa64') == 1
    system('./AFScomputationUNIX64.exe 8');
else
    fprintf(2,'No executable version for this type of system.\n');
    suc = -2;
    tim = 0;
    d = [0 0];
    totalpoin2 = 0;
    calls2 = 0;
    bisec2 = 0;
    AFS2 = {};
    set(gcf,'Pointer','arrow');
    cd(actpwd);
    return;
end
set(gcf,'Pointer','arrow');

tim = load('wrap/tim.txt');
if tim(1) == 0
    suc = -2;
    d = [0 0];
    totalpoin2 = 0;
    calls2 = 0;
    bisec2 = 0;
    AFS2 = {};
else
    tim = tim(2);
    results = load('wrap/AFSLock2.txt');
    
    if results(1,1) == 1
        suc = 1;
        d = results(1,2);
        totalpoin2 = d;
        calls2 = results(2,1);
        bisec2 = results(2,2);

        AFS2{1} = results(3:end,:);
    else
        suc = -1;
        d = [0 0];
        totalpoin2 = 0;
        calls2 = 0;
        bisec2 = 0;
        AFS2 = {};
    end
end

dimP2 = d;

cd(actpwd);
