aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/splot/anshdr.x
blob: e314454bdb0c0346476c12a509a919b93d378134 (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
73
74
75
76
77
78
79
80
81
82
83
84
include	<time.h>
include	<fset.h>
include	<smw.h>

# ANS_HDR -- Add answer header in answer file

procedure ans_hdr (sh, newimage, key, fname1, fname2, fd1, fd2)

pointer	sh
int	newimage
int	key
char	fname1[SZ_FNAME]
char	fname2[SZ_FNAME]
int	fd1, fd2

pointer	sp, time
long	clktime()
int	key1, open()
errchk	open
data	key1/0/

begin
	# Check for valid file name
	if (fd1 == NULL && fname1[1] != EOS) {
	    fd1 = open (fname1, APPEND, TEXT_FILE)
	    call fseti (fd1, F_FLUSHNL, YES)
	}
	if (fd2 == NULL && fname2[1] != EOS) {
	    fd2 = open (fname2, APPEND, TEXT_FILE)
	    call fseti (fd2, F_FLUSHNL, YES)
	}

	# Print image name.
	if (newimage == YES) {
	    call smark (sp)
	    call salloc (time, SZ_DATE, TY_CHAR)
	    call cnvdate (clktime(0), Memc[time], SZ_DATE)

	    if (fd1 != NULL) {
		call fprintf (fd1, "\n%s [%s%s]: %s\n")
		    call pargstr (Memc[time])
		    call pargstr (IMNAME(sh))
		    call pargstr (IMSEC(sh))
		    call pargstr (TITLE(sh))
	    }
	    if (fd2 != NULL) {
		call fprintf (fd2, "\n%s [%s%s]: %s\n")
		    call pargstr (Memc[time])
		    call pargstr (IMNAME(sh))
		    call pargstr (IMSEC(sh))
		    call pargstr (TITLE(sh))
	    }
	    call sfree (sp)
	}

	# Print key dependent header.
	if (key != key1) {
	    if (key != 'm') {
		if (fd1 != NULL) {
		    call fprintf (fd1, "%10s%10s%10s%10s%10s%10s%10s\n")
			call pargstr ("center")
			call pargstr ("cont")
			call pargstr ("flux")
			call pargstr ("eqw")
			call pargstr ("core")
			call pargstr ("gfwhm")
			call pargstr ("lfwhm")
		    call flush (fd1)
		}
		if (fd2 != NULL) {
		    call fprintf (fd2, "%10s%10s%10s%10s%10s%10s%10s\n")
			call pargstr ("center")
			call pargstr ("cont")
			call pargstr ("flux")
			call pargstr ("eqw")
			call pargstr ("core")
			call pargstr ("gfwhm")
			call pargstr ("lfwhm")
		    call flush (fd2)
		}
	    }
	    key1 = key
	}
end