      PROGRAM OUTBACK

C     Multiply the transfer functions to produce the monostatic echo

C     PROJFIL contains the projector transfer function (projector to target)
C     TARGFIL contains the target transfer function (target to array)
C     ECHOFIL contains the product of the two (this is the output file)

      INTEGER PROJFIL, TARGFIL, ECHOFIL 
      PARAMETER ( PROJFIL = 26, TARGFIL = 27, ECHOFIL = 25,
     &   MAXNSD = 4094, MAXNRD = 4094, MAXNR = 4094 )

      REAL    R( MAXNR ), SD( MAXNSD ), RD( MAXNRD ), RDPROJ( MAXNRD )
      COMPLEX PROJ( 51, MAXNR ), P( MAXNR )
      CHARACTER TITLE*80, PLTTYP*10

C     *** Read projector file headers and data ***

      CALL RDHEAD( PROJFIL, 'PROJFIL', MAXNR, MAXNSD, MAXNRD,
     &      FREQ, R, NR, DELTAR, PLTTYP, XS, YS, THETA,
     &      SD, NSD, RDPROJ, NRDPROJ, TITLE )

      DO IRD = 1, NRDPROJ
C        --- read in the transfer function
         IRECIN = 6 + IRD
         WRITE( *, * ) IRD
         READ ( PROJFIL, REC = IRECIN ) ( PROJ( IRD, IR ), IR = 1, NR )
      END DO

C     *** Read target file headers ***

      CALL RDHEAD( TARGFIL, 'TARGFIL', MAXNR, MAXNSD, MAXNRD,
     &      FREQ, R, NR, DELTAR, PLTTYP, XS, YS, THETA,
     &      SD, NSD, RD, NRD, TITLE )

C     *** Write new header ***

      CALL HEADER( TITLE, SD, NSD, RD, NRD,
     &   R, NR, FREQ, ATTEN, PLTTYP, XS, YS, THETA )

C     *** Loop to read successive slices ***

      DO ISD = 1, NSD

         DO IRD = 1, NRD
C           --- read in pressure for a particular source/rcvr
            IREC  = 6 + NRD * ( ISD - 1 ) + IRD

            WRITE( *, * ) ISD, IRD
            READ( TARGFIL, REC = IREC ) ( P( IR ), IR = 1, NR )

C           --- Write out the product
            WRITE( ECHOFIL, REC = IREC )
     &         ( PROJ( ISD, IR ) * P( IR ), IR = 1, NR )

         END DO   ! next receiver depth, IRD

      END DO   ! next source depth, ISD

      STOP
      END
