
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% private_530_ROUTINE 
%
%
%		Ported to Matlab by Jason Lott, University of Alabama at Birmingham 2001
%		CONTACT:hoffa@uab.edu
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function a= private_530_ROUTINE(b)				

global X
global XMAX
global XMIN
global DELTX
global DELMIN
global ERR
global FOBJ
global VEC
global DLX
global XS
global FSTORE
global DX
global SALVO
global XOSC
global FOSC
global ARG
global STCUT
global ACK
global FACUP
global RZERO
global XPLUS
global FSAVE
global FBEST
global XSAVE
global ABSDX
global FPREV
global DENOM
global DEL
global DXZ
global DXU
global DFZ
global DFU
global ABSVEC
global SUMV
global CINDER
global COXCOM
global COSIN
global STEPS
global J
global JFLAT
global JFLMIN
global JOCK
global JUMP
global JVARY
global JX
global K
global KERFEL
global KL
global KW
global MASK
global MATRX
global MINSOC
global MAXOSC
global MAXSTP
global NACK
global NACTIV
global NAH
global NCIRC
global NEQUAL
global NF
global NFLAT
global NFMAX
global NFSAV
global NGATE
global NGIANT
global NONZER
global NOREP
global NOSC
global NOUT
global NRETRY
global NSSW
global NSTEPS
global NT
global NTRACE
global NV
global NEXTRA
global NZIP
global tag_380
global tag_390
global wtag
global tag
global continueflag
global T
global Y
global YSIG
global grandtag
global KFLAG
global DX
global DLX
global XS
global fortag
global KFLAGENCOUNTER


if NZIP<=0
   
   FSTORE(JX) = FBEST;
   
   if NF>NFMAX
      
      KFLAG = -2
      private_KFLAG_EXIT(KFLAG);
                                                                                         
   end
   
else
   
   NONZER=0;
   SUMV = RZERO;
                            
   for J=1:NV
      
      if VEC(J)~=RZERO
                              
         NONZER = NONZER+1;
         
      end
      
      SUMV = SUMV+VEC(J)^2;
      
   end
   
   if NONZER<2
      
      FSTORE(JX) = FBEST;
      
      if NF>NFMAX
         
         KFLAG = -2
         private_KFLAG_EXIT(KFLAG);
                                                                                                  
      end
      
   elseif (SUMV<=RZERO) | (MAXOSC<1)
     
      private_380_ROUTINE(1);									%argument is dummy; statement just executes a script
      
   else																%Picking up after IF SUMV<=RZERO/MAXOSC<1 statement above
      
      KL = 1;
      
      NOSC = NOSC +1;
      
      if NOSC<=MAXOSC
        
         private_290_ROUTINE(1);
         
      else
         
         NOSC = MAXOSC;
         
         if NOSC == 1
           
            private_290_ROUTINE(1);
            
         else
            
            for K=2:NOSC
               
               FOSC(K-1) = FOSC(K);
               
               for J=1:NV
                  
                  XOSC(J,K-1) = XOSC(J,K);
                  ERR(J,K-1) = ERR(J,K);
                                       
               end
               
            end
           
            private_290_ROUTINE(1);
            
         end
         
      end
      
   end
   
end
