anchor.diff:    !          aij      value
     !      (o)
     !          iv       communication array
  -  !======================================================================!
  -  subroutine STAIJ1(Isw,I,J,Aij,NEQns,NDEg,LEN_colno,NSTop,LEN_dsln,INVp,XLNzr,COLno,DIAg,ZLN,DSLn,RALoc,STAge,Ir)
  +  !  sets DIAg, ZLN, DSLn
  +  !  updates RALoc, STAge
  +  !======================================================================!
  +  subroutine STAIJ1(Isw,I,J,Aij,FCT,Ir)
       implicit none
       !------
       integer(kind=kint), intent(in):: I
       integer(kind=kint), intent(in):: Isw
       integer(kind=kint), intent(in):: J
  -    real(kind=kreal), intent(in):: Aij(NDEg*NDEg)
  -    integer(kind=kint), intent(in):: NEQns
  -    integer(kind=kint), intent(in):: NDEg
  -    integer(kind=kint), intent(in):: LEN_colno
  -    integer(kind=kint), intent(in):: NSTop
  -    integer(kind=kint), intent(in):: LEN_dsln
  -    integer(kind=kint), intent(in):: INVp(:)
  -    integer(kind=kint), intent(in):: XLNzr(:)
  -    integer(kind=kint), intent(in):: COLno(:)
  -    real(kind=kreal), pointer :: DIAg(:)
  -    real(kind=kreal), pointer :: ZLN(:)
  -    real(kind=kreal), pointer :: DSLn(:)
  -    integer(kind=kint), intent(inout):: RALoc
  -    integer(kind=kint), intent(inout):: STAge
  +    real(kind=kreal), intent(in):: Aij(:)
  +    type (cholesky_factor), intent(inout):: FCT
       integer(kind=kint), intent(out):: Ir
       !------
       integer(kind=kint):: ndeg2
  
positive.code:         i = hecMAT%ITEML(k)
          kk = kk + 1
          call VLCPY(val,hecMAT%AL(ndof2*(k-1)+1:ndof2*k),ndof)
          call STAIJ1(0,j,i,val,FCT%NEQns,FCT%NDEg,FCT%LEN_colno,FCT%NSTop,FCT%LEN_dsln,FCT%INVp,FCT%XLNzr,FCT%COLno,&
               FCT%DIAg,FCT%ZLN,FCT%DSLn,FCT%RALoc,FCT%STAge,Ir)
        enddo
      enddo
  
  
negative.code:     integer(kind=kint):: ierror
  
      Ir = 0
      ndeg2 = FCT%NDEg*FCT%NDEg
      ndeg2l = FCT%NDEg*(FCT%NDEg+1)/2
      if ( FCT%STAge==30 ) write (6,*) 'warning a matrix was build up '//'but never solved.'
      if ( FCT%STAge==10 ) then
        allocate (FCT%DIAg(FCT%NEQns*ndeg2l),stat=IERror)
        if ( IERror/=0 ) stop "Allocation error diag"
        FCT%RALoc = FCT%RALoc + FCT%NEQns*ndeg2l
  
        allocate (FCT%ZLN(FCT%LEN_colno*ndeg2),stat=IERror)
        if ( IERror/=0 ) stop "Allocation error zln"
        FCT%RALoc = FCT%RALoc + FCT%LEN_colno*ndeg2
  
        allocate (FCT%DSLn(FCT%LEN_dsln*ndeg2),stat=IERror)
        if ( IERror/=0 ) stop "Allocation error dsln"
        FCT%RALoc = FCT%RALoc + FCT%LEN_dsln*ndeg2
      endif
      if ( FCT%STAge/=20 ) then
        !
        ! for diagonal
        !
        FCT%DIAg = 0.
        !
        ! for lower triangle
        !
        FCT%ZLN = 0.
        !
        ! for dense window
        !
        FCT%DSLn = 0.
  
        FCT%STAge = 20
      endif
      !         Print *,'********Set Stage 20 *********'
      !
      if ( FCT%NDEg<=2 ) then
        call ADDR0(Isw,I,J,Aij,FCT%INVp,FCT%XLNzr,FCT%COLno,FCT%DIAg,FCT%ZLN,FCT%DSLn,FCT%NSTop,ndeg2,ndeg2l,Ir)
      elseif ( FCT%NDEg==3 ) then
        call ADDR3(I,J,Aij,FCT%INVp,FCT%XLNzr,FCT%COLno,FCT%DIAg,FCT%ZLN,FCT%DSLn,FCT%NSTop,Ir)
      else
        call ADDRX(I,J,Aij,FCT%INVp,FCT%XLNzr,FCT%COLno,FCT%DIAg,FCT%ZLN,FCT%DSLn,FCT%NSTop,FCT%NDEg,ndeg2l,Ir)
      endif
    end subroutine STAIJ1
  
  