C---------------------------------------------------------------------- subroutine ftgrsz(iunit,nrows,status) C Returns an optimal value for the number of rows that should be C read or written at one time in a binary table for maximum efficiency. C Accessing more rows than this may cause excessive flushing and C rereading of buffers to/from disk. C iunit i fortran unit number C nrows i optimal number of rows to access C status i output error status C C written by Wm Pence, HEASARC/GSFC, December, 1996 integer iunit,nrows,status C COMMON BLOCK DEFINITIONS:-------------------------------------------- integer nb,nf,ne,pb parameter (nb = 20) parameter (nf = 3000) parameter (ne = 512) parameter (pb = 20) 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) integer buflun,currnt,reclen,bytnum,maxrec common/ftlbuf/buflun(nb),currnt(nb),reclen(nb), & bytnum(nb),maxrec(nb) C END OF COMMON BLOCK DEFINITIONS----------------------------------- integer ibuff, ii, jj, unique, nfiles C There are pb internal buffers available each reclen(nb) bytes long ibuff=bufnum(iunit) C if HDU structure is not defined then scan the header keywords if (dtstrt(ibuff) .lt. 0)call ftrdef(iunit,status) if (status .gt. 0)return C determine how many different FITS files are currently open nfiles = 0 do 20 ii = 1,nb unique = 1 do 10 jj = 1, ii-1 if (buflun(ii) .le. 0 .or. buflun(ii) .eq. buflun(jj))then unique = 0 go to 15 end if 10 continue 15 continue if (unique .eq. 1)nfiles=nfiles+1 20 continue C one buffer (at least) is always allocated to each open file. C assume record size is 2880 bytes (not necessarily true on Vax) nrows = ((pb - nfiles) * 2880) / max(1,rowlen(ibuff)) nrows = max(1, nrows) end