c
c  binary out data
c
c
      PROGRAM bin_in
      INTEGER i, j, k, ni, nj, timestep, startstep, endstep, isp
      REAL f(1:256,1:512)
      REAL*8 plasma_freq
      CHARACTER*1 num(0:9)
      CHARACTER*11 file_in, file_out
      CHARACTER*10 file_name
	  character*12 file_name_isp
      CHARACTER*4 real_time
      DATA num  /'0','1','2','3','4','5','6','7','8','9'/
c      ni=256
c      nj=512
      isp=6
      plasma_freq=1.170d0
      startstep = 0
      endstep = 500
c	  endstep = 500

      open(30,file='test.gpl', status='unknown')
      WRITE(30, *) 'reset'
      WRITE(30, *) 'set terminal postscript eps enh color'
     &              // '"Times-Roman" 20'
      WRITE(30, *) 'set size 1*1'
c      WRITE(30, *) 'set size ratio 2'
c      WRITE(30, *) 'set xrange[0:256]'
c      WRITE(30, *) 'set yrange[-0.3e+14:0.3e+14]'
c      WRITE(30, *) 'set zrange[0:5.0e+23]'
c      WRITE(30, *) 'set cbrange[0:5.0e+23]'
c      WRITE(30, *) 'set palette defined '
c     &            //'( 0 "green", 1 "blue", 2 "red", 3 "orange" )'
c      WRITE(30, *) 'set palette rgbformulae 22, 13, -31'
c      WRITE(30, *) 'set view 60,128'
c      WRITE(30, *) 'set xtics 64'
c      WRITE(30, *) 'set ytics 64'
      WRITE(30, *) 'set log y'
      WRITE(30, *) 'set ticslevel 0'
c      WRITE(30, *) 'set xlabel "Real x [{/Symbol m}m]"'
c      WRITE(30, *) 'set ylabel "Density"'
c      WRITE(30, *) 'set pm3d map'
c      WRITE(30, *) 'set pm3d'
c      WRITE(30, *) 'set hidden3d'
c      WRITE(30, *) 'set format cb "%6.1e"'
c      WRITE(30, *) 'set format z "%6.1e"'
c      WRITE(30, *) 'set nosurface'
      WRITE(30, *) 'set style line 1 linetype 1' 
     &           //' linecolor rgb "red" linewidth 10'
cc      WRITE(30, *) 'set style line 2 linetype 1' 
cc     &           //' linecolor rgb "blue" linewidth 10'
cc      WRITE(30, *) 'set style line 3 linetype 1' 
cc     &           //' linecolor rgb "green" linewidth 10'

      DO 99 timestep=startstep, endstep
      file_name='fEilog'//num(mod(timestep/1000, 10))
     &              //num(mod(timestep/100, 10))
     &              //num(mod(timestep/10, 10))
     &              //num(mod(timestep, 10))
	 
	  rtimestep=timestep/plasma_freq
      real_time=num(mod(rtimestep/1000, 10))
     &        //num(mod(rtimestep/100, 10))
     &        //num(mod(rtimestep/10, 10))
     &        //num(mod(rtimestep, 10))

c      WRITE(30, '(a,I3,a)') 'set view 60,',360*timestep/endstep,''
      WRITE(30, *) 'set output "',file_name,'.eps"'
      WRITE(30, *) 'set title "fEilog ',real_time,' [fs]"'
     &              //' font "Times-Roman,30"'
c      WRITE(30, *) 'plot "',file_name,'.txt"'
      WRITE(30, *) 'plot "',file_name,'.txt"'
     &                         //' using 1:2 w l ls 1'
c     &      //'"',file_name,'.txt" using 1:3 w l ls 2 ti "x=120",'
c     &      //'"',file_name,'.txt" using 1:4 w l ls 3 ti "x=140"'

  99  continue

      DO 98 i=1, isp
      DO 97 timestep=startstep, endstep
      file_name_isp='fEilog'//num(mod(i/10,10))
     &              //num(mod(i,10))
     &              //num(mod(timestep/1000, 10))
     &              //num(mod(timestep/100, 10))
     &              //num(mod(timestep/10, 10))
     &              //num(mod(timestep, 10))
	 
	  rtimestep=timestep/plasma_freq
      real_time=num(mod(rtimestep/1000, 10))
     &        //num(mod(rtimestep/100, 10))
     &        //num(mod(rtimestep/10, 10))
     &        //num(mod(rtimestep, 10))

      WRITE(30, *) 'set output "',file_name_isp,'.eps"'
      WRITE(30, *) 'set title "fEilog ',real_time,' [fs]"'
     &              //' font "Times-Roman,30"'
      WRITE(30, *) 'plot "',file_name_isp,'.txt"'
     &                         //' using 1:2 w l ls 1'
  97  continue
  98  continue
      close(30)
      end