C---------------------------------------------------------------------- subroutine ftpi2b(ounit,nvals,incre,i2vals,status) C Write an array of Integer*2 bytes to the output FITS file. C Does any required translation from internal machine format to FITS. integer nvals,incre,ounit,status,offset integer*2 i2vals(nvals) C ounit i fortran unit number C nvals i number of pixels in the i2vals array C incre i byte increment between values C i2vals i*2 array of input integer*2 values C status i output error status integer*2 temp(4) integer ierr,cray2ieg,remain integer compid common/ftcpid/compid character ctemp*1 if (compid .eq. 0)then C big endian machine (e.g., SUN) doesn't need byte swapping else if (compid .eq. -1)then C SUN F90 compiler maps I*2 -> I*4; have to pack bytes call ftpki2(i2vals,nvals,ctemp) else if (compid .ge. 1)then C little endian machine (e.g. DEC, VAX, or PC) must be byte swapped call ftswby(i2vals,nvals) else C must be a CRAY C convert from cray I*8 to IEEE I*2 C there is a bug in cray2ieg if the number of values to convert C is 1 less than a multiple of 4 2-byte words. (3, 7, 11, etc) remain=nvals-nvals/4*4 if (remain .eq. 3)then if (nvals .gt. 3)then ierr= cray2ieg(7,nvals-3,i2vals,0,i2vals,1,' ') end if temp(3)=i2vals(nvals) temp(2)=i2vals(nvals-1) temp(1)=i2vals(nvals-2) ierr=cray2ieg(7,4,i2vals(nvals/4+1),0,temp,1,' ') else ierr=cray2ieg(7,nvals,i2vals,0,i2vals,1,' ') end if end if if (incre .le. 2)then call ftpbyt(ounit,nvals*2,i2vals,status) else C offset is the number of bytes to move between each value offset=incre-2 call ftpbyo(ounit,2,nvals,offset,i2vals,status) end if end