	subroutine prepal(fnaam1,idh,dbin,yvalmin,yvalmax)
C prepare palette for PAW
        character*80 fnaam1
        integer icol(51)

C prepare palette for PAW
       open(35,file=fnaam1)
C dbin nominal=6.
       imax=yvalmax + nint(dbin+1) + 0.1*abs(yvalmax)
       imin=yvalmin - nint(dbin+1) - 0.1*abs(yvalmin)
       if (imax.lt.0) imax=0
       if (imin.gt.0) imin=0
       di=(imax-imin)/dbin
       ni=nint(di)
       if (ni.ge.25) ni=24 ! to much colors
       imin=imax-ni*dbin
	sclose=0.
	close=1000.
       do i=0,ni
         yval=imin+dbin*i
         if (abs(yval).lt.close) then
            close=abs(yval)
            sclose=yval
         endif
	ENDDO
         imin=imin-nint(sclose)
         imax=imax-nint(sclose)
         do i=1,ni
         ylow=imin+dbin*(i-1)
         yval=imin+dbin*i
         dtwo=2.*dbin
         if (abs(yval).le.dbin .and. abs(ylow).le.dbin) then
            icol(i)=3
	 elseif (abs(yval).le.dtwo .and. abs(ylow).le.dtwo) then
            icol(i)=4
         else
            icol(i)=2
         endif
	ENDDO

       write(35,*)'att/pal 1 ',ni,' ',(icol(i),i=1,ni)
       write(35,*)'max ',idh,' ',imax
       write(35,*)'min ',idh,' ',imin
	
	close(35)
	end

