      SUBROUTINE HEELIS
C     ****
C     ****     GENERATE AURORAL CIRCLE FIELDS, UI, VI, WI
C     ****
      include "params.h"
      PARAMETER (IMAXG=ZIMX, JMAXG=ZJMX)
      PARAMETER (IMAXGP=IMAXG+1, JMAXGP=JMAXG+1)
      include "dynphi.h"
      include "blnk.h"
      include "vscr.h"
      include "cons.h"
      include "index.h"
      include "strt.h"
      include "buff.h"
      include "phys.h"
      include "amie.h"
      COMMON/MAGFLD/BXM(ZIMXP,2),BX(ZIMXP,ZJMX),BXP(ZIMXP,4),
     1  BY(ZIMXP,ZJMX),BYP(ZIMXP,4),BZ(ZIMXP,ZJMX),BZP(ZIMXP,4),
     2  BMOD(ZIMXP,ZJMX),BMODP(ZIMXP,2)
      DIMENSION WION(ZIMXP)
C     ****     CALCULATE UI AND VI
C     ****
C     ****     SCALE UI AND VI FROM INPUT
C     ****
      NUIK=NDJ+NUI
      NVIK=NDJ+NVI
      NWIK=NDJ+NWI
      DO 500 I=1,LEN3
        F(I,NUIK)=100.*F(I,NUIK)
        F(I,NVIK)=100.*F(I,NVIK)
        F(I,NWIK)=100.*F(I,NWIK)
  500 CONTINUE
      USERLA=(FLOAT(J-JMAX)-.5)*C(2)+C(110)/2.
      ISHUNK=1
      IF(IAUR.EQ.0)ISHUNK=0
      IF(ABS(USERLA).LT.C(110)/6.)ISHUNK=0
      IF(ISHUNK.EQ.0)GO TO 24
      IF (IAMIE .EQ. 1) THEN
        CALL AMIEPA (T2(3),T1(3),T4(3),T5(3),T6(3),T8(3),T3(3),WION(3))
        GO TO 499
      ENDIF
      JJ=((2*J-JMAX-1)/IABS(2*J-JMAX-1)+3)/2
      CALL FLOWXX(T5(3),T6(3),T8(3),T3(3))
  499 CONTINUE
C     ****     INSERT PERIODIC POINTS
      DO 502 I=1,2
        T3(I)=T3(I+IMAX)
        T5(I)=T5(I+IMAX)
        T6(I)=T6(I+IMAX)
        T7(I)=T7(I+IMAX)
        T8(I)=T8(I+IMAX)
        T9(I)=T9(I+IMAX)
        T3(I+IMAXP2)=T3(I+2)
        T5(I+IMAXP2)=T5(I+2)
        T6(I+IMAXP2)=T6(I+2)
        T7(I+IMAXP2)=T7(I+2)
        T8(I+IMAXP2)=T8(I+2)
        T9(I+IMAXP2)=T9(I+2)
  502 CONTINUE
      GO TO 25
   24 CONTINUE
      DO 26 I=1,LEN1
        T3(I)=0.
        T5(I)=0.
        T6(I)=0.
        T7(I)=0.
        T8(I)=0.
        T9(I)=0.
   26 CONTINUE
   25 CONTINUE
C     ****
C     ****     SAVE AURORAL PARAMETERS
C     ****
      RETURN
      END
C
