anchor.diff:          iErr = .true.
           return
         endif
  -      call chr_cast(lnSplit(4),cheby_mapXmin(icheby(iElem)),iErr)
  -      call chr_cast(lnSplit(5),cheby_mapXmax(icheby(iElem)),iErr)
  -      call chr_cast(lnSplit(6),cheby_mapNx  (icheby(iElem)),iErr)
  -      call chr_cast(lnSplit(7),cheby_mapYmin(icheby(iElem)),iErr)
  -      call chr_cast(lnSplit(8),cheby_mapYmax(icheby(iElem)),iErr)
  -      call chr_cast(lnSplit(9),cheby_mapNy  (icheby(iElem)),iErr)
  -    end if
  -    cheby_lMap(icheby(iElem))=.true.
  +      call chr_cast(lnSplit(4),cheby_mapXmin(ncheby_mapEchoes),iErr)
  +      call chr_cast(lnSplit(5),cheby_mapXmax(ncheby_mapEchoes),iErr)
  +      call chr_cast(lnSplit(6),cheby_mapNx  (ncheby_mapEchoes),iErr)
  +      call chr_cast(lnSplit(7),cheby_mapYmin(ncheby_mapEchoes),iErr)
  +      call chr_cast(lnSplit(8),cheby_mapYmax(ncheby_mapEchoes),iErr)
  +      call chr_cast(lnSplit(9),cheby_mapNy  (ncheby_mapEchoes),iErr)
  +    end if
       
       if(st_debug) then
  -      call sixin_echoVal("name",trim(bez(iElem)),                           "CHEBY",iLine)
  -      call sixin_echoVal("filename", trim(cheby_mapFileName(icheby(iElem))),"CHEBY",iLine)
  -      call sixin_echoVal("xmin [mm]",cheby_mapXmin(icheby(iElem)),          "CHEBY",iLine)
  -      call sixin_echoVal("xmax [mm]",cheby_mapXmax(icheby(iElem)),          "CHEBY",iLine)
  -      call sixin_echoVal("Nx     []",cheby_mapNx  (icheby(iElem)),          "CHEBY",iLine)
  -      call sixin_echoVal("ymin [mm]",cheby_mapYmin(icheby(iElem)),          "CHEBY",iLine)
  -      call sixin_echoVal("ymin [mm]",cheby_mapYmax(icheby(iElem)),          "CHEBY",iLine)
  -      call sixin_echoVal("Ny     []",cheby_mapNy  (icheby(iElem)),          "CHEBY",iLine)
  +      call sixin_echoVal("name",trim(bez(iElem)),                              "CHEBY",iLine)
  +      call sixin_echoVal("filename", trim(cheby_mapFileName(ncheby_mapEchoes)),"CHEBY",iLine)
  +      call sixin_echoVal("xmin [mm]",cheby_mapXmin(ncheby_mapEchoes),          "CHEBY",iLine)
  +      call sixin_echoVal("xmax [mm]",cheby_mapXmax(ncheby_mapEchoes),          "CHEBY",iLine)
  +      call sixin_echoVal("Nx     []",cheby_mapNx  (ncheby_mapEchoes),          "CHEBY",iLine)
  +      call sixin_echoVal("ymin [mm]",cheby_mapYmin(ncheby_mapEchoes),          "CHEBY",iLine)
  +      call sixin_echoVal("ymin [mm]",cheby_mapYmax(ncheby_mapEchoes),          "CHEBY",iLine)
  +      call sixin_echoVal("Ny     []",cheby_mapNy  (ncheby_mapEchoes),          "CHEBY",iLine)
       end if
        
     case default
  
positive.code: 
    character(len=:), allocatable   :: lnSplit(:)
    character(len=mInputLn) inLine
    integer nSplit, ii, jj, fUnit
    logical spErr, err, lDefI
  
    lDefI=.true.
  
negative.code:   ! module for handling maps expressed by Chebyshev polynomials
  
    integer, allocatable, save  :: icheby(:)            ! index of chebyshev lens
    integer, save               :: ncheby=0             ! number of chebyshev lenses actually in memory
    integer, save               :: ncheby_mapEchoes=0   ! number of requested echoes of maps
    integer, save               :: ncheby_tables=0      ! number of chebyshev tables in memory
    integer, parameter          :: cheby_kz=42          ! kz of chebyshev lenses
    integer, parameter          :: cheby_ktrack=67      ! ktrack of chebyshev lenses
  
    ! variables to save parameters for tracking etc.
    integer,          allocatable, save :: cheby_itable(:)      ! index of chebyshev table
    real(kind=fPrec), allocatable, save :: cheby_r2(:)          ! outer radius R2 [mm] (optional)
    real(kind=fPrec), allocatable, save :: cheby_r1(:)          ! inner radius R1 [mm] (optional)
    real(kind=fPrec), allocatable, save :: cheby_angle(:)       ! rotation angle about the longitudinal axis [deg] (optional)
    real(kind=fPrec), allocatable, save :: cheby_offset_x(:)    ! hor. offset [mm] (optional)
    real(kind=fPrec), allocatable, save :: cheby_offset_y(:)    ! ver. offset [mm] (optional)
    real(kind=fPrec), allocatable, save :: cheby_I(:)           ! actual powering of lens [A] (optional)
    real(kind=fPrec), allocatable, save :: cheby_scalingFact(:) ! scaling factor [] (computed internally)
    
    ! show map
    integer,          allocatable, save :: cheby_iLens(:)       ! lens for which a map echo is requested
    character(len=:), allocatable, save :: cheby_mapFileName(:) ! file name
    real(kind=fPrec), allocatable, save :: cheby_mapXmin(:)     ! xMin [mm]
    real(kind=fPrec), allocatable, save :: cheby_mapXmax(:)     ! xMax [mm]
    integer,          allocatable, save :: cheby_mapNx(:)       ! number of intervals
    real(kind=fPrec), allocatable, save :: cheby_mapYmin(:)     ! yMin [mm]
    real(kind=fPrec), allocatable, save :: cheby_mapYmax(:)     ! yMax [mm]
    integer,          allocatable, save :: cheby_mapNy(:)       ! number of intervals
  
    ! tables with chebyshev coefficients
    character(len=:), allocatable, save :: cheby_filename(:)    ! file names
    real(kind=fPrec), allocatable, save :: cheby_coeffs(:,:,:)  ! coefficients
    integer,          allocatable, save :: cheby_maxOrder(:)    ! max order of the current map
    real(kind=fPrec), allocatable, save :: cheby_refI(:)        ! reference current [A] (optional)
    real(kind=fPrec), allocatable, save :: cheby_refR(:)        ! reference radius [mm] (mandatory)
  
  contains
  
  