      function chi2_xq(q) ! bernd berg, jyly 3 1999.
c chi2 distribution: qtiles.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      external chi2_df
      common /chi2par/ nf
      x1=zero
      x2=zero
      q1=chi2_df(x1)
1     x2=x2+one*nf
        qt=chi2_df(x2)
      if(qt.le.q) go to 1
      q2=chi2_df(x2)
      chi2_xq=fi1(chi2_df,q,x1,x2)
      return
      end
