aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/dispcor/refmsgs.x
blob: a374088ee470b09d631ae6cdd3815046fcb233b6 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
include	"refspectra.h"


# REFMSGS -- Print any verbose messages to log files.  All messages
# except the assignments go through this procedure.  It calls REFPRINT with
# each output stream.

procedure refmsgs (msg, spec, ref, gval, gvalref, ap, apref, ref2)

int	msg		# Message code
char	spec[ARB]	# Spectrum
char	ref[ARB]	# Reference spectrum
char	gval[ARB]	# Group value
char	gvalref[ARB]	# Group value in reference
int	ap		# Aperture
int	apref		# Aperture in reference
char	ref2[ARB]	# Reference spectrum 2

int	fd, clgfil(), open()
pointer	sp, logfile
include	"refspectra.com"

begin
	if (verbose == NO)
	    return

	call smark (sp)
	call salloc (logfile, SZ_FNAME, TY_CHAR)
	while (clgfil (logfiles, Memc[logfile], SZ_FNAME) != EOF) {
	    fd = open (Memc[logfile], APPEND, TEXT_FILE)
	    call refprint (fd, msg, spec, ref, gval, gvalref, ap, apref, ref2)
	    call close (fd)
	}
	call clprew (logfiles)

	call sfree (sp)
end


# REFPRINT -- Print requested message with appropriate parameters if non-null
# stream is specified.

procedure refprint (fd, msg, spec, ref, gval, gvalref, ap, apref, ref2)

int	fd		# File descriptor
int	msg		# Message code
char	spec[ARB]	# Spectrum
char	ref[ARB]	# Reference spectrum
char	gval[ARB]	# Group value
char	gvalref[ARB]	# Group value in reference
int	ap		# Aperture
int	apref		# Aperture in reference
char	ref2[ARB]	# Reference spectrum 2

include	"refspectra.com"

begin
	if (fd == NULL)
	    return

	switch (msg) {
	case NO_SPEC:
	    call fprintf (fd, "[%s] Spectrum not found\n")
		call pargstr (spec)
	case NO_REF:
	    call fprintf (fd, "[%s] Reference spectrum not found\n")
		call pargstr (spec)
	case NOT_REFSPEC:
	    call fprintf (fd, "[%s] Not a reference spectrum\n")
		call pargstr (spec)
	case NO_REFSPEC:
	    call fprintf (fd, "[%s] No reference spectrum found\n")
		call pargstr (spec)
	case DEF_REFSPEC:
	    call fprintf (fd, "[%s] Reference spectra already defined: %s %s\n")
		call pargstr (spec)
		call pargstr (ref)
		call pargstr (ref2)
	case OVR_REFSPEC:
	    call fprintf (fd, 
		"[%s] Overriding previous reference spectra: %s %s\n")
		call pargstr (spec)
		call pargstr (ref)
		call pargstr (ref2)
	case BAD_AP:
	    call fprintf (fd, "[%s] Wrong aperture: %d\n")
		call pargstr (spec)
		call pargi (ap)
	case BAD_REFAP:
	    call fprintf (fd, "[%s] Wrong reference aperture: %d\n")
		call pargstr (spec)
		call pargi (ap)
	case REF_GROUP:
	    call fprintf (fd, "Input [%s] %s = %s : Ref [%s] %s = %s\n")
		call pargstr (spec)
		call pargstr (Memc[group])
		call pargstr (gval)
		call pargstr (ref)
		call pargstr (Memc[group])
		call pargstr (gvalref)
	case REF_AP:
	    call fprintf (fd, "Input [%s] ap = %d : Ref [%s] ap = %d\n")
		call pargstr (spec)
		call pargi (ap)
		call pargstr (ref)
		call pargi (apref)
	}
end