C-------------------------------------------------------------------------- subroutine ftrsim(ounit,bitpix,naxis,naxes,status) C resize an existing primary array or IMAGE extension C ounit i fortran output unit number C bitpix i number of bits per data value C naxis i number of axes in the data array C naxes i array giving the length of each data axis C status i returned error status (0=ok) C written by Wm Pence, HEASARC/GSFC, July 1997 integer ounit,bitpix,naxis,naxes(*),status integer i,bytlen,nblock,minax integer nsize,osize,obitpx,onaxis,onaxes(99),pcount,gcount logical simple,extend character*8 keynm if (status .gt. 0)return call ftghpr(ounit,99,simple,obitpx,onaxis,onaxes, & pcount,gcount,extend,status) if (status .gt. 0)return C check for error conditions if (naxis .lt. 0 .or. naxis .gt. 999)then status=212 return end if C test that bitpix has a legal value and set the datatype code value 5 if (bitpix .eq. 8)then bytlen=1 else if (bitpix .eq. 16)then bytlen=2 else if (bitpix .eq. 32)then bytlen=4 else if (bitpix .eq. -32)then bytlen=4 else if (bitpix .eq. -64)then bytlen=8 else C illegal value of bitpix status=211 return end if C calculate the number of pixels in the new image if (naxis .eq. 0)then C no data nsize=0 else nsize=1 do 10 i=1,naxis if (naxes(i) .ge. 0)then nsize=nsize*naxes(i) else status=213 return end if 10 continue end if C calculate the number of pixels in the old image if (onaxis .eq. 0)then C no data osize=0 else osize=1 do 15 i=1,onaxis if (onaxes(i) .ge. 0)then osize=osize*onaxes(i) else status=213 return end if 15 continue end if C sizes of old and new images, in bytes osize=(osize+pcount) * gcount * abs(obitpx)/8 nsize=(nsize+pcount) * gcount * bytlen C sizes of old and new images, in blocks osize=(osize+2879)/2880 nsize=(nsize+2879)/2880 C insert or delete blocks, as necessary if (nsize .gt. osize)then nblock=nsize-osize call ftiblk(ounit,nblock,1,status) else if (osize .gt. nsize)then nblock=osize-nsize call ftdblk(ounit,nblock,1,status) end if if (status .gt. 0)return C update the header keywords if (bitpix .ne. obitpx)then call ftmkyj(ounit,'BITPIX',bitpix,'&',status) end if if (naxis .ne. onaxis)then call ftmkyj(ounit,'NAXIS',naxis,'&',status) end if C update all the existing keywords minax=min(naxis,onaxis) do 20 i=1,minax call ftkeyn('NAXIS',i,keynm,status) call ftmkyj(ounit,keynm,naxes(i),'&',status) 20 continue if (naxis .gt. onaxis)then C insert more NAXISn keywords do 25 i=onaxis+1,naxis call ftkeyn('NAXIS',i,keynm,status) call ftikyj(ounit,keynm,naxes(i), & 'length of data axis',status) 25 continue else if (onaxis .gt. naxis)then C delete old NAXISn keywords do 30 i=naxis+1,onaxis call ftkeyn('NAXIS',i,keynm,status) call ftdkey(ounit,keynm,status) 30 continue end if C re-read the header, to make sure structures are updated call ftrdef(ounit,status) end