c23456789012345678901234567890123456789012345678901234567890123456789012


      SUBROUTINE betaxxx

c     ******************************************************************
c
c     This routine constructs the vector beta
c
c     ******************************************************************

c     -------------
c     Declarations
c     -------------

c     ''''''''''''''''''''''
      implicit none
      include 'commonvar.f'      
c     ''''''''''''''''''''''

c---- Local variables

      integer	n,n1,n2,n3

      integer	i,j,k,kcomp

      real*8	Fx        (idim_n_o),
     >		FT_Cf_1_Fx(idim_n_o),
     >		FT_Cf_1_f (idim_n_o)




c     ---------------------------------------------------
c     Product of Co^{-1} and x_o
c
c     Note
c     ----
c     This product must be calculated only once,
c     but is included here to increase program legibility 
c     ---------------------------------------------------

      do n=1,n_o
         vec1(n) = Co_1(n)*xo(n) 
      enddo




c     ---------------------------------------------------
c     Product of A_zon' Ca_zon^{-1} b_zon
c
c     Note
c     ----
c     This product must be calculated only once,
c     but is included here to increase program legibility
c     ---------------------------------------------------

c---- Matrix product A' CA^{-1}

      do n1=1,n_o
      do n2=1,n_zon
         MAT1(n1,n2) = A_zon(n2,n1)*Ca_zon_1(n2) 
      enddo
      enddo


c---- Product A' CA^{-1} b

      do n1=1,n_o
         vec2(n1) = 0.d0
         do n2=1,n_zon
           vec2(n1) = vec2(n1) + MAT1 (n1,n2)*
     >                           b_zon(   n2)
         enddo
      enddo




c     -------------------------
c     Product F' Cf^{-1} (Fx-f)
c     -------------------------

c---- Matrix product F' Cf^{-1}

      do n1=1,n_o
      do n2=1,n_nl
          MAT1(n1,n2) = FF(n2,n1)*Cf_1(n2)
      enddo
      enddo


c---- Matrix product Fx 

      do n1=1,n_nl

         Fx(n1) = 0.d0
         do n2=1,n_o
            Fx(n1) = 
     >	    Fx(n1) + FF(n1,n2)*x(n2)
         enddo

      enddo


c---- Matrix product F' Cf^{-1} Fx

      do n1=1,n_o

         FT_Cf_1_Fx(n1) = 0.d0
         do n2=1,n_nl
            FT_Cf_1_Fx(n1) = 
     >	    FT_Cf_1_Fx(n1) + MAT1(n1,n2)*Fx(n2)
         enddo

      enddo 


c---- Matrix product F' Cf^{-1} f

      do n1=1,n_o

         FT_Cf_1_f(n1) = 0.d0
         do n2=1,n_nl
            FT_Cf_1_f(n1) = 
     >	    FT_Cf_1_f(n1) + MAT1(n1,n2)*f(n2)
         enddo
 
      enddo




c     -----------      
c     Vector beta
c     -----------

      do n=1,n_o

         beta(n) = vec1      (n) +
     >		   vec2      (n) +
     >		   FT_Cf_1_Fx(n) - 
     >		   FT_Cf_1_f (n) 

      enddo




c     -------------------
c     End of the routine
c     -------------------

      return

      end

c     ******************************************************************

