aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/fitsio/ftchfl.f
blob: 9da242785a68a8f9cc1f4cbd0d16973f2780fc9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
C----------------------------------------------------------------------
        subroutine ftchfl(iunit,status)

C       Check Header Fill values
C       Check that the header unit is correctly filled with blanks from the
C       END card to the end of the current FITS 2880-byte block

C       iunit   i  fortran unit number
C       status  i  output error status
C
C       written by Wm Pence, HEASARC/GSFC, June, 1994

        integer iunit,status

C       COMMON BLOCK DEFINITIONS:--------------------------------------------
        integer nb,ne
        parameter (nb = 20)
        parameter (ne = 200)
        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
C       END OF COMMON BLOCK DEFINITIONS-----------------------------------

        integer ibuff,nblank,i,endpos
        character*80 rec
        logical gotend

        if (status .gt. 0)return

        ibuff=bufnum(iunit)

C       calculate the number of blank keyword slots in the header
        endpos=hdend(ibuff)
        nblank=(dtstrt(ibuff)-endpos)/80
C       move the i/o pointer to the end of the header keywords
        call ftmbyt(iunit,endpos,.true.,status)
C       find the END card (there may be blank keywords perceeding it)

        gotend=.false.
        do 10 i=1,nblank
                call ftgcbf(iunit,1,80,rec,status)
                if (rec(1:8) .eq. 'END     ')then
                       if (gotend)then
C                          there is a duplicate END record
                           status=254
             call ftpmsg('Warning: Header fill area contains '//
     &       'duplicate END card:')
                       end if
                       gotend=.true.
                       if (rec(9:80) .ne. ' ')then
C                          END keyword has extra characters
                           status=253
            call ftpmsg('Warning: END keyword contains '//
     &      'extraneous non-blank characters:')
                       end if
                 else if (gotend)then
                       if (rec .ne. ' ')then
C                          The fill area contains extraneous characters
                           status=254
             call ftpmsg('Warning: Header fill area contains '//
     &       'extraneous non-blank characters:')
                        end if
                end if

                if (status .gt. 0)then
                           call ftpmsg(rec)
                           return
                end if
10      continue
        end