unsigned variables in f77 ???

John D Mccalpin mccalpin at vax1.acs.udel.EDU
Mon Jun 11 01:10:23 AEST 1990


I am working with lots of 8-bit image data that I want to transfer
rapidly to the screen using an f77 program.  Since RECTWR wants
16-bit data, I have to copy the 8-bit data to a 16-bit array.
Unfortunately, f77 considers the 8-bit (integer*1) data to be 
signed, and so it does sign extension in the transfer to the
integer*2 array.  Is there any clean way of turning this off?
(Without coding in C!)

My workaround is based on the old FORTRAN trick of adding an
extra dimension of 2 at the beginning of the array an using
that to refer to the real and imaginary parts, only here I use
it to refer to the high and low bytes of the 16-bit pixel values.
In the production code, I collapse the DO loops and unroll them
to a depth of 4 to decrease the overhead.

Anybody have any better ideas?

	subroutine putpix(irec)
	parameter (n=512)
	integer*1 byte(n,n)
	integer*1 pixel(2,n,n)
	logical first
	save pixel,first
	data first /.true./

	if (first) then			! clear high-order bytes
	    do 2 j=1,n
		do 1 i=1,n
		    pixel(1,i,j) = 0
    1		continue
    2 	    continue
	    first = .false.
	endif

*	----- get data -----
	read (iunit,rec=irec) byte

*	----- copy array byte to low-order bytes of array pixel -----
	do 20 j=1,n
	    do 10 i=1,n
		pixel(2,i,j) = byte(i,j)
   10	    continue
   20	continue

*	----- send to pix buffer -----
	call rectwr(1,1,n,n,pixel)

	return
	end
-- 
John D. McCalpin                               mccalpin at vax1.udel.edu
Assistant Professor                            mccalpin at delocn.udel.edu
College of Marine Studies, U. Del.             mccalpin at scri1.scri.fsu.edu



More information about the Comp.sys.sgi mailing list