c rainpal.for
c
c creates a pds pallette for color density slice images
c
c Jeff Phillips 8 Aug 91
      dimension n(6)
      character*50 ifile
      print *,'Enter output file name: '
      read(5,100) ifile
  100 format(a)
      open(10,file=ifile,form='formatted',status='unknown')
      print *,'Enter data range (eg. 1 240)'
      read(5,*) n(1),n(6)
      do 20 i=2,5
      n(i)=n(1)+float((i-1)*(n(6)-n(1)))/5.
   20 continue
c
      jm=0
      write(10,*) jm,jm,jm,jm
      do 40 j=1,255
      if (j.lt.n(1)) then
           ir=0
           ig=0
           ib=0
      else if(j.lt.n(2)) then
           ir=0
           ig=float(j-n(1))/float(n(2)-n(1))*255
           ib=255
      else if (j.lt.n(3)) then
           ir=0
           ig=255
           ib=float(n(3)-j)/float(n(3)-n(2))*255
      else if (j.lt.n(4)) then
           ir=float(j-n(3))/float(n(4)-n(3))*255
           ig=255
           ib=0
      else if (j.lt.n(5)) then
           ir=255
           ig=float(n(5)-j)/float(n(5)-n(4))*255
           ib=0
      else if (j.lt.n(6)) then
           ir=255
           ig=0
           ib=float(j-n(5))/float(n(6)-n(5))*255
      else
           ir=255
           ig=255
           ib=255
      endif
      write(10,*) j,ir,ig,ib
   40 continue
      stop
      end
