anchor.diff:      real(8) :: alfa,beta,c,cnorm,distsq,dsq,gamma, &
            mindelta,rhobeg,rhoend,sigm,sum,tau,tempofinal, &
            tempoinicial,fz,distz,qx,qz
  -
  -    IF ( OUTPUT ) WRITE(*,3000)
   
       ! -------------- !
       ! Initialization !
  
positive.code: 
    end subroutine trdfsolver
  
  
    ! ******************************************************************
    ! ******************************************************************
  
    ! ******************************************************************
    ! ******************************************************************
  
    ! ******************************************************************
    ! ******************************************************************
  
    ! ******************************************************************
    ! ******************************************************************
  
    ! ******************************************************************
    ! ******************************************************************
  
  
  
  
    SUBROUTINE TRDFSUB(N,NPT,X,XL,XU,M,EQUATN,LINEAR,CCODED,MAXFCNT, &
         RBEG,REND,XEPS,OUTPUT,NF,ALPHA,FFILTER,HFILTER,FILTERTEST,  &
         OUTITER,DELTA,EPSFEAS,F,FEAS,FCNT,RHO,FLAG)
  
      ! This subroutine is the implementation of the Derivative-free
      ! Trust-region algorithm for constrained optimization described in
      !
      !     P. D. Conejo, E. W. Karas, L. G. Pedroso, "A trust-region
      !     derivative-free algorithm for constrained optimization".
      !     Optimization Methods & Software, to appear, 2015.
      !
      ! For more information on configurations, recommended values of
      ! the parameters and examples, please read the documentation
      ! provided with the method.
      !
      !     The INPUT parameters are
      ! N - dimension of the problem
      !
      ! NPT - number of points used in the quadratic interpolation
      !
      ! X(N) - inital point
      !
      ! XL(N) - lower bounds on the variables
      !
      ! XU(N) - upper bounds on the variables
      !
      ! M - number of constraints
      !
      ! EQUATN(M) - a logical vector such that EQUATN(i) = .true. if and
      !             only if constraint 'i' is an equality constraint
      !
      ! LINEAR(M) - a logical vector such that LINEAR(i) = .true. if and
      !             only if constraint 'i' is a linear constraint
      !
      ! CCODED(2) - a logical vector indicating whether or not the
      !             Jacobian (CCODED(1)) and the Hessian (CCODED(2)) of
      !             the constraints are provided by the user
      !
      ! EVALF_ - the user-defined objective function
      !
      ! EVALC_ - the user-defined constraints
      !
      ! EVALJAC_ - the user-defined Jacobian of the constraints
      !
      ! EVALHC_ - the user defined Hessian of the constraints
      !
      ! MAXFCNT - maximum number of function evaluations
      !
      ! RBEG - initial value for the trust region radius and interpolation
      !
      ! REND - smallest trust-region radius for declaring convergence of
      !        the method
      !
      ! XEPS - feasibility/optimality tolerance for solving the subproblems
      !
      ! OUTPUT - a logical variable indicating if the method has or has not
      !          to display information
      !
      ! The OUTPUT parameters are
      !
      ! X(N) - the final point
      !
      ! F - On entry, F contains the objective function value at the
      !     starting point. On exit, is objective function value at the
      !     final point
      !
      ! FEAS - sup-norm of the infeasibility at the final point
      !
      ! FCNT - number of function evaluations
  
      use filters, only: absfilter
  
  
negative.code: 
      FCNT = IC
  
  !!$    IF ( OUTPUT ) THEN
  !!$       call cpu_time(tempofinal)
  !!$       write(*,2000) F,FEAS,RHO,DELTA,IC,(tempofinal - tempoinicial), &
  !!$                     MIN(N,MAXXEL),(X(I), I=1,MIN(N,MAXXEL))
  !!$    END IF
  
      ! FORMATS
  
  1000 FORMAT(/,'PHASE 0',/,7('-'),/,/,'FEASIBILITY =',36X,D23.8,/, &
           'NEW POINT',/,3(1X,D23.8))
  1001 FORMAT(/,'PHASE 1',/,7('-'),/)
  1002 FORMAT(3X,'(RE)BUILDING MODEL from scratch.',/, &
           3X,5X,'RHO =',45X,D12.5,/,               &
           3X,5X,'Delta =',43X,D12.5,/,             &
           3X,5X,'Objective function =',19X,D23.8,/,&
           3X,5X,'Function evaluations =',30X,I10,/,&
           3X,5X,'Current model center (first ',I3, &
           ' elements)',/,3X,6X,3(1X,D21.8))
  1003 FORMAT(/,3X,'SOLVED TR SUBPROBLEM.',/,                 &
           3X,5X,'RHO =',45X,D12.5,/,                      &
           3X,5X,'Delta =',43X,D12.5,/,                    &
           3X,5X,'Model value =',26X,D23.8,/,              &
           3X,5X,'Objective function (at Z) =',12X,D23.8,/,&
           3X,5X,'Function evaluations =',30X,I10)
  1004 FORMAT(5X,'Objective function =',24X,D23.8)
  1005 FORMAT(/,'REMOVING sampling point',1X,I4,'.')
  1006 FORMAT(5X,'Objective function (at trial point) =',&
           7X,D23.8)
  
  
  1020 FORMAT(/,3X,'Solution was found!',/)
  1021 FORMAT(/,3X,'Flag -1: Error while evaluating functions.',/)
  1022 FORMAT(/,3X,'Flag 2: Error in the internal solver.',/)
  1023 FORMAT(/,3X,'Flag 3: Reached the maximum of',1X,I10,1X, &
           'function evaluations.',/)
  1024 FORMAT(/,3X,'Flag 4: Rho smaller than tolerance.',/)
  
  3000 FORMAT(/,'Welcome to TRDF Algorithm!',/,                   &
           'This algorithm was based on paper',/,                &
           'P.D. Conejo, E.W. Karas, and L.G. Pedroso',/,        &
           '"A trust-region derivative-free algorithm for',/,    &
           'constrained problems", Optimization Methods ',/,     &
           'and Software, v. 30 (6), p. 1126-1145, 2015]',/)
    END SUBROUTINE TRDFSUB
  
    ! ******************************************************************
  