      SUBROUTINE HMATRX(FREQ,FREQR,XSIIR,FII,H,NDIM,NMODES)
C     
C..THISPROGRAM WILL CALCULATE VALUES FOR COMPLEX TRANSFER FUNCTION MATRIX H
C     
CDEP  
      IMPLICIT REAL (A-H,O-Z)
      DIMENSION FREQR(NMODES),XSIIR(NMODES),FII(NDIM,NMODES)
      DIMENSION H(NDIM,NDIM)
C-old:DEP  --- NOTE: ALL COMPLEX*16 MEANS A 64-BIT REAL AND IMAGINARY PART
C-old      COMPLEX*16 H,RECIP
      COMPLEX H,RECIP
      INTEGER R
C     
      PII2=6.283185307
      OMEGA=PII2*FREQ
C     
      DO 110 K=1,NDIM
         DO 100 J=K,NDIM
            H(J,K)=(0.,0.)
 100     CONTINUE
 110  CONTINUE
C     
      DO 220 R=1,NMODES
         OMEGAR=PII2*FREQR(R)
         RECIP=1/CMPLX(OMEGAR**2-OMEGA**2,
     +        2*OMEGA*OMEGAR*XSIIR(R))
         DO 210 K=1,NDIM
            FIIK=FII(K,R)*RECIP
            DO 200 J=K,NDIM
               H(J,K)=H(J,K)+FII(J,R)*FIIK
 200        CONTINUE
 210     CONTINUE
 220  CONTINUE
C     
      DO 310 J=1,NDIM-1
         DO 300 K=J+1,NDIM
            H(J,K)=H(K,J)
 300     CONTINUE
 310  CONTINUE
C     
      END  
