!
!if .not.exist(scan%data) then
   var scan r
!endif
!
if .not.exist(feId) then
   define character feId*7 /global
endif
let feId "       "
!
if .not.exist(feIdPlot) then
   define character feIdPlot*6 /global
endif
!
if .not.exist(beId) then 
   define character beId*8 /global
endif
!
if .not.exist(beIdPlot) then
   define character beIdPlot*12 /global
endif
!
if .not.exist(specLin) then
   define character specLin*20 /global
endif
!
if .not.exist(switchMode) then
   define character switchMode*20 /global
endif
!
define integer ibe k nfb
define integer im ic id iu
define character tmpFe*3
define character prefix*1 prefixLowerCase*1
define character postfix*1 postfixLowerCase*1
!
let ibe = &1
!
define integer parallelMode /like scan%data%be
let parallelMode = 0
!
k = 0
nfb = scan%header%nfebe
!
for i 1 to nfb-1
    for j i+1 to nfb
        if scan%data%be[i].eq.scan%data%be[j]
           parallelMode[i] = k+1
           parallelMode[j] = k+2
           k = 0
        endif
    next
next
!
postfix          = ""
postfixLowerCase = postfix 
!
if scan%data%fe[ibe].lt.1000 then
!
   k = mod(scan%data%fe[ibe],10)
   if k.eq.1 then
      prefix          = "A"
      prefixLowerCase = "a"
   else if k.eq.2 then
      prefix          = "B"
      prefixLowerCase = "b"
   else if k.eq.3 then
      prefix          = "C"
      prefixLowerCase = "c"
   else if k.eq.4 then
      prefix          = "D"
      prefixLowerCase = "d"
   else if k.eq.5 then
      prefix          = "H"
      prefixLowerCase = "h"
   else if k.eq.6 then
      prefix          = "V"
      prefixLowerCase = "v"
   else if k.eq.7 then
      prefix          = "R"
      prefixLowerCase = "r"
   else if k.eq.8 then
      prefix          = "I"
      prefixLowerCase = "i"
   endif

   if int(scan%data%fe[ibe]/10.).eq.1 then
      feId     = 'prefix'100 
      feIdPlot = 'prefixLowerCase'100 
   else if int(scan%data%fe[ibe]/10.).eq.2 then
      feId     = 'prefix'150 
      feIdPlot = 'prefixLowerCase'150 
   else if int(scan%data%fe[ibe]/10.).eq.3 then
      feId     = 'prefix'230 
      feIdPlot = 'prefixLowerCase'230 
   else if int(scan%data%fe[ibe]/10.).eq.4 then
      feId     = 'prefix'270 
      feIdPlot = 'prefixLowerCase'270 
   else if int(scan%data%fe[ibe]/10.).eq.5 then
      feId     = HERA1
      feIdPlot = hera1
   else if int(scan%data%fe[ibe]/10.).eq.6 then
      feId     = HERA2 
      feIdPlot = hera2 
   else if int(scan%data%fe[ibe]/10.).eq.7 then
      feId     = MAMBO 
      feIdPlot = mambo 
   else if scan%data%fe[ibe].eq.0 then
      feId     = " "
      feIdPlot = " "
   endif
!
!
else ! EMIR cases
! 
   im = scan%data%fe[ibe]-mod(scan%data%fe[ibe],1000)
   if im.eq.1000 then
      feId = "E090"
   else if im.eq.2000 then
      feId = "E150"
   else if im.eq.3000 then
      feId = "E230"
   else if im.eq.4000 then
      feId = "E300"
   endif
   ic = scan%data%fe[ibe]-im
   ic = ic-mod(ic,100)
   if ic.eq.100 then
      feId = 'feId'"H"
   else if ic.eq.200 then
      feId = 'feId'"V"
   else if ic.eq.300 then
      feId = 'feId'"R"
   else if ic.eq.400 then
      feId = 'feId'"I"
   endif
   id = scan%data%fe[ibe]-im-ic
   id = id-mod(id,10)
   if id.eq.10 then
      feId = 'feId'"L"
   else if id.eq.20 then
      feId = 'feId'"U"
   endif
   iu = scan%data%fe[ibe]-im-ic-id
   if iu.eq.1 then
      feId = 'feId'"I"
   else if iu.eq.2 then
      feId = 'feId'"O"
   endif
!
   feIdPlot = feId

!
endif
!
k = scan%data%be[ibe]-10*int(scan%data%be[ibe]/10)
!
if int(scan%data%be[ibe]).eq.10 then
   beId = CONT
   if k.eq.0 then
      beIdPlot = continuum1
   else
      beIdPlot = continuum'k'
   endif
else if int(scan%data%be[ibe]).eq.11 then
    beId = BBC
    if k.eq.0 then
       beIdPlot = bbc1
    else
       beIdPlot = bbc'k'
    endif
else if int(scan%data%be[ibe]).eq.12 then
    beId = NBC
    if k.eq.0 then
       beIdPlot = nbc1
    else
       beIdPlot = nbc'k'
    endif
else if int(scan%data%be[ibe]/10).eq.2 then
   beId = 100KHZ
   if k.eq.0 then
      beIdPlot = 100khz1
   else
      beIdPlot = 100khz'k'
   endif
else if int(scan%data%be[ibe]/10).eq.3 then
   beId = 1MHZ
   if k.eq.0 then
      beIdPlot = 1mhz1
   else
      beIdPlot = 1mhz'k'
   endif
else if int(scan%data%be[ibe]/10).eq.4 then
   beId = VESPA 
   if k.eq.0 then
      beIdPlot = vespa1
   else
      beIdPlot = vespa'k'
   endif
   if parallelMode[ibe].ne.0 then
      beIdPlot = 'beIdPlot's'parallelMode[ibe]'
   endif
else if int(scan%data%be[ibe]/10).eq.5 then
   beId = VESPA 
   if k.eq.0 then
      beIdPlot = vespa10
   else
      beIdPlot = vespa1'k'
   endif
   if parallelMode[ibe].ne.0 then
      beIdPlot = 'beIdPlot's'parallelMode[ibe]'
   endif
else if int(scan%data%be[ibe]/10).eq.6 then
   beId = WILMA 
   if k.eq.0 then
      beIdPlot = wilma1
   else
      beIdPlot = wilma'k'
   endif
else if int(scan%data%be[ibe]/10).eq.7 then
   beId = 4MHz 
   if k.eq.0 then
      beIdPlot = 4mhz1
   else
      beIdPlot = 4mhz'k'
   endif
else if int(scan%data%be[ibe]/10).eq.8 then
   beId = FTS 
   if k.eq.0 then
      beIdPlot = fts 
   else
      beIdPlot = fts'k'
   endif
else if int(scan%data%be[ibe]/10).eq.9 then
   beId = ABBA 
   if k.eq.0 then
      beIdPlot = abba 
   else
      beIdPlot = abba'k'
   endif
else if int(scan%data%be[ibe]).eq.0 then
   beId = " " 
   if k.eq.0 then
      beIdPlot = none1
   else
      beIdPlot = none'k'
   endif
endif
!
if scan%data%be[ibe].ge.50.and.scan%data%be[ibe].lt.60 then
   beid = 'beid'/'k+10'
else if k.ne.0 then
! disabled 
!   beId = 'beId'/'k'
endif
!
if ibe.eq.1 then
   speclin = 'array1%header1%transiti'
else if ibe.eq.2 then
   speclin = 'array2%header1%transiti'
else if ibe.eq.3 then
   speclin = 'array3%header1%transiti'
else if ibe.eq.4 then
   speclin = 'array4%header1%transiti'
else if ibe.eq.5 then
   speclin = 'array5%header1%transiti'
else if ibe.eq.6 then
   speclin = 'array6%header1%transiti'
else if ibe.eq.7 then
   speclin = 'array7%header1%transiti'
else if ibe.eq.8 then
   speclin = 'array8%header1%transiti'
else if ibe.eq.9 then
   speclin = 'array9%header1%transiti'
else if ibe.eq.10 then
   speclin = 'array10%header1%transiti'
else if ibe.eq.11 then
   speclin = 'array11%header1%transiti'
else if ibe.eq.12 then
   speclin = 'array12%header1%transiti'
else if ibe.eq.13 then
   speclin = 'array13%header1%transiti'
else if ibe.eq.14 then
   speclin = 'array14%header1%transiti'
else if ibe.eq.15 then
   speclin = 'array15%header1%transiti'
else if ibe.eq.16 then
   speclin = 'array16%header1%transiti'
else if ibe.eq.17 then
   speclin = 'array17%header1%transiti'
else if ibe.eq.18 then
   speclin = 'array18%header1%transiti'
else if ibe.eq.19 then
   speclin = 'array19%header1%transiti'
else if ibe.eq.20 then
   speclin = 'array20%header1%transiti'
else if ibe.eq.21 then
   speclin = 'array21%header1%transiti'
else if ibe.eq.22 then
   speclin = 'array22%header1%transiti'
else if ibe.eq.23 then
   speclin = 'array23%header1%transiti'
else if ibe.eq.24 then
   speclin = 'array24%header1%transiti'
else if ibe.eq.25 then
   speclin = 'array25%header1%transiti'
else if ibe.eq.26 then
   speclin = 'array26%header1%transiti'
else if ibe.eq.27 then
   speclin = 'array27%header1%transiti'
else if ibe.eq.28 then
   speclin = 'array28%header1%transiti'
else if ibe.eq.29 then
   speclin = 'array29%header1%transiti'
else if ibe.eq.30 then
   speclin = 'array30%header1%transiti'
endif
!
if ibe.eq.1 then
   switchMode = 'febe1%header%swtchmod'
else if ibe.eq.2 then
   switchMode = 'febe2%header%swtchmod'
else if ibe.eq.3 then
   switchMode = 'febe3%header%swtchmod'
else if ibe.eq.4 then
   switchMode = 'febe4%header%swtchmod'
else if ibe.eq.5 then
   switchMode = 'febe5%header%swtchmod'
else if ibe.eq.6 then
   switchMode = 'febe6%header%swtchmod'
else if ibe.eq.7 then
   switchMode = 'febe7%header%swtchmod'
else if ibe.eq.8 then
   switchMode = 'febe8%header%swtchmod'
else if ibe.eq.9 then
   switchMode = 'febe9%header%swtchmod'
else if ibe.eq.10 then
   switchMode = 'febe10%header%swtchmod'
endif
