	program aap
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
	character*40 chfile,chf
	character*3 chnr
	character*2 chnrb
	character chnra
        integer nlables, ncomps, nikhefnr

	if (1.eq.1) then
	   do i=1,96
	      write(chnr,*)i
	      if (i.le.9) then
		 chnra=chnr(2:2)
		 chf='bolchamber_'//chnra
	      else
		 chnrb=chnr(2:3)
		 chf='bolchamber_'//chnrb
	      endif
	      chfile=chf
	      open(22,file=chfile)
	      print *,'pint to file ',chfile
	      nikhefnr=i
	      call chamber()
	      close(22)
	   enddo
	else
	   call labelaar()
	endif
	end



	subroutine labelaar()
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr
	
	integer labelcounter(100)
	character*512 line,lia
	character*40 chname
	character*20 lname

	do i=1,100
	   labelcounter(i)=0
	enddo


        nlables=0
	ncomps=0
        open(20,file='bolcabling.csv')
 10	continue
	read(20,'(a)',END=20)line
	if (line(1:6).eq.'NIKHEF') then
           call setlables(line)
        endif
	if (line(1:3).eq.'BOL') then
	   call getnikhefnr(line,inow,chname)
	   atlasname=chname
	   call setcomps(line)
	   if (ncomps.ne.nlables) then
	      print *,'FATAL: ncomps ne nlables ',ncomps, nlables
	   endif
	   do i=1,ncomps
	      if (lcomps(i).ne.'0') labelcounter(i)=labelcounter(i)+1
	   enddo
	endif
        goto 10
 20	continue

	if (ncomps.eq.0) then
	   print *,'FATAL: no comps found on exit labelaar '
	endif

	   write(*,*)'========================================'
	   write(*,*)'---------->LABELS en AANTAL<------------'
	   do i=1,nlables
	      lname=lables(i)
	      write(*,*)lname,labelcounter(i)
	   enddo
	   write(*,*)'---------->The End<---------------------'
	   write(*,*)'========================================'
	   close(20)
	end



	subroutine chamber()
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr
	character*512 line,lia
	character*40 chname
	integer inow
        nlables=0
	ncomps=0
        open(20,file='bolcabling.csv')
 10	continue
	read(20,'(a)',END=20)line
	if (line(1:6).eq.'NIKHEF') then
           call setlables(line)
        endif
	if (line(1:3).eq.'BOL') then
	   call getnikhefnr(line,inow,chname)
	   if (nikhefnr.eq.inow) then
	      atlasname=chname
	      call setcomps(line)
	      if (ncomps.ne.nlables) then
		 print *,'FATAL: ncomps ne nlables ',ncomps, nlables
	      endif
	   endif
	endif
        goto 10
 20	continue
	call prilables()
	if (ncomps.eq.0) then
	   print *,'FATAL: no comps found on exit ', nikhefnr
	endif
	close(20)
	end

C         daily='Daily.'//datum

	subroutine setlables(line)
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr



	character*512 line
        integer icount,i1,i2
	icount=0
        i1=1
	i2=1
        ilast=512
	do i=6,ilast
	  if ((line(i:i).eq.',') .or. (i.eq.ilast)) then
		icount=icount+1 
                i1=i2+2
                i2=i-1
                if (icount.gt.3) then
                   nlables=nlables+1
		   lables(nlables)=line(i1:i2)
C                   write(*,*)lables(nlables)
	        endif
	  endif
	enddo
	end
		   


	subroutine setcomps(line)
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr



	character*512 line
        integer icount,i1,i2
	ncomps=0
	icount=0
        i1=1
	i2=1
        ilast=512
	do i=1,ilast
	  if ((line(i:i).eq.',') .or. (i.eq.ilast)) then
		icount=icount+1 
                i1=i2+2
                i2=i-1
                if (icount.gt.3) then
                   ncomps=ncomps+1
		   lcomps(ncomps)=line(i1:i2)
C                   write(*,*)lcomps(ncomps)
	        endif
	  endif
	enddo
	end
		   




	subroutine getnikhefnr(line,nr,chname)
	character*40 chname
        integer nr
	character*512 line
	character*2 cnr
        integer icount,i1,i2
        nr=0
	icount=0
        i1=4
	i2=1
        ilast=8
	do i=1,ilast
	   if (line(i:i).eq.',') then
	      i2=i-1
	   endif
	enddo
	if (i2.gt.1) then
	   cnr=line(i1:i2)
	   read(cnr,*)nr
	endif

C get Atlas name
	icount=0
        i1=1
	i2=-1
        ilast=40
	do i=1,ilast
	   if (line(i:i).eq.',') then
	      i1=i2+2
	      i2=i-1
	      icount=icount+1
	   endif
	   if (icount.eq.2) then
	      chname=line(i1:i2)
	   endif
	enddo
	end
		   


	subroutine prilables
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname

	character*7 chbol
	character*20 chfile
	character*79 aline
        character*80 lc
        integer nlables, ncomps, nikhefnr
	integer acham
	
	acham=1
	if (atlasname(10:10).eq.'C') acham=0
	
	write(22,*)' '
	write(22,*)'For BOL chamber nikhef number: ',nikhefnr
	write(22,*)'    ATLAS name= ',atlasname
	write(22,*)' '
	write(22,*)'---->Groffe indicatie positie lables, gezien vanuit IP '
	write(22,*)'---->Let op pijltjes=buisprofiel en RO/HV side '
	if (acham.eq.1) then
	   write(22,*)'   (je kijkt tegen onderkant kamer)  '
	else
	   write(22,*)'    (projectie met Franse slag)  '
	endif
	write(22,*)' '
	write(22,*)'                                  C-side '
	call priprolable(1)
	if (acham.eq.1) then
	write(22,*)'       V--------------------
     +------------------------------------------V'
	else
	write(22,*)'       ^--------------------
     +------------------------------------------^'
	endif
	call pripraxilable(1)
	call priccclable(1)
	call priprolable(3)
	write(22,*)'       |                        
     +                                      |'
	write(22,*)'RO-side|                        
     +                                      |HV-side'
	write(22,*)'       |                        
     +                                      |'
		   
	call priprolable(2)
	call priccclable(2)	
        call pripraxilable(2)
	if (acham.eq.1) then
	write(22,*)'       V--------------------
     +------------------------------------------V'
	else
	write(22,*)'       ^--------------------
     +------------------------------------------^'
	endif
	call priprolable(4)
	write(22,*)'                                  A-side '
	write(22,*)' '
	write(22,*)' '
	write(22,*)' '
	write(22,*)'Alle (behalve inplane) lables op deze kamer'
	call prilist()
	write(22,*)' '
	write(22,*)'CAMERA RASMUX SLOTS: zie apart vel
     +   (plak op kamer!) '
	write(22,*)' '
	call prislots()
C	call prirasmux()

C fill page
	ipro=0
	iccc=0
	do i=1,nlables
	   lc=lables(i)
	   if (lc(4:6).eq.'PRO' .and. lcomps(i).ne.'0') ipro=1
	   if (lc(4:6).eq.'CCC' .and. lcomps(i).ne.'0') iccc=1
	enddo
	write(22,*)' '
	write(22,*)' '
	write(22,*)' '
	write(22,*)' '
	write(22,*)' '
	if (iccc.eq.1) then
	   write(22,*)'De CCC (LED) cables komen boven op de RPC'
	   write(22,*)'lengte nog niet duidelijk: dus zeer lang laten'
	else
	write(22,*)' '
	write(22,*)' '
	endif
	write(22,*)' '
	if (ipro.eq.1) then
	   write(22,*)'De projective platform posities worden op '
	   write(22,*)'de volgende pagina afgedrukt '
	else
	   write(22,*)' '
	endif
	do i=1,15
	   write(22,*)' '
	enddo


	chbol='bol'//atlasname(9:12)
	chfile=chbol//'_pro.txt'
	open(21,file=chfile)
 10	continue
	read(21,'(a)',END=20)aline
	write(22,*)aline
	goto 10
 20	continue
	close(21)

	end

	subroutine prilist()
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr
	character*18 lab(4)
	character*2 rem1
	character*3 rem
	character*80 lc
	   lab(1)='                  '
	   lab(2)='                  '
	   lab(3)='                  '
	   lab(4)='                  '
	   il=1
	do i=1,nlables
	   if (lcomps(i).ne.'0') then
	      rem='   '
	      if (lcomps(i).ne.'1') then
		 lc=lcomps(i)
		 rem1='('//lc(1:1)
		 rem=rem1//')'
	      endif
	      lab(il)=rem//lables(i)
	      il=il+1
	   endif
	   if (il.eq.5 .or. i.eq.nlables) then
	      write(22,*)lab(1),lab(2),lab(3),lab(4)
	      lab(1)='                  '
	      lab(2)='                  '
	      lab(3)='                  '
	      lab(4)='                  '
	      il=1
	   endif
	enddo
	end


	subroutine prislots()
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr
	character*80 lab
	character*20 led
	character*5 slots(100)
	character*20 leds(100)
	integer iwrite(100)


	slots(1)='  1A'
	slots(2)='  1B'
	slots(3)='  2A'
	slots(4)='  2B'
	slots(5)='  3A'
	slots(6)='  3B'
	slots(7)='  4A'
	slots(8)='  4B'
	slots(9)='  5A'
	slots(10)='  5B'
	slots(11)='  5A'
	slots(12)='  5B'
	slots(13)='  6A'
	slots(14)='  6B'
	slots(15)='  7A'
	slots(16)='  7B'
	slots(17)='  8A'
	slots(18)='  8B'


	leds(1)='RL_INP_HV1'
	leds(2)='RL_INP_HV2'
	leds(3)='RL_INP_HV3'
	leds(4)='RL_INP_HV4'
	leds(5)='RL_PRA_AHV'
	leds(6)='RL_PRA_ARO'
	leds(7)='RL_PRA_CHV'
	leds(8)='RL_PRA_CRO'
	leds(9)='RL_AXI_AHV'
	leds(10)='RL_AXI_ARO'
	leds(11)='RL_AXI_CHV'
	leds(12)='RL_AXI_CRO'
	leds(13)='RL_PRO_HV'
	leds(14)='RL_PRO_RO'
	leds(15)='SL_REF_HV'
	leds(16)='SL_REF_RO'
	leds(17)='SL_CCC_HV'
	leds(18)='SL_CCC_RO'
	leds(19)='          '

	write(22,*)'LED RASMUX SLOTS: (plak op kamer!) '
	write(22,*)'     LED RASMUX SLOTS ',atlasname
	write(22,*)'     ',slots(1),' : ',leds(1)
	write(22,*)'     ',slots(2),' : ',leds(2)
	write(22,*)'     ',slots(3),' : ',leds(3)
	write(22,*)'     ',slots(4),' : ',leds(4)

	do j=5,18
	   iwrite(j)=0
	   do i=1,nlables
	      if (lcomps(i).ne.'0') then
		 lab=lables(i)
		 led=leds(j)
		 if (led(1:9).eq.lab(1:9)) then
		    write(22,*)'     ',slots(j),' : ',leds(j)
		    iwrite(j)=1
		 endif
	      endif
	   enddo

	   if ((j.lt.9) .or. (j.gt.10)) then
	      if (j.eq.11) then
		 if (iwrite(11).eq.0 .and. (iwrite(9).eq.0))
     +                write(22,*)'     ',slots(11),' : ',leds(19)
	      else if (j.eq.12) then
		 if (iwrite(12).eq.0 .and. (iwrite(10).eq.0))
     +                write(22,*)'     ',slots(12),' : ',leds(19)
	      else if (iwrite(j).eq.0) then 
		 write(22,*)'     ',slots(j),' : ',leds(19)
	      endif
	   endif
	enddo
	end



	subroutine prirasmux()
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
     	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr
	character*80 lc

	   write(22,*)'Standard RASMUX LED CALBING SCHEMA blz. 17 '
	   write(22,*)'Standard RASMUX CAMERA CALBING SCHEMA blz. 16 (tekening)
     +  en blz. 25 (lijst) '


C 1Axx en 1Axx no 13
	if ((atlasname(9:9).eq.'1') .and.
     +     (atlasname(11:12).ne.'13') )  then
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 41 '
	endif

C BOl2 A+C met pro
	if ((atlasname(9:9).eq.'2') .and.
     +     (atlasname(11:12).ne.'13') )  then
	   write(22,*)'RASMUX CAMERA vol (geen plek voor RC_PRO_xxx cable).'
           write(22,*)' Maak patchpanel.'
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 41 '
	endif

C BOl3 A+C met pro
	if ((atlasname(9:9).eq.'3') .and.
     +     (atlasname(11:12).eq.'13') )  then
	   write(22,*)'RASMUX CAMERA vol (geen plek voor RC_PRO_xxx cable).'
           write(22,*)' Maak patchpanel.'
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 42 '
	endif

C BOl4 A+C met pro
	if ((atlasname(9:9).eq.'4') .and.
     +     (atlasname(11:12).eq.'13') )  then
	   write(22,*)'RASMUX CAMERA vol (geen plek voor RC_PRO_xxx cable).'
           write(22,*)' Maak patchpanel.'
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 42 '
	endif

C BOl4 A+C met pro
	if ((atlasname(9:9).eq.'4') .and.
     +     (atlasname(11:12).ne.'13') )  then
	   write(22,*)'RASMUX CAMERA vol (geen plek voor RC_PRO_xxx cable).'
           write(22,*)' Maak patchpanel (wordt later 2de rasmux).'
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 43 '
	endif

C BOl6 A+C met pro
	if ((atlasname(9:9).eq.'6') .and.
     +     ((atlasname(11:12).ne.'15').and.(atlasname(11:12).ne.'11')) )
     +     then
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 44 '
	endif

	if ((atlasname(9:9).eq.'6') .and.
     +     ((atlasname(11:12).eq.'11').or.(atlasname(11:12).ne.'15')) )
     +     then
	   write(22,*) 'Voor deze kamer SPECIAAL RASMUX SCHEMA: See blz 45 '
	endif

	end



	subroutine pripraxilable(ipri)
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr

	
	character*11 lab1,lab2,lab3,lab4,
     +               plab1,plab2,plab3,plab4
	character*16 space
	space=''
	if (ipri.eq.1) then
C Cameraas C side
	    lab1='RC_PRA_CRO'
	    lab2='RC_PRA_CHV'
	    lab3='RC_AXI_CRO'
	    lab4='RC_AXI_CHV'
	   plab1='          '
	   plab2='          '
	   plab3='          '
	   plab4='          '
	   do i=1,nlables
	      if ((lables(i).eq.lab1) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab1
		 plab1=lab1
	      endif
	      if ((lables(i).eq.lab2) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab2
		 plab2=lab2
	      endif
	      if ((lables(i).eq.lab3) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab3
		 plab3=lab3
	      endif
	      if ((lables(i).eq.lab4) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab4
		 plab4=lab4
	      endif

	   enddo
	   write(22,*)'       | ',plab3, plab1,space, plab2, plab4,' | '

C Leds C side
	    lab1='RL_PRA_CRO'
	    lab2='RL_PRA_CHV'
	    lab3='RL_AXI_CRO'
	    lab4='RL_AXI_CHV'
	   plab1='          '
	   plab2='          '
	   plab3='          '
	   plab4='          '
	   do i=1,nlables
	      if ((lables(i).eq.lab1) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab1
		 plab1=lab1
	      endif
	      if ((lables(i).eq.lab2) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab2
		 plab2=lab2
	      endif
	      if ((lables(i).eq.lab3) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab3
		 plab3=lab3
	      endif
	      if ((lables(i).eq.lab4) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab4
		 plab4=lab4
	      endif

	   enddo
	   write(22,*)'       | ',plab3, plab1,space, plab2, plab4,' | '
	endif			! ipri=1


	if (ipri.eq.2) then
C Cameraas A side
	    lab1='RC_PRA_ARO'
	    lab2='RC_PRA_AHV'
	    lab3='RC_AXI_ARO'
	    lab4='RC_AXI_AHV'
	   plab1='          '
	   plab2='          '
	   plab3='          '
	   plab4='          '
	   do i=1,nlables
	      if ((lables(i).eq.lab1) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab1
		 plab1=lab1
	      endif
	      if ((lables(i).eq.lab2) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab2
		 plab2=lab2
	      endif
	      if ((lables(i).eq.lab3) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab3
		 plab3=lab3
	      endif
	      if ((lables(i).eq.lab4) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab4
		 plab4=lab4
	      endif

	   enddo
	   write(22,*)'       | ',plab3, plab1,space, plab2, plab4,' | '

C Leds C side
	    lab1='RL_PRA_ARO'
	    lab2='RL_PRA_AHV'
	    lab3='RL_AXI_ARO'
	    lab4='RL_AXI_AHV'
	   plab1='          '
	   plab2='          '
	   plab3='          '
	   plab4='          '
	   do i=1,nlables
	      if ((lables(i).eq.lab1) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab1
		 plab1=lab1
	      endif
	      if ((lables(i).eq.lab2) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab2
		 plab2=lab2
	      endif
	      if ((lables(i).eq.lab3) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab3
		 plab3=lab3
	      endif
	      if ((lables(i).eq.lab4) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab4
		 plab4=lab4
	      endif

	   enddo
	   write(22,*)'       | ',plab3, plab1,space, plab2, plab4,' | '
	endif			! ipri=2

	end




	subroutine priccclable(ipri)
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr

	
	character*11 lab1,lab2,lab3,lab4,
     +               plab1,plab2,plab3,plab4
	character*18 space
	integer acham
	space=''
	acham=1
	if (atlasname(10:10).eq.'C') acham=0

	if ( ((acham.eq.1) .and. (ipri.eq.1)) .or.
     +             ((acham.eq.0) .and. (ipri.eq.2)) ) then
C Leds C side
	    lab1='SL_CCC_RO'
	    lab2='SL_CCC_HV'
	   plab1='         '
	   plab2='         '
	   do i=1,nlables
	      if ((lables(i).eq.lab1) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab1
		 plab1=lab1
	      endif
	      if ((lables(i).eq.lab2) .and. (lcomps(i).ne.'0')) then
		 if (lcomps(i).ne.'1') print *,'unknown flag ',lab2
		 plab2=lab2
	      endif
	   enddo
	   write(22,*)'       | ',plab1,space, space, '  ',plab2,' | '
	else
C Leds A side --NO CCC LEDS
	   plab1='          '
	   plab2='          '
	   write(22,*)'       | ',plab1,space, space,'  ', plab2,' | '
	endif			! ipri=2

	end





	subroutine priprolable(ipri)
	common /caap/lables,lcomps,atlasname, 
     +               nlables,ncomps, nikhefnr
	character*80 lables(100),lcomps(100)
	character*40 atlasname
        integer nlables, ncomps, nikhefnr

	
	character*11 lab1,lab2,lab3,lab4,
     +               plab1,plab2,plab3,plab4
	character*16 space
	space=''
	
        lab1='RC_PRO_RO'
        lab2='RC_PRO_HV'
        lab3=''
        lab4=''
        plab1='          '
        plab2='          '
        plab3='          '
        plab4='          '

	do i=1,nlables
	   if ((lables(i).eq.lab1) .and. (lcomps(i).ne.'0')) then
	      if (.not.((lcomps(i).eq.'1').or.
     +                  (lcomps(i).ne.'2').or.
     +                  (lcomps(i).ne.'3')) )
     +			 print *,'unknown flag ',lab1
	      plab1=lab1
	   endif
	   if ((lables(i).eq.lab2) .and. (lcomps(i).ne.'0')) then
	      if (.not.((lcomps(i).eq.'1').or.
     +                  (lcomps(i).ne.'2').or.
     +                  (lcomps(i).ne.'3')) )
     +			 print *,'unknown flag ',lab2
	      plab2=lab2
	   endif
	   
	enddo
C for BOL1A type C side
	if (ipri.eq.1) then 
	plab3=plab1
	plab4=plab2
	if (atlasname(9:10).ne.'1A') then
	   plab3='          '
	   plab4='          '
	endif
	write(22,*)'             ',plab3,
     +  '                              ',plab4
C for BOL1C type A side
	else if (ipri.eq.4) then 
	plab3=plab1
	plab4=plab2
	if (atlasname(9:10).ne.'1C') then
	   plab3='          '
	   plab4='          '
	endif
	write(22,*)'             ',plab3,
     +  '                              ',plab4
C for BOL2,4A type (A side) and 6 C
	else if (ipri.eq.2) then
	plab3=plab1
	plab4=plab2
	if (.not.((atlasname(9:10).eq.'2A') .or.
     +           (atlasname(9:10).eq.'4A').or.
     +           (atlasname(9:10).eq.'3C').or.
     +           (atlasname(9:10).eq.'6C') )) then
	   plab3='          '
	   plab4='          '
	endif
	write(22,*)'  ',plab3,'                       
     +                               ',plab4
C for BOL6A type (Cside) and 2,4C
	else if (ipri.eq.3) then
	plab3=plab1
	plab4=plab2
	if (.not.( (atlasname(9:10).eq.'6A').or.
     +	     (atlasname(9:10).eq.'3A').or.
     +	     (atlasname(9:10).eq.'4C').or.
     +	     (atlasname(9:10).eq.'2C') ) )then
	   plab3='          '
	   plab4='          '
	endif
	write(22,*)'  ',plab3,'                       
     +                               ',plab4
	endif
	end
	
