      SUBROUTINE EVALE(CXE00,AKD,IXYZ0,MXNAT,MXN3,NAT,NAT0,NX,NY,NZ,CXE)
C*** Arguments:
      INTEGER MXN3,MXNAT,NAT,NAT0,NX,NY,NZ
      INTEGER*2 IXYZ0(MXNAT,3)
      REAL AKD(3)
C Note: CXE should be dimensioned to CXE(NAT,3) in this routine
C       so that first 3*NAT elements of CXE are employed.
C       XYZ0 should be dimensioned to 
      COMPLEX CXE(NAT,3),CXE00(3)
C
C***  Local variables:
      COMPLEX CXFAC,CXI
      REAL GPI,X,X1,X2
      INTEGER IA,IX,IY,IZ,M
C
C*** Intrinsic functions:
      INTRINSIC ATAN,EXP,REAL
C
C*** Data statements:
      DATA CXI/(0.,1.)/
C***********************************************************************
C
C Given:   CXE00(1-3)=Incident E field at origin (complex) at t=0
C          AKD(1-3)=(kx,ky,kz)*d for incident wave (d=lattice spacing)
C          IXYZ0(1-NAT0,3)=x/d,y/d,z/d for each of NAT0 physical dipoles
C          MXNAT,MXN3=dimensioning information
C          NAT0=number of dipoles in physical target
C          NAT=number of locations at which to calculate CXE
C
C Returns: CXE(1-NAT,3)=incident E field at NAT locations at t=0
C
C B.T.Draine, Princeton Univ. Obs., 88.05.09
C History:
C 90.11.06 (BTD): Modified to pass array dimension.
C 90.11.29 (BTD): Modified to allow option for either
C                   physical locations only (NAT=NAT0), or
C                   extended dipole array (NAT>NAT0)
C 90.11.30 (BTD): Corrected error for case NAT>NAT0
C 90.11.30 (BTD): Corrected another error for case NAT>NAT0
C 90.12.03 (BTD): Change ordering of XYZ0 and CXE
C 90.12.05 (BTD): Corrected error in dimensioning of CXE
C 90.12.10 (BTD): Remove XYZ0, replace with IXYZ0
C
C Copyright (C) 1993, B.T. Draine and P.J. Flatau
C This code is covered by the GNU General Public License.
C***********************************************************************
C
      GPI=4.*ATAN(1.)
C
C Evaluate electric field vector at each dipole location.
C
C If NAT=NAT0, then evaluate E only at occupied sites.
C If NAT>NAT0, then evaluate E at all sites.
C
      IF(NAT.EQ.NAT0)THEN
         DO 10 IA=1,NAT0
            X=0.
            DO 5 M=1,3
               X=X+AKD(M)*IXYZ0(IA,M)
    5       CONTINUE
            CXFAC=EXP(CXI*X)
            DO 7 M=1,3
               CXE(IA,M)=CXE00(M)*CXFAC
    7       CONTINUE
   10    CONTINUE
      ELSE
         IA=0
         DO 20 IZ=1,NZ
            X1=AKD(3)*REAL(IZ)
            DO 19 IY=1,NY
               X2=X1+AKD(2)*REAL(IY)
               DO 18 IX=1,NX
                  IA=IA+1
                  X=X2+AKD(1)*REAL(IX)
                  CXFAC=EXP(CXI*X)
                  DO 17 M=1,3
                     CXE(IA,M)=CXE00(M)*CXFAC
   17             CONTINUE
   18          CONTINUE
   19       CONTINUE
   20    CONTINUE
      ENDIF
      RETURN
C
      END
