       PROGRAM c3mmrcs
c*********************************************************************
c
c   purpose:  to compute the rcs of a target using the method of 
c             moments.
c             uses curved triangles with multiple parameterizations.
c
c  modified to compute rcs's for multiple polarizations 5/91
c  includes timing routines. 
c  single precision version.
c*******************************************************************
c
c    			   warning
c
c    this  code  contains  technical  data  whose  export  is
c    restricted  by the  arms export control act (22 usc 2751
c    et seq)  or the  export administration act  of  1979, as
c    amended  ( 50 usc 2401 et seq ).   violations  of  these
c    export  laws are  subject to  severe  civil and criminal
c    penalties.   distributions  limited  to   us  government
c    agencies and  their contractors. other requests for this 
c    code shall be referred to syracuse research corporation,
c    merrill lane, syracuse new york 13210-4080.
c
c*******************************************************************
c
c      implicit complex (c)
c      implicit none

      include 'ctparm.inc'
      include 'dspparam.inc'
      include 'ctgeom.inc'	
      include 'ctgeom2.inc'	
      include 'mmprms2.inc'
      include 'mmloops.inc'
      include 'mmiounit.inc'
      include 'mmiounitd.inc'
      include 'ctgeomwire.inc'
      include 'ctgeomjunc.inc'
      include 'symm.inc'
      include 'symmd.inc'
      include 'wirechar.inc'

      real pi
      integer k_tim, nrcs, npoloop, imgprob, kt, kpt, ntpol
      integer kr, kpr, nrpol
      integer i, j, iunit
      real alamda, rcond, aztx, thetai, phii, azrx, thetar, phir
      real hmag, ak
cg      integer ips(mxedgs)
cg      real tpr(3,3)
cg      real*4 rcs(1000)
      complex htheta,hphi,ertheta,erphi
      complex cz(mxedgs,mxedgs)
cg      complex ci(mxedgs),cvtemp(mxedgs)
cg      complex cvsct(2,2,1000), chinc(2,2,1000), cs(1000)
cg      complex chtheta(1000),chphi(1000)
      complex c1, c2, ceth, ceph
cg      character*80 str
      logical zfill,yfill,wires,loads
      integer index, iwire
cg      complex input_voltage(mxfaces), input_current(mxfaces)
cg      complex input_impedance(mxfaces)
      real powerin
      character*1 operator
      real timediff,timearray(2),dtime

      common /param/ thetai,phii
      common /kkk/ ak,pi
      common /field/ htheta,hphi,alamda
      common /geomopt/ wires,loads
      common /ieoper/ operator
      
      timediff = dtime(timearray)
      k_tim = 0		!for timing
      k_all = 0         !for timing
      nrcs = 0          ! final # of rcs values computed
      
      call initprm

      if( npols .eq. 1 ) then
        npoloop=1
      else
        npoloop=2		!go through tx & rx = v,h
      endif
      
c      call ontimer(k_all)
      call rdcfil
      call initcon(nfaces,alamda,c1,c2)
      call optcheck(zfill,yfill,eta_alpha)
      call define_junction()
      call speedup()
      call gentesters
      timediff = dtime(timearray)
      print *,'setup time(in sec.) =',timediff

      do imgprob=1, 2**nplanes

         call add_basis(imgprob)
         
         write(6,*) 'image problem #',imgprob
         write(6,*) 'number of unknowns = ',nunkns
         
         do j = 1,nunkns        !always initialize [z] = 0
            do i = 1,nunkns
               cz(i,j) = cmplx(0.,0.)
            enddo
         enddo

c         call ontimer(k_tim)

        if(zfill) then
c           call ontimer(k_tim)
           timediff = dtime(timearray)

           call zmatrx(c1,c2,cz,imgprob)

           timediff = dtime(timearray)
           print *,'zmatrix fill time(in sec.) =',timediff
c           call shotimer(k_tim,str)
c           write(6,*) ' time to fill [z] from zmatrx is:'
c           write(6,'(a80)') str
        endif

        open(13,file='sphere.zmatrix',status='unknown')
        write(13,*) 'matrix size (nunkns) = ',nunkns
        write(13,*) '------------------------------------------'
        do j = 1, nunkns
           write(13,1333) (i,j,real(cz(i,j)),aimag(cz(i,j)), 
     &          i = 1,90)

          if (mod(j,10) .eq. 0) write(13,*) ' '

        enddo
        write(13,*) '------------------------------------------'

        close(13)

 1333   format(2(1x,'[',I2,',',I3,']','(',F8.5,',',F9.4,')'))
        stop 'program ends at Zmatrix filled !'

        if(yfill) then
c           call ontimer(k_tim)
           call ymatrx(eta_alpha,cz,imgprob)
c           call shotimer(k_tim,str)
c           write(6,*) ' time to fill [z] from ymatrx is:'
c           write(6,'(a80)') str
        endif
        if(loads) then
c           call ontimer(k_tim)
           call sload(cz)
c           call shotimer(k_tim,str)
c           write(6,*) ' time to fill [z] from sload is:'
c           write(6,'(a80)') str
        endif

      end do                   !image problems


      stop 'program ends !'
      end


