
      subroutine initprm
c*********************************************************************
c
c  purpose: to read the parameter file, output the rcs file header,
c           and convert the angles from degrees to radians.
c
c  modified to read in list of rcs file names & write headers to
c  all of them.
c*********************************************************************
c
      include 'mmprms2.inc'
      include 'mmiounit.inc'
c
      common /ieoper/ operator
      common /field/ htheta,hphi,alamda
      complex htheta,hphi
      character*1 operator
      character version*40,ptype(5)*1,title(2)*32,filnam*30
      real pi, dtr, alamda, cc
      integer i, j, ios, iunit
c
      data version /'     paramom  version 1.0     09/92    '/
      data ptype/'V','H','R','L','A'/
      data title/'bistatic w/fixed transmitter',
     &           'bistatic w/fixed equivalent los'/
c
      data cc/300./
c
      pi = 2. * acos(0.)
      dtr = pi/180.
c
      call rdprm              ! read parameters from parameter file
c
      call setloops           ! determine loop control variables
c
c---------------------------------------------------------------------
c  read in list of rcs files (one for each polarization)
c  -check if at end-of-file; if so, name file for110. this happens
c   when using old parameter files (case where npol=1).
      do j = 1,npols
        read(ir2,1080,iostat=ios) filnam
        if(ios.lt.0) filnam = 'for110'		!end-of-file
        iunit = 91 + j - 1
       
        open(unit=iunit,file=filnam,status='unknown',form='formatted')

c--- output header lines of the rcs data file
        write(iunit,1000) dnname,version
        write(iunit,1010) fzcn
        if(operator.eq.'E') then
          write(iunit,1021)
        elseif(operator.eq.'H') then
         write(iunit,1022)
        elseif(operator.eq.'C') then
          write(iunit,1023)
        elseif(operator.eq.'A') then
          write(iunit,1024)
        endif
        write(iunit,1030) angst,angend,angdt
c
        if (imode.eq.0) then
          write(iunit,1040) tilt,pitch,roll
        elseif (imode.eq.1) then
           write(iunit,1050) tilt,pitch,roll,biang
        else
           write(iunit,1060) tilt,pitch,roll,title(imode-1)
        endif
c
        write(iunit,1020)
        write(iunit,1070) (ptype(ntypol(i,j)),i=1,2)

      enddo
c
c---------------------------------------------------------------------
c
c---- convert angles from degrees to radians
      tilt = tilt * dtr
      pitch = pitch * dtr
      roll = roll * dtr
      biang = biang * dtr            ! used in main loops
      angdt = angdt * dtr            ! used in main loops
c
      alamda = cc/fzcn
c
 1000 format(' model file name is ',a30,5x,a40)
 1010 format(' center freq=',f10.2)
 1020 format()
 1021 format(x,'rcs ; efie operator')
 1022 format(x,'rcs ; hfie operator')
 1023 format(x,'rcs ; cfie operator')
 1024 format(x,'antenna gain ; efie operator')
 1030 format(' starting,ending, and delta angle:',2f8.2,f6.2)
 1040 format(' tilt, pitch, roll:',3f8.2)
 1050 format(' tilt, pitch, roll:',3f8.2,2x,
     &       ' fixed bistatic angle=',f7.2)
 1060 format(' tilt, pitch, roll:',3f8.2,2x,a32)
 1070 format(' transmit & receive polarizations:',2a1)
 1080 format(1x,a)
c
      return
      end
