      subroutine addln2(aln,bln,cln,isgn) ! bernd berg, aug 24 2004.
c given ln(a) and ln(b), a>0,b>0. output for
c isgn=+1: cln=ln(c) with c=a+b, isgn unchanged,
c isgn=-1: cln=ln(c) with c=|a-b|, isgn=+1 for a>b and isgn=-1 for a<b.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      parameter(eps=em11,cut_off=700*one) ! change with precission!
      abs_ln=abs(aln-bln)
      if(abs_ln.gt.cut_off) then
        cln=max(aln,bln)
      else
        if(isgn.eq.1) then
          cln=max(aln,bln)+log(one+exp(-abs_ln))
        else
          if(abs_ln.lt.eps) then
            print*,"subroutine addln2: c=0."      
            print*,"aln,bln =",aln,bln
          stop "subroutine addln2: c=0."      
          end if
          cln=max(aln,bln)+log(one-exp(-abs_ln))
        end if
      end if
      if(aln.gt.bln) isgn=+1 
      return
      end


