
 COMPLEX :: cZ


   READ (*,*) mAzi

   i11= 11
   i12= i11 + 1

   IF (mAzi == 0) THEN
      i12= -1
      OPEN(UNIT  = i11, &
           FILE  = 'Longitudinal-Impedance.mtv', &
           ACCESS= 'SEQUENTIAL', &
           FORM  = 'FORMATTED', &
           STATUS= 'UNKNOWN')
   ELSE
      i11= -1
      OPEN(UNIT  = i12, &
        FILE  = 'Transverse-Impedance.mtv', &
        ACCESS= 'SEQUENTIAL', &
        FORM  = 'FORMATTED', &
        STATUS= 'UNKNOWN')
   END IF

   IF (i11 > 0) THEN
      WRITE (i11,*) ' $DATA= COLUMN'
      WRITE (i11,*) ' % toplabel= "Longitudinal Impedance"'
      WRITE (i11,*) ' % xlabel= "Frequency [Hz]"'
      WRITE (i11,*) ' % ylabel= "Zz[V/A]"'
      WRITE (i11,*) ' k real aimag'
   END IF

   IF (i12 /= 0) THEN
      WRITE (i12,*) ' $DATA= COLUMN'
      WRITE (i12,*) ' % toplabel= "Transverse Impedance"'
      WRITE (i12,*) ' % xlabel= "Frequency [Hz]"'
    !!  WRITE (i12,*) ' % ylabel= "Zr*(rQ/r0)/((rQ/r0)^2)^m"'
      WRITE (i12,*) ' % ylabel= "Zr[V/A]"'
      WRITE (i12,*) ' k real aimag'
   END IF

   DO
      READ (*,*,iostat=iostat) iDum, cZ, if, rK, isXX
      if (iostat /= 0) exit
 write (0,*) if
      IF (i11 > 0) THEN
         WRITE (i11,*) rK, REAL(cZ), AIMAG(cZ)
      END IF
      READ (*,*) iDum, cZ  ! TKZ
      IF (i12 > 0) THEN
         WRITE (i12,*) rK, -REAL(cZ), -AIMAG(cZ)
      END IF
      READ (*,*) iDum, cZ  ! TKZs

      READ (*,*) iDum, cZ
      READ (*,*) iDum, cZ
      READ (*,*) iDum, cZ
   END DO

 END

