function [PL_A,PL_D,FIG,FIG_ENG] = report_AR(chainID,unitID,tipoarray,contunit,...
    siteID,FIG,FIG_ENG,rpt,rpt_ENG,Font_caption,Font_Chapter,Font_section,...
    Font_tools,datarif,yesKLHR3D,rTL,rTLHR,rTLH,rTLHRH,rPL,rBL,rLL,rRL,rKL,...
    rKLHR,rThL,rPT100,rIPL,rIPLHR,rTuL,rRaL,rPCL,rPCLHR,rPrL,rEL,r3DEL,rWEL,rMPBEL,...
    rCrL,r2DCrL,r3DCrL,rBML,rHL,rLuxL,rCO2,rRSN,rRSNHR,rTrL,rPE,rWL,rGF,rGS,...
    NodoTiltLink,NodoTiltLinkH,NodoPiezoLink,NodoBaroLink,NodoLoadLink,...
    NodoRainLink,NodoKlinoLink,NodoKlinoLinkHR,NodoThermLink,NodoPT100Link,...
    NodoInPlaceLink,NodoInPlaceLinkHR,NodoTunnelLink,NodoRadialLink,NodoPreConvLink,...
    NodoPressureLink,NodoExtensometerLink,Nodo3DExtensometerLink,...
    NodoWireExtensometerLink,NodoMultiPointExtensometerLink,NodoCrackLink,...
    Nodo2DCrackLink,Nodo3DCrackLink,NodoBaroMusaLink,NodoHumidityLink,NodoLuxLink,...
    NodoCO2Link,NodoRSNLink,NodoRSNHRLink,NodoTriggerLink,NodoStressMeter,NodoWeirLink,...
    NodoPendulum,MUMS,MUMS_ENG,colonna2,colonna2bis,colonna4,firstdata_num,activeEN,IDscaduta,...
    status,br,conn,FileName)

fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'report_AR function started';
fprintf(fileID,fmt,text);
fclose(fileID);

import mlreportgen.dom.*
import mlreportgen.report.*

% Make sure DOM is compilable
makeDOMCompilable()

% Inizializzo
[rAR,~] = size(chainID);
[GI_Disp_TL,GI_Date_TL,GI_Prof_TL,GI_Disp_IPL,GI_Date_IPL,GI_Prof_IPL,...
    GI_Disp_IPLHR,GI_Date_IPLHR,GI_Prof_IPLHR,GI_Level_PL,GI_Prof_PL,GI_Date_PL,...
    GI_Rain_RL,GI_Date_RL,GI_Angolo_KL,GI_Date_KL,GI_Num_KL,GI_Disp_CrL,GI_Date_CrL,...
    GI_Num_CrL,PL_A,PL_D,GI_Q1_TuL,GI_Q2_TuL,GI_Q3_TuL,GI_Q4_TuL,GI_Q1_Num_TuL,...
    GI_Q2_Num_TuL,GI_Q3_Num_TuL,GI_Q4_Num_TuL,GI_Seg_TuL,GI_NumSeg_TuL,GI_Z_TuL,...
    GI_Date_TuL,GI_XYZ_Rad,GI_Num_Rad,GI_dS_RL_MPB,GI_dS_RL_TuL,GI_dS_TuL_RL,...
    GI_Date_Rad,GI_Z_PCL,GI_Date_PCL,GI_Date_MPB,GI_dS_MPB,GI_MPB_Base,GI_dS_MPB_RL] = report_ini;

fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'report_ini function executed';
fprintf(fileID,fmt,text);
fclose(fileID);

kl = 1;
s = 1; % Usato nei Cir
TR = 1; % usato nei Cir-Rad
TP = 1; % Usato nei Cir-PCL
MR = 1; % usato nei multibase-Rad

%% Analizzo i singoli Array e li riporto nel Report
for m = 1:rAR % creo una sottosezione per ciascuna catena
    % Cerco se alcune centraline (e i relativi Array) sono scaduti
    IDcentralina = char(chainID(m,2)); % Centralina dell'Array in analisi
    [rCU,~] = size(chainID);
    for indCU = 1:rCU
        if strcmp(char(unitID(indCU,2)),IDcentralina) == 1
            u = indCU;
            break
        end
    end
    if IDscaduta(u,1) == 1
        escludi = 1;
        IDcentralina = char(chainID(m,2));
        DTcatena = char(chainID(m,4));
        DT = Section();
        app = Heading2(strcat(IDcentralina, '-', DTcatena));
        app.Style = {OuterMargin('0in','0in','0.2in','0.2in'),FontSize(Font_section),HAlign('justify')}; % Sx-Dx-Alto-Basso
        DT.Title = app;
    else
        escludi = 0;
    end
    if escludi == 0
        battANALOG = 0; % indicatore per riportare batteria GMUX una sola volta per catena
        toolrif = chainID(m,4);
        DTcatena = char(toolrif);
        toolrifID = chainID(m,3);
        ID801 = chainID(m,1);
        comando = ['select prod_date from tools where unit_ID like ''' num2str(cell2mat(ID801)) ''' and name like ''' char(toolrif) ''' '];
        curs = exec(conn,comando);
        curs = fetch(curs);
        data_ini = curs.Data;
        stringa = cell2mat(data_ini);
        [~,cst] = size(stringa);
        if cst > 10
            date = stringa(1,1:10);
            time = stringa(1,11:21);
            dataora_sito(1,1) = cellstr(date);
            dataora_sito(1,2) = cellstr(time);
            datasito = [cell2mat(dataora_sito(1,1)) repmat(' ', [1,1]) cell2mat(dataora_sito(1,2))]; % Data definita sul sito
            if datenum(datasito) > datenum(datarif)
                datarif = datestr(datenum(datasito),'yyyy-mm-dd');
            end
        end
        for ind = 1:rAR
            if strcmp(chainID(ind,4),cellstr(toolrif)) == 1
                unitrif = char(chainID(ind,2));
                break
            else
            end
        end
        DT = Section();
        app = Heading2(char(strcat(unitrif, '-', toolrif)));
        app.Style = {OuterMargin('0in','0in','0.2in','0.2in'),FontSize(Font_section),HAlign('justify')}; % Sx-Dx-Alto-Basso
        DT.Title = app;
        if activeEN == 1
            DT_ENG = Section();
            app_ENG = Heading2(char(strcat(unitrif, '-', toolrif)));
            app_ENG.Style = {OuterMargin('0in','0in','0.2in','0.2in'),FontSize(Font_section),HAlign('justify')}; % Sx-Dx-Alto-Basso
            DT_ENG.Title = app_ENG;
        else
            DT_ENG = [];
        end
        ATTIVA = 1;
        
        %% TILT LINK V
        if rTL(m,1) > 0
            [GI_MaxDispMESE,GI_DateTL,GI_MaxDispProf,ATTIVA,FIG,FIG_ENG] = report_TL(...
                rTL,rTLHR,m,NodoTiltLink,toolrif,unitrif,datarif,firstdata_num,...
                Font_caption,Font_tools,siteID,toolrifID,DT,DT_ENG,FIG,FIG_ENG,br,...
                colonna2,colonna2bis,status,ATTIVA,activeEN,conn,FileName);
            [rControl_1,~] = size(GI_MaxDispMESE);
            [rControl_2,~] = size(GI_Disp_TL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Disp_TL
                    clear GI_Prof_TL
                    clear GI_Date_TL
                    GI_Disp_TL(:,m) = GI_MaxDispMESE;
                    GI_Prof_TL(1,m) = GI_MaxDispProf;
                    GI_Date_TL(:,m) = GI_DateTL;
                elseif rControl_1 == 0
                    GI_Disp_TL(1,m) = 0;
                    GI_Prof_TL(1,m) = 0;
                    GI_Date_TL(1,m) = 0;
                else
                    GI_Disp_TL(1:rControl_1,m) = GI_MaxDispMESE;
                    GI_Prof_TL(1,m) = GI_MaxDispProf;
                    GI_Date_TL(1:rControl_1,m) = GI_DateTL;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Disp_TL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Disp_TL(1:rControl_1,m) = GI_MaxDispMESE;
                    GI_Disp_TL(1:rControl_2,1:cBck) = BackUp;
                    GI_Prof_TL(1,m) = GI_MaxDispProf;
                    BackUp = GI_Date_TL (1:rControl_2,:);
                    GI_Date_TL(1:rControl_1,m) = GI_DateTL;
                    GI_Date_TL(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% TILT LINK H
        if rTLH(m,1) > 0
            wip = Paragraph('Sezione non ancora disponibile per dati del Tilt Link H');
            add(DT,wip);
            if activeEN == 1
                wip = Paragraph('Section for Tilt Link H is not yet available.');
                add(DT_ENG,wip);
            end
        end
        
        %% IN PLACE LINK
        if rIPL(m,1) > 0
           [GI_MaxDispMESE,GI_DateIPL,GI_MaxDispProf,ATTIVA,FIG,FIG_ENG] = report_IPL(...
               rIPL,rIPLHR,m,NodoInPlaceLink,toolrif,unitrif,datarif,firstdata_num,Font_caption,...
               Font_tools,siteID,toolrifID,DT,DT_ENG,FIG,FIG_ENG,br,colonna2,colonna2bis,status,...
               ATTIVA,activeEN,conn,FileName);
            [rControl_1,~] = size(GI_MaxDispMESE);
            [rControl_2,~] = size(GI_Disp_IPL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Disp_IPL
                    clear GI_Prof_IPL
                    clear GI_Date_IPL
                    GI_Disp_IPL(:,m) = GI_MaxDispMESE;
                    GI_Prof_IPL(:,m) = GI_MaxDispProf;
                    GI_Date_IPL(:,m) = GI_DateIPL;
                elseif rControl_1 == 0
                    GI_Disp_IPL(1,m) = 0;
                    GI_Prof_IPL(1,m) = 0;
                    GI_Date_IPL(1,m) = 0;
                else
                    GI_Disp_IPL(1:rControl_1,m) = GI_MaxDispMESE;
                    GI_Prof_IPL(1:rControl_1,m) = GI_MaxDispProf;
                    GI_Date_IPL(1:rControl_1,m) = GI_DateIPL;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Disp_IPL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Disp_IPL(1:rControl_1,m) = GI_MaxDispMESE;
                    GI_Disp_IPL(1:rControl_2,1:cBck) = BackUp;
                    GI_Prof_IPL(1,m) = GI_MaxDispProf;
                    BackUp = GI_Date_IPL(1:rControl_2,:);
                    GI_Date_IPL(1:rControl_1,m) = GI_DateIPL;
                    GI_Date_IPL(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% IN PLACE LINK HR
        if rIPL(m,1) == 0 && rIPLHR(m,1) > 0
            [GI_MaxDispMESE,GI_DateIPLHR,GI_MaxDispProf,ATTIVA,FIG,FIG_ENG] = report_IPLHR(...
                rIPLHR,m,NodoInPlaceLinkHR,toolrif,unitrif,datarif,firstdata_num,Font_caption,...
                Font_tools,siteID,toolrifID,DT,DT_ENG,FIG,FIG_ENG,br,colonna2,colonna2bis,status,...
                ATTIVA,activeEN,conn,FileName);
            [rControl_1,~] = size(GI_MaxDispMESE);
            [rControl_2,~] = size(GI_Disp_IPLHR);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Disp_IPLHR
                    clear GI_Prof_IPLHR
                    clear GI_Date_IPLHR
                    GI_Disp_IPLHR(:,m) = GI_MaxDispMESE;
                    GI_Prof_IPLHR(:,m) = GI_MaxDispProf;
                    GI_Date_IPLHR(:,m) = GI_DateIPLHR;
                elseif rControl_1 == 0
                    GI_Disp_IPLHR(1,m) = 0;
                    GI_Prof_IPLHR(1,m) = 0;
                    GI_Date_IPLHR(1,m) = 0;
                else
                    GI_Disp_IPLHR(1:rControl_1,m) = GI_MaxDispMESE;
                    GI_Prof_IPLHR(1:rControl_1,m) = GI_MaxDispProf;
                    GI_Date_IPLHR(1:rControl_1,m) = GI_DateIPLHR;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Disp_IPLHR(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Disp_IPLHR(1:rControl_1,m) = GI_MaxDispMESE;
                    GI_Disp_IPLHR(1:rControl_2,1:cBck) = BackUp;
                    GI_Prof_IPLHR(1,m) = GI_MaxDispProf;
                    BackUp = GI_Date_IPLHR(1:rControl_2,:);
                    GI_Date_IPLHR(1:rControl_1,m) = GI_DateIPLHR;
                    GI_Date_IPLHR(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% PIEZO LINK
        if rPL(m,1) > 0
            [GI_LivelloFaldaPL,GI_ProfPL,GI_DatePL,PL_A,PL_D,ATTIVA,FIG,FIG_ENG] = report_PL(...
                rPL,rTL,rIPL,m,NodoPiezoLink,PL_A,PL_D,toolrif,unitrif,datarif,Font_caption,...
                Font_tools,toolrifID,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,activeEN,conn,FileName);
            [rControl_1,~] = size(GI_LivelloFaldaPL);
            [rControl_2,~] = size(GI_Level_PL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Level_PL
                    clear GI_Prof_PL
                    clear GI_Date_PL
                    GI_Level_PL(:,m) = GI_LivelloFaldaPL;
                    GI_Prof_PL(1,m) = GI_ProfPL;
                    GI_Date_PL(:,m) = GI_DatePL;
                elseif rControl_1 == 0
                    GI_Level_PL(1,m) = 0;
                    GI_Prof_PL(1,m) = 0;
                    GI_Date_PL(1,m) = 0;
                else
                    GI_Level_PL(1:rControl_1,m) = GI_LivelloFaldaPL(:,1);
                    GI_Prof_PL(1:rControl_1,m) = GI_ProfPL(:,1);
                    GI_Date_PL(1:rControl_1,m) = GI_DatePL(:,1);
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Level_PL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Level_PL(1:rControl_1,m) = GI_LivelloFaldaPL;
                    GI_Level_PL(1:rControl_2,1:cBck) = BackUp;
                    GI_Prof_PL(1,m) = GI_ProfPL;
                    BackUp = GI_Date_PL(1:rControl_2,:);
                    GI_Date_PL(1:rControl_1,m) = GI_DatePL;
                    GI_Date_PL(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% BARO LINK
        if rBL(m,1) > 0
            [ATTIVA,FIG,FIG_ENG] = report_BL(rBL,m,NodoBaroLink,toolrif,unitrif,datarif,...
                Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,activeEN,...
                conn,FileName);
        end
        
        %% LOAD LINK
        if rLL(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_LL(rLL,m,NodoLoadLink,toolrif,...
                unitrif,datarif,contunit,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,...
                br,colonna4,status,ATTIVA,battANALOG,activeEN,conn,FileName);
        end
        
        %% PRESSURE LINK
        if rPrL(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_PrL(rPrL,m,NodoPressureLink,toolrif,...
                unitrif,datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,...
                battANALOG,activeEN,conn,FileName);
        end
        
        %% KLINO LINK
        if rKL(m,1) > 0
            [GI_AngoloKL,GI_NumKL,GI_DateKL,ATTIVA,FIG,FIG_ENG] = report_KL(rKL,m,...
                NodoKlinoLink,toolrif,unitrif,datarif,contunit,Font_caption,Font_tools,...
                siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,activeEN,colonna4,conn,FileName);
            [rControl_1,~] = size(GI_AngoloKL);
            [rControl_2,~] = size(GI_Angolo_KL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Angolo_KL
                    clear GI_Num_KL
                    clear GI_Date_KL
                    GI_Angolo_KL(:,kl:kl+1) = GI_AngoloKL;
                    GI_Num_KL(1,m) = GI_NumKL;
                    GI_Date_KL(:,m) = GI_DateKL;
                    kl = kl+2;
                elseif rControl_1 == 0
                    GI_Angolo_KL(1,kl:kl+1) = 0;
                    GI_Num_KL(1,m) = 0;
                    GI_Date_KL(1,m) = 0;
                    kl = kl+2;
                else
                    GI_Angolo_KL(1:rControl_1,kl:kl+1) = GI_AngoloKL;
                    GI_Num_KL(1:rControl_1,m) = GI_NumKL;
                    GI_Date_KL(1:rControl_1,m) = GI_DateKL;
                    kl = kl+2;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Angolo_KL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Angolo_KL(1:rControl_1,kl:kl+1) = GI_AngoloKL;
                    GI_Angolo_KL(1:rControl_2,1:cBck) = BackUp;
                    kl = kl+2;
                    GI_Num_KL(1,m) = GI_NumKL;
                    BackUp = GI_Date_KL (1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Date_KL(1:rControl_1,m) = GI_DateKL;
                    GI_Date_KL(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% KLINO LINK HR
        if rKLHR(m,1) > 0
            if yesKLHR3D(m,1) == 0
                [ATTIVA,FIG,FIG_ENG] = report_KLHR(rKLHR,m,NodoKlinoLinkHR,toolrif,unitrif,...
                    datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,...
                    activeEN,conn,FileName);  
            end
        end
        
        %% THERM LINK
        if rThL(m,1) > 0
            [ATTIVA,FIG,FIG_ENG] = report_ThL(rThL,m,NodoThermLink,toolrif,...
                unitrif,datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,...
                activeEN,br,status,ATTIVA,conn,FileName);
        end
        
        %% PT100 LINK
        if rPT100(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_PT100(rPT100,m,NodoPT100Link,...
                toolrif,unitrif,datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,...
                battANALOG,ATTIVA,activeEN,contunit,br,status,conn,FileName);
        end
        
        %% TUNNEL LINK
        if rTuL(m,1) > 0
           [GI_Cir_Q1,GI_Cir_Q2,GI_Cir_Q3,GI_Cir_Q4,GI_Cir_Q1_Num,GI_Cir_Q2_Num,...
               GI_Cir_Q3_Num,GI_Cir_Q4_Num,GI_Cir_Seg,GI_Cir_Z,GI_Cir_Date,GI_TuL_RL,...
               ATTIVA,FIG,FIG_ENG] = report_TuL(IDcentralina,DTcatena,rTuL,m,NodoTunnelLink,toolrif,...
               unitrif,datarif,firstdata_num,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,...
               colonna2,colonna2bis,status,ATTIVA,activeEN,conn,FileName);
            [rControl_1,~] = size(GI_Cir_Date);
            [rControl_2,~] = size(GI_Date_TuL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Q1_TuL
                    clear GI_Q2_TuL
                    clear GI_Q3_TuL
                    clear GI_Q4_TuL
                    clear GI_Q1_Num_TuL
                    clear GI_Q2_Num_TuL
                    clear GI_Q3_Num_TuL
                    clear GI_Q4_Num_TuL
                    clear GI_Date_TuL
                    clear GI_Seg_TuL
                    GI_Q1_TuL(:,m) = GI_Cir_Q1;
                    GI_Q2_TuL(:,m) = GI_Cir_Q2;
                    GI_Q3_TuL(:,m) = GI_Cir_Q3;
                    GI_Q4_TuL(:,m) = GI_Cir_Q4;
                    GI_Q1_Num_TuL(:,m) = GI_Cir_Q1_Num;
                    GI_Q2_Num_TuL(:,m) = GI_Cir_Q2_Num;
                    GI_Q3_Num_TuL(:,m) = GI_Cir_Q3_Num;
                    GI_Q4_Num_TuL(:,m) = GI_Cir_Q4_Num;
                    GI_Date_TuL(:,m) = GI_Cir_Date;
                    [~,num_s] = size(GI_Cir_Seg);
                    GI_Seg_TuL(1,s:s+num_s-1) = GI_Cir_Seg;
                    s = s+num_s;
                    GI_NumSeg_TuL(m,1) = num_s;
                    if isempty(GI_Cir_Z) == 0
                        clear GI_Z_TuL
                        [~,num_T] = size(GI_Cir_Z);
                        GI_Z_TuL(:,TP:TP+num_T-1) = GI_Cir_Z;
                        TP = TP+num_T;
                    end
                    if isempty(GI_TuL_RL) == 0
                        clear GI_dS_TuL_RL
                        [~,num_TR] = size(GI_TuL_RL);
                        GI_dS_TuL_RL(:,TR:TR+num_TR-1) = GI_TuL_RL;
                        TR = TR+num_TR;
                    end
                elseif rControl_1 == 0
                    GI_Q1_TuL(1,m) = 0;
                    GI_Q2_TuL(1,m) = 0;
                    GI_Q3_TuL(1,m) = 0;
                    GI_Q4_TuL(1,m) = 0;
                    GI_Q1_Num_TuL(1,m) = 0;
                    GI_Q2_Num_TuL(1,m) = 0;
                    GI_Q3_Num_TuL(1,m) = 0;
                    GI_Q4_Num_TuL(1,m) = 0;
                    GI_Date_TuL(1:rControl_1,m) = 0;
                    GI_NumSeg_TuL(m,1) = 0;
                else
                    GI_Q1_TuL(1,m) = GI_Cir_Q1;
                    GI_Q2_TuL(1,m) = GI_Cir_Q2;
                    GI_Q3_TuL(1,m) = GI_Cir_Q3;
                    GI_Q4_TuL(1,m) = GI_Cir_Q4;
                    GI_Q1_Num_TuL(1,m) = GI_Cir_Q1_Num;
                    GI_Q2_Num_TuL(1,m) = GI_Cir_Q2_Num;
                    GI_Q3_Num_TuL(1,m) = GI_Cir_Q3_Num;
                    GI_Q4_Num_TuL(1,m) = GI_Cir_Q4_Num;
                    GI_Date_TuL(1:rControl_1,m) = GI_Cir_Date;
                    [~,num_s] = size(GI_Cir_Seg);
                    GI_Seg_TuL(1,s:s+num_s-1) = GI_Cir_Seg;
                    s = s+num_s;
                    GI_NumSeg_TuL(m,1) = num_s;
                    if isempty(GI_Cir_Z) == 0
                        [~,num_T] = size(GI_Cir_Z);
                        GI_Z_TuL(1:rControl_1,TP:TP+num_T-1) = GI_Cir_Z;
                        TP = TP+num_T;
                    end
                    if isempty(GI_TuL_RL) == 0
                        [~,num_TR] = size(GI_TuL_RL);
                        GI_dS_TuL_RL(1:rControl_1,TR:TR+num_TR-1) = GI_TuL_RL;
                        TR = TR+num_TR;
                    end
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    GI_Q1_TuL(1,m) = GI_Cir_Q1;
                    GI_Q2_TuL(1,m) = GI_Cir_Q2;
                    GI_Q3_TuL(1,m) = GI_Cir_Q3;
                    GI_Q4_TuL(1,m) = GI_Cir_Q4;
                    GI_Q1_Num_TuL(1,m) = GI_Cir_Q1_Num;
                    GI_Q2_Num_TuL(1,m) = GI_Cir_Q2_Num;
                    GI_Q3_Num_TuL(1,m) = GI_Cir_Q3_Num;
                    GI_Q4_Num_TuL(1,m) = GI_Cir_Q4_Num;
                    BackUp = GI_Date_TuL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Date_TuL(1:rControl_1,m) = GI_Cir_Date;
                    GI_Date_TuL(1:rControl_2,1:cBck) = BackUp;
                    [~,num_s] = size(GI_Cir_Seg);
                    GI_Seg_TuL(1,s:s+num_s-1) = GI_Cir_Seg;
                    GI_NumSeg_TuL(m,1) = num_s;
                    s = s+num_s;
                    if isempty(GI_Cir_Z) == 0
                        BackUp = GI_Z_TuL(1:rControl_2,:);
                        [~,cBck] = size(BackUp);
                        [~,num_T] = size(GI_Cir_Z);
                        GI_Z_TuL(1:rControl_1,TP:TP+num_T-1) = GI_Cir_Z;
                        TP = TP+num_T;
                        GI_Z_TuL(1:rControl_2,1:cBck) = BackUp;
                    end
                    if isempty(GI_TuL_RL) == 0
                        BackUp = GI_dS_TuL_RL(1:rControl_2,:);
                        [~,cBck] = size(BackUp);
                        [~,num_TR] = size(GI_TuL_RL);
                        GI_dS_TuL_RL(1:rControl_1,TR:TR+num_TR-1) = GI_TuL_RL;
                        GI_dS_TuL_RL(1:rControl_2,1:cBck) = BackUp;
                        TR = TR+num_TR;
                    end
                end
            end
        end
        
        %% RADIAL LINK
        if rRaL(m,1) > 0
            [GI_Rad_XYZ,GI_Rad_Num,GI_Rad_MPBEL,GI_Rad_Cir,GI_Rad_Date,ATTIVA,FIG,FIG_ENG] = report_RaL(...
                DTcatena,rRaL,m,NodoRadialLink,toolrif,unitrif,datarif,firstdata_num,Font_caption,...
                Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,colonna2,colonna2bis,status,ATTIVA,activeEN,...
                conn,FileName);
            [rControl_1,~] = size(GI_Rad_Date);
            [rControl_2,~] = size(GI_Date_Rad);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_XYZ_Rad
                    clear GI_Num_Rad
                    clear GI_Date_Rad
                    GI_XYZ_Rad(:,m) = GI_Rad_XYZ;
                    GI_Num_Rad(:,m) = GI_Rad_Num;
                    if isempty(GI_Rad_MPBEL) == 0
                        clear GI_dS_RL_MPB
                        GI_dS_RL_MPB(:,m) = GI_Rad_MPBEL;
                    else
                        GI_dS_RL_MPB(:,m) = 0;
                    end
                    if isempty(GI_Rad_Cir) == 0
                        clear GI_dS_RL_TuL
                        GI_dS_RL_TuL(:,m) = GI_Rad_Cir;
                    else
                        GI_dS_RL_TuL(:,m) = 0;
                    end
                    GI_Date_Rad(:,m) = GI_Rad_Date;
                elseif rControl_1 == 0
                    GI_XYZ_Rad(:,m) = 0;
                    GI_Num_Rad(:,m) = 0;
                    GI_Date_Rad(:,m) = 0;
                else
                    GI_XYZ_Rad(1,m) = GI_Rad_XYZ;
                    GI_Num_Rad(1,m) = GI_Rad_Num;
                    if isempty(GI_Rad_MPBEL) == 0
                        GI_dS_RL_MPB(1:rControl_1,m) = GI_Rad_MPBEL;
                    else
                        GI_dS_RL_MPB(1:rControl_1,m) = 0;
                    end
                    if isempty(GI_Rad_Cir) == 0
                        GI_dS_RL_TuL(1:rControl_1,m) = GI_Rad_Cir;
                    else
                        GI_dS_RL_TuL(1:rControl_1,m) = 0;
                    end
                    GI_Date_Rad(1:rControl_1,m) = GI_Rad_Date;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    GI_XYZ_Rad(1,m) = GI_Rad_XYZ;
                    GI_Num_Rad(1,m) = GI_Rad_Num;
                    BackUp = GI_dS_RL_MPB(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    if isempty(GI_Rad_MPBEL) == 0
                        GI_dS_RL_MPB(1:rControl_1,m) = GI_Rad_MPBEL;
                        GI_dS_RL_MPB(1:rControl_2,1:cBck) = BackUp;
                    else
                        GI_dS_RL_MPB(:,m) = 0;
                    end
                    BackUp = GI_dS_RL_TuL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    if isempty(GI_Rad_Cir) == 0
                        GI_dS_RL_TuL(1:rControl_1,m) = GI_Rad_Cir;
                        GI_dS_RL_TuL(1:rControl_2,1:cBck) = BackUp;
                    else
                        GI_dS_RL_TuL(:,m) = 0;
                    end
                    BackUp = GI_Date_Rad(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Date_Rad(1:rControl_1,m) = GI_Rad_Date;
                    GI_Date_Rad(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% PRECONV LINK
        if rPCL(m,1) > 0
            [GI_PCL_Z,GI_PCL_Date,ATTIVA,FIG,FIG_ENG] = report_PCL(DTcatena,rPCL,m,NodoPreConvLink,...
                toolrif,unitrif,datarif,firstdata_num,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,...
                colonna2,colonna2bis,status,ATTIVA,activeEN,conn,FileName);
            [rControl_1,~] = size(GI_PCL_Date);
            [rControl_2,~] = size(GI_Date_PCL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Date_PCL;
                    GI_Date_PCL = GI_PCL_Date;
                    if isempty(GI_PCL_Z) == 0
                        clear GI_Z_PCL;
                        GI_Z_PCL(:,m) = GI_PCL_Z;
                    end
                else
                    GI_Date_PCL(1:rControl_1,m) = GI_PCL_Date;
                    if isempty(GI_PCL_Z) == 0
                        GI_Z_PCL(1:rControl_1,m) = GI_PCL_Z;
                    end
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Date_PCL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Date_PCL(1:rControl_1,m) = GI_PCL_Date;
                    GI_Date_PCL(1:rControl_2,1:cBck) = BackUp;
                    if isempty(GI_PCL_Z) == 0
                        BackUp = GI_Z_PCL(1:rControl_2,:);
                        [~,cBck] = size(BackUp);
                        GI_Z_PCL(1:rControl_1,m) = GI_PCL_Z;
                        GI_Z_PCL(1:rControl_2,1:cBck) = BackUp;
                    end
                end
            end
        end
        
        %% RAIN LINK
        if rRL(m,1) > 0
            [GI_rainloc,GI_DateRL,ATTIVA,FIG,FIG_ENG] = report_RL(rRL,m,NodoRainLink,toolrif,...
                unitrif,datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,...
                activeEN,conn,FileName);
            [rControl_1,~] = size(GI_DateRL);
            [rControl_2,~] = size(GI_Date_RL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Date_RL;
                    GI_Date_RL = GI_DateRL;
                    clear GI_Rain_RL;
                    GI_Rain_RL = GI_rainloc;
                else
                    GI_Date_RL(1:rControl_1,m) = GI_DateRL;
                    GI_Rain_RL(1:rControl_1,m) = GI_rainloc;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Date_RL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Date_RL(1:rControl_1,m) = GI_DateRL;
                    GI_Date_RL(1:rControl_2,1:cBck) = BackUp;
                    BackUp = GI_Rain_RL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    GI_Rain_RL(1:rControl_1,m) = GI_rainloc;
                    GI_Rain_RL(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% EXTENSOMETER LINK
        if rEL(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_EL(rEL,m,NodoExtensometerLink,toolrif,...
                unitrif,contunit,datarif,Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,...
                DT_ENG,FIG,FIG_ENG,activeEN,br,status,conn,FileName);
        end
        
        %% 3D EXTENSOMETER LINK
        if r3DEL(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_3DEL(r3DEL,m,Nodo3DExtensometerLink,toolrif,...
                unitrif,contunit,datarif,Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,DT_ENG,...
                FIG,FIG_ENG,activeEN,br,status,conn,FileName);
        end
        
        %% WIRE EXTENSOMETER LINK
        if rWEL(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_WEL(rWEL,m,NodoWireExtensometerLink,toolrif,...
                unitrif,contunit,datarif,Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,DT_ENG,...
                FIG,FIG_ENG,br,activeEN,status,conn,FileName);
        end
        
        %% MULTI POINT BOREHOLE LINK
        if rMPBEL(m,1) > 0
            [GI_MPB_RL,GI_MPB,GI_Base,GI_Date,FIG,FIG_ENG,battANALOG,ATTIVA] = report_MPBEL(DTcatena,...
                rMPBEL,m,NodoMultiPointExtensometerLink,toolrif,unitrif,contunit,datarif,...
                Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,DT_ENG,FIG,FIG_ENG,br,...
                activeEN,status,conn,FileName);
            [rControl_1,~] = size(GI_Date);
            [rControl_2,~] = size(GI_Date_MPB);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    GI_Date_MPB(:,m) = GI_Date(:,1);
                    GI_dS_MPB = GI_MPB;
                    GI_MPB_Base = GI_Base;
                    [~,num_M] = size(GI_MPB_RL);
                    GI_dS_MPB_RL(:,MR:MR+num_M-1) = GI_MPB_RL;
                    MR = MR+num_M;
                elseif rControl_1 == 0
                    GI_Date_MPB(:,m) = 0;
                    GI_dS_MPB(:,m) = 0;
                    GI_MPB_Base(:,m) = 0;
                else
                    Num_Basi = rMPBEL(m);
                    BackUp = GI_Date_MPB;
                    [~,cBck] = size(BackUp);
                    GI_Date_MPB(1:rControl_1,m) = GI_Date(:,1);
                    GI_dS_MPB(1:rControl_1,cBck+1:cBck+Num_Basi) = GI_MPB;
                    GI_MPB_Base(1,cBck+1:cBck+Num_Basi) = GI_Base;
                    [~,num_M] = size(GI_MPB_RL);
                    GI_dS_MPB_RL(1:rControl_1,MR:MR+num_M-1) = GI_MPB_RL;
                    MR = MR+num_M;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    BackUp = GI_Date_MPB(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    clear GI_Date_MPB
                    Num_Basi = rMPBEL(m);
                    GI_Date_MPB(1:rControl_1,m) = GI_Date(:,1);
                    GI_Date_MPB(1:rControl_2,1:cBck) = BackUp;
                    BackUp = GI_dS_MPB(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    clear GI_dS_MPB
                    GI_dS_MPB(1:rControl_1,cBck+1:cBck+Num_Basi) = GI_MPB;
                    GI_dS_MPB(1:rControl_2,1:cBck) = BackUp;
                    BackUp = GI_MPB_Base(1,:);
                    [~,cBck] = size(BackUp);
                    GI_MPB_Base(1,cBck+1:cBck+Num_Basi) = GI_Base;
                    BackUp = GI_dS_MPB_RL(1:rControl_2,:);
                    [~,cBck] = size(BackUp);
                    clear GI_dS_MPB_RL
                    [~,num_M] = size(GI_MPB_RL);
                    GI_dS_MPB_RL(1:rControl_1,MR:MR+num_M-1) = GI_MPB_RL;
                    GI_dS_MPB_RL(1:rControl_2,1:cBck) = BackUp;
                    MR = MR+num_M;
                end
            end
        end
        
        %% CRACK LINK
        if rCrL(m,1) > 0
            [GI_DispCrL,GI_NumCrL,GI_DateCrL,battANALOG,ATTIVA,FIG,FIG_ENG] = report_CrL(rCrL,...
                m,NodoCrackLink,toolrif,unitrif,contunit,datarif,Font_caption,...
                Font_tools,battANALOG,ATTIVA,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,...
                activeEN,conn,FileName);
            [rControl_1,~] = size(GI_DispCrL);
            [rControl_2,~] = size(GI_Disp_CrL);
            if rControl_1 <= rControl_2 || rControl_2 == 0
                if rControl_1 ~= 0 && rControl_2 == 0
                    clear GI_Disp_CrL
                    clear GI_Num_CrL
                    clear GI_Date_CrL
                    GI_Disp_CrL(:,m) = GI_DispCrL;
                    GI_Num_CrL(:,m) = GI_NumCrL;
                    GI_Date_CrL(:,m) = GI_DateCrL;
                elseif rControl_1 == 0
                       GI_Disp_CrL(:,m) = 0;
                       GI_Num_CrL(:,m) = 0;
                       GI_Date_CrL(:,m) = 0;
                else
                    GI_Disp_CrL(1:rControl_1,m) = GI_DispCrL;
                    GI_Num_CrL(1:rControl_1,m) = GI_NumCrL;
                    GI_Date_CrL(1:rControl_1,m) = GI_DateCrL;
                end
            else
                if rControl_2 ~= 0
                    clear BackUp
                    [~,cBck] = size(BackUp);
                    BackUp = GI_Disp_CrL(1:rControl_2,:);
                    GI_Disp_CrL(1:rControl_1,m) = GI_DispCrL;
                    GI_Disp_CrL(1:rControl_2,1:cBck) = BackUp;
                    BackUp = GI_Num_CrL(1:rControl_2,:);
                    GI_Num_CrL(1:rControl_1,m) = GI_NumCrL;
                    GI_Num_CrL(1:rControl_2,1:cBck) = BackUp;
                    BackUp = GI_Date_CrL (1:rControl_2,:);
                    GI_Date_CrL(1:rControl_1,m) = GI_DateCrL;
                    GI_Date_CrL(1:rControl_2,1:cBck) = BackUp;
                end
            end
        end
        
        %% 2D CRACK LINK
        if r2DCrL(m,1) > 0
            [battANALOG,ATTIVA,FIG,FIG_ENG] = report_2DCrL(r2DCrL,m,Nodo2DCrackLink,toolrif,...
                unitrif,contunit,datarif,Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,DT_ENG,...
                FIG,FIG_ENG,br,status,activeEN,conn,FileName);
        end
        
        %% 3D CRACK LINK
        if r3DCrL(m,1) > 0
            [battANALOG,ATTIVA,FIG,FIG_ENG] = report_3DCrL(r3DCrL,m,Nodo3DCrackLink,toolrif,...
                unitrif,contunit,datarif,Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,DT_ENG,...
                FIG,FIG_ENG,br,status,activeEN,conn,FileName);
        end
        
        %% RSN LINK
        if rRSN(m,1) > 0
            [ATTIVA,FIG,FIG_ENG] = report_RSN(rRSN,m,NodoRSNLink,toolrif,unitrif,datarif,...
                Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,activeEN,conn,FileName);
        end
        
        %% RSN LINK HR
        if rRSNHR(m,1) > 0
            [ATTIVA,FIG,FIG_ENG] = report_RSNHR(rRSNHR,m,NodoRSNHRLink,toolrif,unitrif,...
                datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,activeEN,conn,FileName);
        end
        
        %% TRIGGER SYSTEM
        if rTrL(m,1) > 0
            ATTIVA = report_TrL(NodoTriggerLink,rTrL,m,Font_tools,br,datarif,toolrif,...
                unitrif,DT,DT_ENG,activeEN,status,ATTIVA,conn,FileName);
        end
        
        %% G-Flow SYSTEM
        if rGF(m,1) > 0
            sezGflow = Paragraph('G-Flow Link');
            sezGflow.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            GF = Section();
            GF.Title = sezGflow;
            add(DT,sezGflow);
            if activeEN == 1
                add(DT_ENG,sezGflow);
            end
        
            wip = Paragraph('Sezione non ancora disponibile per dati del G-Flow');
            add(DT,wip);
            if activeEN == 1
                wip = Paragraph('Section for G-Flow is not yet available.');
                add(DT_ENG,wip);
            end
        end
        
        %% G-Shock SYSTEM
        if rGS(m,1) > 0
            sezGshock = Paragraph('G-Shock Link');
            sezGshock.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            GS = Section();
            GS.Title = sezGshock;
            add(DT,sezGshock);
            if activeEN == 1
                add(DT_ENG,sezGshock);
            end
        
            wip = Paragraph('Sezione non ancora disponibile per dati del G-Shock');
            add(DT,wip);
            if activeEN == 1
                wip = Paragraph('Section for G-Shock is not yet available.');
                add(DT_ENG,wip);
            end
        end
        
        %% Weir Link
        if rWL(m,1) > 0
            [FIG,FIG_ENG,battANALOG,ATTIVA] = report_WL(rWL,m,NodoWeirLink,toolrif,...
                unitrif,contunit,datarif,Font_caption,Font_tools,battANALOG,ATTIVA,siteID,DT,...
                DT_ENG,FIG,FIG_ENG,activeEN,br,status,conn,FileName);
        end
        
        %% Pendulum
        if rPE(m,1) > 0
            [battANALOG,ATTIVA,FIG,FIG_ENG] = report_PE(rPE,m,NodoPendulum,toolrif,unitrif,...
                datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,battANALOG,ATTIVA,...
                activeEN,conn,FileName);
        end
        
        %% MUSA
        if strcmp(tipoarray(m),'MUSA') == 1 % la catena è un MUSA
            sezMusa = Paragraph('Musa');
            sezMusa.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            MU = Section();
            MU.Title = sezMusa;
            add(DT,sezMusa);
            if activeEN == 1
                add(DT_ENG,sezMusa);
            end
            
            wip = Paragraph('Sezione non ancora disponibile per dati del sistema Musa');
            add(DT,wip);
            if activeEN == 1
                wip = Paragraph('Section for Musa is not yet available.');
                add(DT_ENG,wip);
            end
        end
        
        %% Grafici Integrati
        [Site,Site_ENG,FIG,FIG_ENG] = report_CrossGraphs(rTL,rIPL,rTuL,rRaL,...
            rPCL,rPL,rRL,rKL,rCrL,rMPBEL,GI_Disp_TL,GI_Date_TL,GI_Prof_TL,GI_Disp_IPL,...
            GI_Date_IPL,GI_Prof_IPL,GI_Level_PL,GI_Prof_PL,GI_Date_PL,GI_Rain_RL,GI_Date_RL,...
            GI_Angolo_KL,GI_Num_KL,GI_Date_KL,GI_Disp_CrL,GI_Num_CrL,GI_Date_CrL,GI_Q1_TuL,...
            GI_Q2_TuL,GI_Q3_TuL,GI_Q4_TuL,GI_Q1_Num_TuL,GI_Q2_Num_TuL,GI_Q3_Num_TuL,...
            GI_Q4_Num_TuL,GI_Z_TuL,GI_Seg_TuL,GI_NumSeg_TuL,GI_Date_TuL,GI_Z_PCL,GI_Date_PCL,...
            GI_XYZ_Rad,GI_Num_Rad,GI_dS_RL_MPB,GI_dS_RL_TuL,GI_dS_TuL_RL,GI_Date_Rad,...
            GI_Date_MPB,GI_dS_MPB,GI_MPB_Base,GI_dS_MPB_RL,siteID,toolrif,chainID,Font_Chapter,...
            Font_caption,Font_tools,m,rAR,br,FIG,FIG_ENG,DT,DT_ENG,activeEN,FileName);
        
        add(MUMS,DT);
        if activeEN == 1
            add(MUMS_ENG,DT_ENG);
        end
    else
        testo = Paragraph(['I dati dell''Array ' DTcatena ' letto dalla centralina '...
            IDcentralina ' non sono disponibili in quanto ' char(232) ' scaduto '...
            'l''abbonamento ai dati della stessa. I dati torneranno ad essere '...
            'disponibili non appena sar' char(224) ' rinnovato il canone annuo.']);
        testo.HAlign = 'justify';
        add(DT,testo);
        add(MUMS,DT);
        if activeEN == 1
        end
        Site = [];
        toolrifID = chainID(m,3);
        for p = 1:rPL(m,1)
            NodeNum = num2str(NodoPiezoLink(p,m));
            comando = ['select measurment from nodes where tool_id = ''' num2str(cell2mat(toolrifID))...
                ''' and num = ''' NodeNum ''' and nodetype_id = 2 '];
            curs = exec(conn,comando);
            curs = fetch(curs);
            Leggo = curs.Data;
            misuraPL(1,p) = Leggo(1,1); % unità di misura del piezometro
            % pressione assoluta vs relativa
            PL_A(p) = 0;
            PL_D(p) = 0;
            if strcmp(misuraPL(1,p),'VW kPa') == 1 || strcmp(misuraPL(1,p),'VW kg/cm2') == 1
                PL_A(p) = PL_A(p)+1;
            else
                PL_D(p) = PL_D(p)+1;
            end
        end
    end
end
add(rpt,MUMS);
add(rpt,Site);
template(rpt);
if activeEN == 1
    add(rpt_ENG,MUMS_ENG);
    add(rpt_ENG,Site_ENG);
    template(rpt_ENG);
end

fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'report_AR function executed correctly';
fprintf(fileID,fmt,text);
fclose(fileID);

end