C ************************************************************************* subroutine readheader(infile,mode,ic,id,jd,quat,frame) C Initializing variables integer status,unit,readwrite,blocksize character infile*80,comment*80 integer naxes(2),nfound integer group,firstpix,nbuffer,npixels real nullval logical anynull integer *4 ic, id, jd, mode real *8 quat(*) integer frame(*) C Initializing specific variables group=1 firstpix=1 nullval=-999 readwrite=0 status=0 C Creating file handle call ftgiou(unit,status) C Open the FITS file previously created by WRITEIMAGE readwrite=0 call ftopen(unit,infile,readwrite,blocksize,status) C Read in the values for specific keywords call ftgknj(unit,'NAXIS',1,2,naxes,nfound,status) call ftgkyj(unit,'CAMERA',ic,comment,status) call ftgkyj(unit,'MODE',mode,comment,status) call ftgknd(unit,'QUAT_',1,4,quat,nfound,status) C Check that it found all keywords in the fits header if (nfound .ne. 4)then print *,'READIMAGE failed to read the NAXISn keywords.' return end if C Initialize variables now that we have information from the file npixels=naxes(1)*naxes(2) nbuffer=naxes(1)*naxes(2) call ftgpvj(unit,group,firstpix,nbuffer,nullval, & frame(firstpix),anynull,status) C Closing handle to file call ftclos(unit, status) call ftfiou(unit, status) if (status .gt. 0)call printerror(status) end C ************************************************************************* subroutine printerror(status) C This subroutine prints out the descriptive text corresponding to the C error status value and prints out the contents of the internal C error message stack generated by FITSIO whenever an error occurs. integer status character errtext*30,errmessage*80 C Check if status is OK (no error); if so, simply return if (status .le. 0)return C The FTGERR subroutine returns a descriptive 30-character text string that C corresponds to the integer error status number. A complete list of all C the error numbers can be found in the back of the FITSIO Users Guide. call ftgerr(status,errtext) print*,'FITSIO Error' C FITSIO usually generates an internal stack of error messages whenever C an error occurs. These messages provide much more information on the C cause of the problem than can be provided by the single integer error C status value. The FTGMSG subroutine retrieves the oldest message from C the stack and shifts any remaining messages on the stack down one C position. FTGMSG is called repeatedly until a blank message is C returned, which indicates that the stack is empty. Each error message C may be up to 80 characters in length. Another subroutine, called C FTCMSG, is available to simply clear the whole error message stack in C cases where one is not interested in the contents. call ftgmsg(errmessage) do while (errmessage .ne. ' ') print *,errmessage call ftgmsg(errmessage) end do end C *************************************************************************