      subroutine rdprm
c*********************************************************************
c  purpose:  to read the parameters from a file (unit #4) to be used
c            in the moment method rcs program.
c
c            modified 5/91 to read in multiple polarizations.
c            modified 6/92 to read the integral eqn operator.
c*********************************************************************
c
      include 'mmprms2.inc'
      include 'mmiounit.inc'
      common /ieoper/ operator
      character*1 operator
c
      character typol(2,8)*1,ptype(5)*1,txpol*1,rxpol(8)*1
      integer i, j, k, kk, ntxpol
      real cc
c
      data ptype/'V','H','R','L','A'/
      data cc/300./
c
      readz = .false.
      readj = .false.
      savez = .false.
      savej = .false.
c
c--- initialize angles
      pitch = 0.
      roll = 0.
      tilt = 0.
      biang = 0.
c
      read(ir2,2001) iopt,operator
c
 100  continue            ! compute everything from scratch
c
 105  continue                  ! get the model file name
      read(ir2,2010) dnname     !output file name to parameter file
      read(ir2,2020) fzcn       ! center frequency (mhz)
      read(ir2,2030) savez,zout   !flag & filename if used
      if (savez) then
        write(6,*) ' error in parameter file, can not read in [z]'
        write(6,*) ' will compute [z] from scratch...'
      endif      
c
 250  continue
c -- read in the string of polarizations 
      read(ir2,2040) ((typol(i,j),i=1,2),j=1,8)
      npols = 0
      do j = 1,8
        if(typol(1,j) .eq. ' ' ) go to 260
        npols = npols + 1
        do k=1,2
          do kk=1,4
            if (typol(k,j).eq.ptype(kk)) ntypol(k,j) = kk
            if(ntypol(k,j) .eq. 5) ntypol(j,k)=1
          enddo
        enddo
      enddo
 260  continue
c
      read(ir2,2050) pitch,roll        !pitch and roll angles (deg)
      read(ir2,2000) imode     ! monostatic or a type of bistatic ????
c
c -- want to separate monostatic case from fixed bistatic angle case.
c    add 1 to imode and if biang=0 (monostatic case) set imode=0.
c    then imode=0 :: monostatic
c         imode=1 :: fixed bistatic angle
c         imode=2 :: fixed transmitter
c         imode=3 :: fixed equivalent line of sight
c
      imode = imode + 1  
      goto (275,300,300)  imode
c
 275  continue             ! monostatic or fixed bistatic angle
      read(ir2,2020) biang             !bistatic angle (deg)
      if (biang .eq. 0) then        ! monostatic
         imode = 0
         read(ir2,2020) tilt                      ! (deg)
      endif
      read(ir2,2060) angst,angend,angdt   !starting,ending & delta angle

      if(operator .eq. 'a') then
        read(ir2,2030) savej, jout
      endif

      goto 999
c
c
 300  continue     ! bistatic w/ fixed x-mitter or equiv. line of sight
c
      read(ir2,2020) azim              ! azimuth of the transmitter
      read(ir2,2060) angst,angend,angdt !starting,ending & delta bi-angle
c--  w/ fixed x-mitter, you can save the currents
      if (imode .eq. 2) then
        read(ir2,2030) savej,jout
        if((npols.ne.1).and.(savej)) then
           write(iw1,4000)
           savej=.false.
        endif
        if (savej) then
          open(irw3,file=jout,status='unknown',form='formatted')
          write(irw3,3030) dnname,fzcn,azim,typol(1,1),pitch,roll
        endif
      endif
c
c
 999  continue

c--- (note: the rcs file names at the end of the input parameter file 
c     will be read in initprm)

c--- open the target model file
      open(ir01,file=dnname,status='old',form='formatted')

c
 2000 format(1x,i4,a40)
 2001 format(1x,i4,1x,a1)
 2010 format(1x,a30)
 2020 format(1x,f10.2)
 2030 format(1x,l1,2x,a30)
 2040 format(8(1x,2a1))
 2041 format(8(1x,a1))
 2050 format(1x,2(f10.2))
 2060 format(1x,3(f10.2))
c
 3030 format(' model file :',a30,'center freq :',f10.2,/,
     &       ' transmitter azimuth & polarization :',f10.2,2x,a1,/,
     &       ' pitch & roll :',f10.2,2x,f10.2)
 4000 format(x,'note: currents will not be saved in file since multiple',
     &     /,x,'      polarizations were chosen.')
c
      return
      end
