      subroutine nlcmed
c     
c     NLC media definitions
c     
      implicit none
c
      real vect,getot,gekin,vout,destep,destel,safety,sleng,step,snext,
     + sfield,tofg,gekrat,upwght
      integer nmec,lmec,namec,nstep,maxnst,ignext,inwvol,istop,igauto,
     + iekbin,ilosl,imull,ingoto,nldown,nlevin,nlvsav,istory
      COMMON/GCTRAK/VECT(7),GETOT,GEKIN,VOUT(7),NMEC,LMEC(30),NAMEC(30)
     + ,NSTEP ,MAXNST,DESTEP,DESTEL,SAFETY,SLENG ,STEP  ,SNEXT ,SFIELD
     + ,TOFG  ,GEKRAT,UPWGHT,IGNEXT,INWVOL,ISTOP ,IGAUTO,IEKBIN, ILOSL
     + , IMULL,INGOTO,NLDOWN,NLEVIN,NLVSAV,ISTORY
c
      integer isvol, ifield
      real fieldm, tmaxfd, stemax, deemax, epsil, stmin
      real dumbuf
      integer itmed
      common /medpar/ itmed, tmaxfd, stemax, deemax, epsil, stmin
c------------------------------------------------------------------------------
c ----
      IGAUTO = 0   !  default=1, stemax,deemax,stmin set to -1 (?)

      isvol  = 0
      fieldm = 0.0
      tmaxfd = 5.0
      stemax = 2.0
      deemax = 0.05
      epsil  = 0.005
      stmin  = 0.5

c                                No magnetic field 
      ifield = 0
      call gstmed( 1, 'WORLD', 16, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 2, 'AL_NO_FIELD', 9, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 3, 'W_NO_FIELD', 12, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 4, 'CONCRETE_NO_FIELD', 22, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 5, 'FE_NO_FIELD', 10, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

c                                Non-uniform magnetic field
      ifield = 1
c        Actual field is calculated in GUFLD, but fieldm is used for step size.
      fieldm = 6.0  

      call gstmed( 6, 'NLD_FIELD', 16, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 7, 'TI_FIELD', 20, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 8, 'BE_FIELD', 5, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed( 9, 'FE_FIELD', 10, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(10, 'CU_FIELD', 11, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(11, 'W_FIELD' , 12, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(12, 'AL_FIELD', 9, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(13, 'SUPERCOND_FIELD', 24, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(14, 'SI_FIELD', 19, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(15, 'G10_FIELD', 18, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(16, 'SCINTI_FIELD', 17, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(17, 'SCORE_FIELD', 16, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(18, 'SI_SCORE_F', 19, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(19, 'C_FIELD', 6, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(20, 'AIR_FIELD', 15, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(21, 'LIQHE_FIELD', 23, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

*----------------------------------------------------------------------
* Beamline magnets _FIELD: tracking volume (vacuum) with field strength

* Incoming beam line
* Bend
      fieldm = 10.0
      call gstmed(22, 'B_FIELD', 16, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(23, 'B_MATERIAL', 9, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      fieldm = 10.0 
      call gstmed(24, 'B_FIELD', 16, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)

      call gstmed(25, 'B_MATERIAL', 9, isvol, ifield,
     +     fieldm, tmaxfd, stemax, deemax, epsil, stmin, dumbuf, 0)
c
c-------------------------------------------------------------------
c
      call GPRINT('TMED',0)

         return
         end
