********************************************************************************
*                                                                              *
*  2DHF version 1-2003                                                         *
*  Copyright (C) 1996  Jacek Kobus, Leif Laaksonen, Dage Sundholm              *
*                                                                              *
*  This software may be used and distributed according to the terms            *
*  of the GNU General Public License, see README and COPYING.                  *
*                                                                              *
********************************************************************************
c ### homo_det ###
c
c     Determines Ci symmetry of a given orbital and uses it to replace
c     the values in the [pi/2,pi] region by these from the [0,pi/2] one. 
c
      subroutine homo_det (n2,nmut,psii,ihsym)
      implicit integer*4 (i-n)
      implicit real*8 (a-h,o-z)
      include 'commons8.inc'
      dimension psii(nni,nmut)

      if (idbg(99).ne.0) then
c        check symmetry and impose the symmetry
         if (psii(2,10)*psii(nni-1,10).gt.0.d0) then
            do ni=1,n2-1
               do mi=1,nmut
                  psii(nni+1-ni,mi)= psii(ni,mi)
               enddo
            enddo
            ihsym= 1
         else
            do ni=1,n2-1
               do mi=1,nmut
                  psii(nni+1-ni,mi)=-psii(ni,mi)
               enddo
            enddo
c           
            do mi=1,nmut
               psii(n2,mi)=0.d0
            enddo
            ihsym=-1
         endif
      else
c        set symmetry according to input data
         if (ihsym.eq.1) then
            do ni=1,n2-1
               do mi=1,nmut
                  psii(nni+1-ni,mi)= psii(ni,mi)
               enddo
            enddo
         else
            do ni=1,n2-1
               do mi=1,nmut
                  psii(nni+1-ni,mi)=-psii(ni,mi)
               enddo
            enddo
            do mi=1,nmut
               psii(n2,mi)=0.d0
            enddo   
         endif
      endif
      return
      end

