C---------------------------------------------------------------------- subroutine ftpclu(ounit,colnum,frow,felem,nelem,status) C set elements of a table to be undefined C ounit i fortran unit number C colnum i number of the column to write to C frow i first row to write C felem i first element within the row to write C nelem i number of elements to write C status i output error status C C written by Wm Pence, HEASARC/GSFC, June 1991 integer ounit,colnum,frow,felem,nelem,status C COMMON BLOCK DEFINITIONS:-------------------------------------------- integer nf,nb,ne parameter (nb = 20) parameter (nf = 3000) parameter (ne = 512) integer bufnum,chdu,hdutyp,maxhdu,hdstrt,hdend,nxthdr,dtstrt integer nxtfld logical wrmode common/ft0001/bufnum(199),chdu(nb),hdutyp(nb),maxhdu(nb), & wrmode(nb),hdstrt(nb,ne),hdend(nb),nxthdr(nb),dtstrt(nb),nxtfld integer tfield,tstart,tbcol,rowlen,tdtype,trept,tnull,heapsz integer theap double precision tscale,tzero common/ft0002/tfield(nb),tstart(nb),tbcol(nf),rowlen(nb), & tdtype(nf),trept(nf),tscale(nf),tzero(nf),tnull(nf),heapsz(nb) & ,theap(nb) character cnull*16, cform*8 common/ft0003/cnull(nf),cform(nf) character snull*500 character*1 xdummy(31500) common/ftheap/snull,xdummy C END OF COMMON BLOCK DEFINITIONS----------------------------------- integer bytpix,bstart,i4null(2),tcode,nchars,i,offset,nulval integer ibuff,ntodo,itodo,repeat,rstart,estart integer*2 i2null,i1 integer rnull(2) logical descrp character*1 i1null character messge*80 if (status .gt. 0)return if (frow .lt. 1)then write(messge,1001)frow 1001 format('Starting row number is out of range: ',i10) call ftpmsg(messge) status = 307 return else if (felem .lt. 1)then write(messge,1002)felem 1002 format('Starting element number is out of range: ',i10) call ftpmsg(messge) status = 308 return else if (nelem .lt. 0)then write(messge,1003)nelem 1003 format('Negative no. of elements to read or write: ',i10) call ftpmsg(messge) status = 306 return else if (nelem .eq. 0)then return end if ibuff=bufnum(ounit) C if HDU structure is not defined then scan the header keywords if (dtstrt(ibuff) .lt. 0)call ftrdef(ounit,status) if (colnum .lt. 1 .or. colnum .gt. tfield(ibuff))then write(messge,1004)colnum 1004 format('Specified column number is out of range: ',i10) call ftpmsg(messge) status = 302 return end if tcode=tdtype(colnum+tstart(ibuff)) bytpix=max(abs(tcode)/10,1) descrp=.false. ntodo=nelem rstart=frow-1 estart=felem-1 i1=1 if (tcode .eq. 16)then C this is an ASCII field repeat=trept(colnum+tstart(ibuff)) if (felem .gt. repeat)then C illegal element number write(messge,1005)felem 1005 format( & 'Starting element number is greater than repeat: ',i10) call ftpmsg(messge) status = 308 return end if if (cnull(colnum+tstart(ibuff))(1:1) .eq. char(1))then C error: null value has not been defined status=314 call ftpmsg('Null value string for ASCII table'// & ' column has not yet been defined (FTPCLU).') return end if C the TNULL parameter stores the width of the character field bytpix=tnull(colnum+tstart(ibuff)) else C this is a binary table nulval=tnull(colnum+tstart(ibuff)) if (tcode .gt. 0)then if (hdutyp(ibuff) .eq. 0)then C if this is a primary array or image extension, then C set repeat as large as needed to write all C the pixels. This prevents an error message if C array size is not yet known. The actual array C dimension must be defined by the NAXISn keywords C before closing this HDU. repeat=estart+nelem else repeat=trept(colnum+tstart(ibuff)) end if if (felem .gt. repeat)then C illegal element number write(messge,1004)felem call ftpmsg(messge) status = 308 return end if else C this is a variable length descriptor column descrp=.true. tcode=-tcode C read the number of elements and the starting offset: call ftgdes(ounit,colnum,frow,repeat, & offset,status) if (ntodo+estart .gt. repeat)then C error: tried to write past end of record status=319 return end if C move the i/o pointer to the start of the pixel sequence bstart=dtstrt(ibuff)+offset+ & theap(ibuff)+estart*bytpix call ftmbyt(ounit,bstart,.true.,status) end if if (tcode.eq.11 .or. tcode.eq.21 .or. tcode.eq.41)then if (nulval .eq. 123454321)then C error: null value has not been defined status=314 call ftpmsg('Null value for integer'// & ' column has not yet been defined (FTPCLU).') return end if else C set the floating point Not-a-Number values do 10 i=1,2 rnull(i) = -1 10 continue end if end if C process as many contiguous pixels as possible 20 itodo=min(ntodo,repeat-estart) if (.not. descrp)then C move the i/o pointer to the start of the sequence of pixels bstart=dtstrt(ibuff)+rstart*rowlen(ibuff) & +tbcol(colnum+tstart(ibuff))+estart*bytpix call ftmbyt(ounit,bstart,.true.,status) end if C write the appropriate null value to the pixels if (tcode .eq. 21)then C column data type is I (I*2) do 5 i=1,itodo i2null=nulval call ftpi2b(ounit,1,0,i2null,status) 5 continue else if (tcode .eq. 41)then C column data type is J (I*4) do 15 i=1,itodo i4null(1)=nulval call ftpi4b(ounit,1,0,i4null,status) 15 continue else if (tcode .eq. 42)then C column data type is E (R*4) do 25 i=1,itodo call ftpbyt(ounit,4,rnull,status) 25 continue else if (tcode .eq. 82 .or. tcode .eq. 83)then C column data type is D (R*8), or C complex 2 x R*4 do 35 i=1,itodo call ftpbyt(ounit,8,rnull,status) 35 continue else if (tcode .eq. 16)then C this is an ASCII table column snull=cnull(colnum+tstart(ibuff)) C write up to 500 characters in the column, remainder unchanged C (500 is the maximum size string allowed in IBM AIX compiler) nchars=min(bytpix,500) do 45 i=1,itodo call ftpcbf(ounit,nchars,snull,status) 45 continue else if (tcode .eq. 11)then C column data type is B (byte) i1null=char(nulval) do 55 i=1,itodo call ftpcbf(ounit,1,i1null,status) 55 continue else if (tcode .eq. 163)then C column data type is double complex (M) do 65 i=1,itodo*2 call ftpbyt(ounit,8,rnull,status) 65 continue else if (tcode .eq. 14)then C column data type is logical (L) i4null(1)=0 do 85 i=1,itodo call ftpbyt(ounit,1,i4null,status) 85 continue end if if (status .gt. 0)then write(messge,1006)i1,i1+itodo-1 1006 format('Error writing NULL elements',i9,' thru',i9, & ' (FTPCLU).') call ftpmsg(messge) return end if C find number of pixels left to do, and quit if none left ntodo=ntodo-itodo i1 = i1 + itodo if (ntodo .gt. 0)then C increment the pointers estart=estart+itodo if (estart .eq. repeat)then estart=0 rstart=rstart+1 end if go to 20 end if end