C SUBROUTINE FHEDR0 C C PURPOSE C TO SET OR READ BASIC FITS HEADER DATA C C USAGE C CALL FHEDR0(RBUF,NLINES,LTYPE,BITPIX,NAX,NAXES,NEND,MODE) C C PARAMETERS C RBUF - BUFFER FOR FITS HEADER C NLINES - MAXIMUM NUMBER OF LINES OF FITS HEADER DATA (MODE=0) C LTYPE - LOGICAL TYPE (SIMPLE) C BITPIX - INTEGER*4 VALUE FOR # BIT PER PIXEL (BITPIX) C NAX - NUMBER OF AXES C NAXES - INTEGER*4 ARRAY FOR DIMENSIONS OF NAX AXES. C NEND - WHEN MODE = 0 CONTAINS LINE NUMBER WITH 'END' KEYWORD' C WHEN MODE = 1 CONTAINS LINE NUMBER FOR NEXT FITS DATA C MODE - DETERMINES READING OR WRITING TO BUFFER C 0 - READ (OR DECODE FROM BUFFER) C 1 - WRITE TO BUFFER C IERR - ERROR RETURN C SUBROUTINE FHEDR0(RBUF,NLINES,LTYPE,BITPIX,NAX,NAXES,NEND,MODE, 1IERR) INTEGER*4 BITPIX,NAX,NAXES(1),NEND,MODE,IERR LOGICAL LTYPE CHARACTER*8 RSIMP,RBITP,RNAXI,RTEMP,REND CHARACTER*(*) RBUF(*) DATA RSIMP,RBITP,RNAXI,REND/'SIMPLE ','BITPIX ','NAXIS ', 1'END '/ IERR=1 IF (MODE .EQ. 0) THEN C WRITE (5,'(1X,A)') RBUF(1) C WRITE (5,'(1X,A)') RBUF(2) C WRITE (5,'(1X,A)') RBUF(3) C WRITE (5,'(1X,A,A)') RBUF(1)(1:8),RSIMP IF (RBUF(1)(1:8) .EQ. RSIMP) THEN DECODE(80,901,RBUF(1),ERR=89) LTYPE ELSE IERR=-1 RETURN ENDIF IF (RBUF(2)(1:8) .EQ. RBITP) THEN DECODE(80,902,RBUF(2),ERR=89) BITPIX ELSE IERR=-3 RETURN ENDIF IF (RBUF(3)(1:8) .EQ. RNAXI) THEN DECODE(80,902,RBUF(3),ERR=89) NAX ELSE IERR=-4 RETURN ENDIF IF (NAX .LT. 1 .OR. NAX .GT. 9) THEN IERR=-5 RETURN ENDIF DO I=1,NAX ENCODE (8,908,RTEMP,ERR=89) I IF (RBUF(3+I)(1:8) .EQ. RTEMP) THEN DECODE (80,902,RBUF(3+I),ERR=89) NAXES(I) ELSE IERR=-6 RETURN ENDIF ENDDO NEND=0 DO I=4+NAX,NLINES IF (RBUF(I)(1:8) .EQ. REND) THEN NEND=I RETURN ENDIF ENDDO IERR=0 RETURN 89 IERR=-2 RETURN C ELSE 100 ENCODE (80,911,RBUF(1)) RSIMP,LTYPE ENCODE (80,912,RBUF(2)) RBITP,BITPIX ENCODE (80,912,RBUF(3)) RNAXI,NAX DO 110 I=1,NAX ENCODE (80,919,RBUF(I+3)) I,NAXES(I) 110 CONTINUE NEND=4+NAX RETURN ENDIF 901 FORMAT (28X,L2,50X) 902 FORMAT (16X,I14,50X) 908 FORMAT ('NAXIS',I1,2X) 911 FORMAT (A,'= ',18X,L2,' /',48X) 912 FORMAT (A,'= ',I20,' /',48X) 919 FORMAT ('NAXIS',I1,' = ',I20,' /',48X) END