Off[General::spell1]; 
Clear[Adpt,f0,a,b,M,tau]; 
Adpt[f0_,a_, b_,M_,tau_] :=
Module[{f, v,h,Delta,fa,fb,fc,fv,
           fz,fy,S,S1,S2,Sigma,c },
  Set@@{f[x_],f0};
  v = Table[0,{i,1,M+1},{j,1,6}];
  Delta= b - a; 
  Sigma=0;
  h = Delta /2;
  c = (a+b)/2;
  k =1; Cond=0;
  fa =N[f[a],digit]; fb = N[f[b],digit]; fc=N[f[c],digit];
  S= N[(fa+ 4 fc +fb)h/3,digit];
  v[[1]] = {a,h,fa,fc,fb,S};
  While[1 <=k && k<=M && Cond==0,
    h = v[[k,2]]/2;
    fy =N[ f[v[[k,1]]+h], digit];
    S1=N[(v[[k,3]]+4fy+v[[k,4]])*h/3,
       digit];
    fz=N[f[v[[k,1]]+3h],digit];
    S2=N[(v[[k,4]]+4fz+v[[k,5]])*h/3,
       digit];
      If[ N[Abs[S1+S2 -v[[k,6]]],
            digit] <= 30*tau*h /Delta,
        Sigma =N[Sigma+S1+S2+(S1+S2-
              v[[k,6]])/15, digit];
        k=k-1; 
        If[k ==0,Cond =1;Print[Sigma]],
      If[k == M,Cond =1;Print["Fail"]]; 
         fv=v[[k,5]];   
         v[[k]] = {v[[k,1]],h,v[[k,3]],
             fy,v[[k,4]],S1};
         k=k+1;
         v[[k]] = {v[[k-1,1]]+2h,h,
             v[[k-1,5]],fz,fv,S2};  
      ];  ]; ];  
 On[General::spell1];

Clear[digit];
digit=16;

Clear[f];
f[x_] = Exp[-x^2];

Adpt[f[x],0,1, 10 , 0.5*10^(-8)]

Adpt[f[x],0,1, 4, 0.5*10^(-8)]

N[NIntegrate[f[x],{x,0,1}],digit]

Clear[f];
f[x_] = x^(1/4);
Adpt[f[x],0,1,5, 0.5*10^(-8)]

N[NIntegrate[f[x],{x,0,1}],digit]

Off[General::spell1]; 
Clear[Adpt,f0,a,b,M,tau]; 
Adpt[f0_,a_, b_,M_,tau_] :=
Module[{f, v,h,Delta,fa,fb,fc,fv,fz,
        fy,S,S1,S2, Sigma,c },
  Set@@{f[x_],f0};
  v = Table[0,{i,1,M+1},{j,1,6}];
  Delta= b - a; 
  Sigma=0;
  h = Delta /2;
  c = (a+b)/2;
  k =1; Cond=0;
  fa =N[f[a],digit]; fb = N[f[b],digit]; fc=N[f[c],digit];
  S= N[(fa+ 4 fc +fb)h/3,digit];
  v[[1]] = {a,h,fa,fc,fb,S};
  While[1 <=k && k<=M && Cond==0,
    h = v[[k,2]]/2;
    fy =N[ f[v[[k,1]]+h], digit];
    S1=N[(v[[k,3]]+4fy +v[[k,4]])*h/3,
       digit];
    fz=N[f[v[[k,1]]+3h],digit];
    S2=N[(v[[k,4]]+4fz +v[[k,5]])*h/3,
       digit];
      If[ N[Abs[S1+S2 -v[[k,6]]],
         digit] <= 30*tau*h /Delta,
         Sigma =N[Sigma+S1+S2+(S1+S2-
            v[[k,6]])/15, digit];
      k=k-1; 
      If[k ==0,Cond =1;Print[Sigma] ],
      If[k == M,Cond =1; Print["Fail"]]; 
         fv=v[[k,5]];   
      v[[k]] = {v[[k,1]],h,v[[k,3]],
           fy,v[[k,4]],S1};
 Print[v[[k,1]]//N, " ",v[[k,1]]+h//N];  
         k=k+1;
      v[[k]] ={v[[k-1,1]]+2h,h,
           v[[k-1,5]],fz,fv,S2};  
 Print[v[[k,1]]//N, "  ",v[[k,1]]+h//N];  
      ];  ]; ];  
 On[General::spell1];

Clear[f];
f[x_] = Sqrt[x];

Adpt[f[x],0,1, 5 , 0.5*10^(-3)]