      SUBROUTINE RDHEAD( SHDFIL, FILNAM, MAXNR, MAXNSD, MAXNRD,
     &   FREQ, R, NR, DELTAR, PLTTYP, XS, YS, THETA,
     &   SD, NSD, RD, NRD, TITLE )

      INTEGER SHDFIL
      REAL    R( * ), RD( * ), SD( * )
      CHARACTER TITLE*80, FILNAM*80, PLTTYP*10

C     *** Open file, read header ***

C     Note that for UNIX file must be opened a second time with
C     the correct record length

      IF ( SHDFIL .EQ. 0 ) SHDFIL = 25

      IF ( FILNAM(1:1) .EQ. ' ' ) THEN
         OPEN( FILE = 'SHDFIL', UNIT = SHDFIL, STATUS = 'OLD',
     &         RECL = 20, ACCESS = 'DIRECT', FORM = 'UNFORMATTED' )
         READ( SHDFIL, REC = 1 ) LRECL
         CLOSE( SHDFIL )

         OPEN( FILE = 'SHDFIL', UNIT = SHDFIL, STATUS = 'OLD',
     &      RECL = 4 * LRECL, ACCESS = 'DIRECT', FORM = 'UNFORMATTED' )
      ELSE
         OPEN( UNIT = SHDFIL, FILE = FILNAM, STATUS = 'OLD',
     &       RECL = 20, ACCESS = 'DIRECT', FORM = 'UNFORMATTED' )
         READ( SHDFIL, REC = 1 ) LRECL
         CLOSE( SHDFIL )

         OPEN( UNIT = SHDFIL, FILE = FILNAM, STATUS = 'OLD',
     &      RECL = 4 * LRECL, ACCESS = 'DIRECT', FORM = 'UNFORMATTED' )
      ENDIF

      READ( SHDFIL, REC = 1 ) LRECL, TITLE
      READ( SHDFIL, REC = 2 ) PLTTYP, XS, YS, THETA
      READ( SHDFIL, REC = 3 ) FREQ, NSD, NRD, NR

      XS = XS / 1000.0
      YS = YS / 1000.0

C     *** Intercept cases where program dimensions are inadequate ***

      IF ( NR .GT. MAXNR ) THEN
         WRITE( *, * ) 'FATAL ERROR: Too many range points'
         WRITE( *, * ) 'NR = ', NR, ' MAXNR = ', MAXNR
         STOP
      ENDIF

      IF ( NSD .GT. MAXNSD ) THEN
         WRITE( *, * ) 'FATAL ERROR: Too many source points'
         WRITE( *, * ) 'NSD = ', NSD, ' MAXNSD = ', MAXNSD
         STOP
      ENDIF

      IF ( NRD .GT. MAXNRD ) THEN
         WRITE( *, * ) 'FATAL ERROR: Too many receiver points'
         WRITE( *, * ) 'NRD = ', NRD, ' MAXNRD = ', MAXNRD
         STOP
      ENDIF

      READ( SHDFIL, REC = 4 ) ( SD( I ), I = 1, NSD )
      READ( SHDFIL, REC = 5 ) ( RD( I ), I = 1, NRD )
      READ( SHDFIL, REC = 6 ) ( R(  I ), I = 1, NR  )

      DELTAR = R( NR ) - R( NR - 1 )

      RETURN
      END
