C*******************************************************************************
C
C  COMPUTER: VAX SERIES			OPERATING ENVIRONMENT: VMS
C  LANGUAGE: FORTRAN IV, WITHOUT WATFOR/WATFIV ADDITIONS AND IF/ELSE
C            STATEMENTS
C
C    WRITTEN BY BENJAMIN J. TAYLOR ON MAY 8, 1998 
C    LAST MODIFIED BY BENJAMIN J. TAYLOR ON MAY 19, 1998
C
C  This program writes out results from the evolved-star [Fe/H] catalog.
C   Literature sources and comments for given stars are also written out.
C   Star IDs may be input interactively or in an auxiliary input file.
C
C -1- INSTRUCTIONS FOR USE
C
C   The program has the following I/O files:
C
C	File 8--READ (8,	Input	[Fe/H] catalog ("catalog.dat", 
C					 "comment.dat', and "refs.dat").
C	File 9--READ (9,	Input	User input file, specifying star IDs.
C	File 10-WRITE (10,	Output	For each star, this file contains
C
C					   *) the value of [Fe/H],
C					   *) the rms error,
C					   *) the corresponding number of 
C					       degrees of freedom,
C					   *) (sometimes) a comment number, and
C					   *) reference numbers for literature
C					       sources.
C
C					There are also two composite lists:
C
C					   *) comment numbers and comments (if
C					       necessary), and
C					   *) reference numbers and literature
C					       sources.
C
C   Each line of the user input file has the following structure:
C
C	A2	Catalog designation (HR, hr, HD, or hd).  If this field is
C		 blank, the name/number is treated as an HD number.  If an
C	     	 ASCII name is given instead of a number, this space may be
C		 left blank.
C	A8	ASCII name or catalog number.  Trailing blanks are ignored.
C		 Numbers greater than 9110 are assumed to be HD numbers even
C		 if they are specified as HR numbers.
C
C    No special line is needed to end the input file.  An example of an
C    acceptable file is as follows:
C
C	hd  221148
C       HR6806
C	  IV-203
C	[End-of-file]
C
C -2- GLOSSARY OF PROGRAM VARIABLES
C
C*I,J,K,L,M,MM,N,NN,N1,N2,N3,N4	DO-loop indices, array addresses, and auxiliary 
C				 variables.
C
C*BLANK1	 CHARACTER*1	This is the ASCII character ' '.  It is used
C				 in Sec. 8 to test for trailing blanks in
C				 DUMMY8.  [See DUMMY8 and DUMMY1(8)].
C
C*BLANK4	 CHARACTER*4	This variable contains the ASCII character 
C				 string '    '.  In Sec. 4, it is used to test
C				 the contents of HRA (which see).
C
C*CAYNO(14,1200) INTEGER*4	For star "n," CAYNO(1-14,n) contains ID numbers
C				 ("Cayrel de Strobel numbers").  These numbers
C			   	 designate literature sources used to obtain
C				 the values of [Fe/H] in the [Fe/H] catalog.
C				 Entries in CAYNO are read in from the catalog
C				 (file 8) in Sec. 4 and are tested for matches
C				 with entries in IREFS in Sec. 5.  [See IREFS.]
C
C*CFLAG		 INTEGER*4	If data for stars with comments are to be 
C (initial value: 0)		 written out, CFLAG is set to 1 in Sec. 7 
C				 (interactive readin) or Sec. 8 (readin from 
C				 user file = file 9).  CFLAG then triggers a
C				 writeout of comments in the output file (file
C				 10) for the stars with comments.
C
C*CNO(1200)	 INTEGER*4	"Comment numbers."  For star "n," CNO(N)
C				 contains the comment number.  CNO(N)=0 if there
C				 is no comment.  In Sec. 4, CNO is read in from
C				 the [Fe/H] catalog (file 8).
C
C*COMMENT(2,56)  CHARACTER*76	Comments in the [Fe/H] catalog (file 8).  A one-
C				 line comment for comment number "n" appears in
C				 COMMENT(1,n).  If a second line is necessary,
C				 it is stored in COMMENT(2,n).
C
C*DASH		 CHARACTER*1	The ASCII character "-".
C
C*DUMMY1(8)	 CHARACTER*1	This variable is equivalenced to DUMMY8 (which
C				 see).  After a star name has been read into
C				 DUMMY8, DUMMY1 is used in Sec. 8 to test for
C			 	 and eliminate trailing blanks in DUMMY8.
C
C*DUMMY2	 CHARACTER*2	In Sec. 8, this variable is used to read in the
C				 "HD/HR" prefix to a catalog number from the
C				 [Fe/H] catalog (file 8).
C
C*DUMMY4	 CHARACTER*4	In Sec. 4, this variable is used to help space
C				 through the heading of the catalog file (file 
C				 8).  In Sec. 8, DUMMY4 ultimately receives HR 
C				 numbers from the user input file (file 9).
C
C*DUMMY8	 CHARACTER*8	In Sec. 8, this variable receives HD numbers,
C				 HR numbers, and star names from the user input
C				 file (file 9).  HR numbers are then sent on
C				 to DUMMY4 (which see).
C
C*FEH(3,1200)	 	 	For star "n," FEH(1,n) contains the catalog
C				 value of [Fe/H].  FEH(2,n) contains the cor-
C				 responding rms error.  FEH(3,n) contains the
C				 number of degrees of freedom for FEH(2,n).
C				 All data in FEH are read in from the [Fe/H]
C				 catalog (file 8) in Sec. 4.
C
C*FLAGCOM(56)	 INTEGER*4	If comment "n" is to be quoted in the output
C (initial values: 56*0)	 file (file 9), FLAGCOM(n) is set to 1.
C				 Otherwise, FLAGCOM(n) = 0.
C
C*FLAGFEH(1200)	 INTEGER*4	If data for star "n" are to be quoted in the 
C (initial values: 1200*0)	 output file (file 9), FLAGFEH(n) is set to 1.
C				 Otherwise, FLAGFEH(n) = 0.
C
C*FLAGREF(249)	 INTEGER*4	FLAGREF(n) applies for the "n"th line of the 
C (initial values: 249*-1)	 reference list in the [Fe/H] catalog (see
C				 file 8; read in in Sec. 4).  FLAGREF(n) has
C				 a corresponding ID ("Cayrel de Strobel" or 
C				 "CdS") number in IREFS(1,n) [which see].  
C				 FLAGREF is initialized to -1.  In Sec. 5, 
C				 IREFS(1,n) is then tested to see whether it 
C				 can be matched to at least one entry in
C				 CAYNO [which see].  If a match can be found,
C				 FLAGREF(n) is set to 0.  If a match cannot be
C				 found, FLAGREF(n) applies for a literature
C				 reference which is not cited with a value of
C				 [Fe/H] in the [Fe/H] catalog.  FLAGREF(n) then
C				 remains at -1, and IREFS(1,n) is printed out
C				 in Sec. 5 as part of an error message.
C
C				 If reference lines for a given CdS number in
C				 IREFS(1,N) are to be written into the output
C				 file (file 9), FLAGREF is set to 1 for the 
C				 first reference line which has that CdS number.
C
C*HDA(1200)	 CHARACTER*8	HD numbers (for most stars) and star names (for
C [initial values: 1200*	 the remaining stars) in the [Fe/H] catalog
C '        ']			 (file 8).
C
C*HDHR(3,2)	 CHARACTER*2	HDHR(1-3,1) contains the words 'HD', 'HR',
C				  and '  '.  HDHR(1-3,2) contains the words
C				  'hd', 'hr', and '  '.  In Sec. 7, HDHR is
C				  used to write out prefixes to names and
C				  catalog numbers.  In Sec. 8, HDHR is used
C				  to identify the prefix entered in DUMMY2
C				  (which see).
C
C*HDI(2,1200)	 INTEGER*4	HDI(1,n) contains the HD number for star "n."
C (initial values: 2400*0)	 HDI(2,n) contains the corresponding HR number.
C				 If star "n" has a name instead of an HD number,
C				 HDI(1,n) = 0.  If star "n" has no HR number,
C				 HDI(2,n) = 0.
C
C*HD0		 INTEGER*4	In Sec. 7, HD0 is used for HD and HR numbers
C				 which are input interactively.  In Sec. 8,
C				 HD0 is used for for temporary INTEGER storage
C				 for HD and HR numbers which are read in from
C				 the user file (file 9) and are stored in
C				 DUMMY8 (which see). 
C
C*HRA(1200)	 CHARACTER*4	HR numbers in the [Fe/H] catalog (file 8).
C [initial values: 1200*'    ']	 HRA(n) contains blanks if star "n" has no
C				  HR number.
C
C*ICOMMENT(56)			ICOMMENT(n) contains the number of comment lines
C				 in COMMENT [which see].  ICOMMENT is read in
C				 from the [Fe/H] catalog (file 8) in Sec. 4.  
C				 If ICOMMENT is initially zero, it is set to 1.
C
C*IREFS(2,249)			IREFS contains information corresponding to 
C				 entries in REF [which see].  For REF(n), which 
C				 is line "n" in REF, IREFS(1,n) contains a
C				 literature ID ("Cayrel de Strobel" or "CdS") 
C				 number.  If REF(n) contains the first line 
C				 for a given CdS number, IREFS(2,n) contains
C				 the total number of lines for that CdS number.
C
C*J,K,L,M,N,NN			DO-loop indices, array addresses, and auxiliary
C				 variables.
C
C*MATCH(200)			This array contains all ID numbers ("Cayrel
C				 de Strobel" or "CdS" numbers) which are found
C				 in the [Fe/H] catalog with values of [Fe/H]
C				 (see CAYNO) but are not found in the list of
C				 literature sources (see IREFS).  Entries in 
C				 MATCH are made in Sec. 5.
C
C*NCAYNO(1200)			For star "n," NCAYNO(n) is the number of ID
C				 ("Cayrel de Strobel" or "CdS") numbers in
C				 the [Fe/H] catalog (file 8).
C
C*NCOMMENT (initial value: 56)	The number of comments in the [Fe/H] file (file
C				 8).
C
C*NHEAD (initial value: 89)	The number of initial lines in the [Fe/H] file
C				 (file 8) which are skipped to get to the 
C				 [Fe/H] catalog.
C
C*NHD (initial value: 1093)	The number of stars in the [Fe/H] file (file
C				 8) with HD numbers.
C
C*NOMATCH (initial value: 0)	The number of nonzero entries in MATCH (which
C				 see).
C
C*NOTHER (initial value: 24)	The number of stars in the [Fe/H] file (file 8)
C				 with names instead of HD numbers.
C
C*NREFS (initial value: 249)	The number of **reference lines** (not 
C				 references) in the [Fe/H] catalog (file 8).
C
C*NTOT				The total number of stars with data in the
C				 [Fe/H] catalog (file 8).  NTOT=NHD+NOTHER
C				 (see entries for those variables).
C
C*NTOT2				The total number of stars with either input
C			  	 entries (from either interactive input or file
C				 9) or entries in the [Fe/H] catalog (file 8)
C				 or both kinds of entries.  NTOT2 is greater 
C				 or equal to NTOT (which see).
C
C*REF(249)	 CHARACTER*75	REF(n) contains the "n"th line of literature
C				 references from the [Fe/H] catalog (file 8).
C				 The references are indexed by the numbers in
C				 IREFS(1,-) [which see].
C
C*SIGN		 CHARACTER*2	In Sec. 9, SIGN is used to write out comment
C				 numbers (blank if the number is 0) into the
C				 output file (file 10).  [This variable is
C				 named to have consistency with its counterpart
C				 in the search program for dwarf stars.]
C
C                                                        
C -3- DIMENSION AND DATA STATEMENTS
C
	CHARACTER*1 BLANK1,DASH,DUMMY1(8)
	CHARACTER*2 DUMMY2,HDHR(3,2),SIGN
	CHARACTER*4 BLANK4,DUMMY4,HRA(1200)
	CHARACTER*8 DUMMY8,HDA(1200)
	CHARACTER*75 REF(249)
	CHARACTER*76 COMMENT(2,56)
C
	EQUIVALENCE (DUMMY8,DUMMY1(1))
C
	INTEGER*4 CAYNO(14,1200),CFLAG,CNO(1200),FLAGCOM(56)
	INTEGER*4 FLAGFEH(1200),FLAGREF(249),HDI(2,1200),HD0
	DIMENSION FEH(3,1200),ICOMMENT(56),IREFS(2,249)
	DIMENSION MATCH(200),NCAYNO(1200)
C
	DATA BLANK1/' '/,BLANK4/'    '/,CFLAG/0/
	DATA DASH/'-'/,FLAGCOM/56*0/,FLAGFEH/1200*0/
	DATA FLAGREF/249*-1/,HDA/1200*'        '/,HRA/1200*'    '/
	DATA HDHR/'HD','HR','  ','hd','hr','  '/,HDI/2400*0/
	DATA NCOMMENT/56/,NHD/1093/,NHEAD/89/,NOMATCH/0/
	DATA NOTHER/24/,NREFS/249/
C
	NTOT=NHD+NOTHER
	NTOT2=NTOT
C
C -4- READ IN ADC/CDS FILE
C
	   DO 10 N=1,NHEAD
10	   READ (8,20) DUMMY4
20	   FORMAT (A4)
C
	   DO 60 N=1,NHD
C
	   READ (8,30) HDA(N),CNO(N),HRA(N),(FEH(M,N),M=1,3),L,
	1   (CAYNO(J,N),J=1,L)
30	   FORMAT (1X,A8,I2,1X,A4,F7.3,F6.3,F5.1,15I4)
	   NCAYNO(N)=L
C
	   READ (UNIT=HDA(N),FMT=40) HDI(1,N)
40	   FORMAT (I8)
C
	   IF (HRA(N) .NE. BLANK4) READ(UNIT=HRA(N),FMT=50) HDI(2,N)
50	   FORMAT (I4)
C
60	   CONTINUE
C
	   DO 80 NN=1,NOTHER
	   N=NN+NHD
	   READ (8,70) HDA(N),CNO(N),(FEH(M,N),M=1,3),L,
	1   (CAYNO(J,N),J=1,L)
70	   FORMAT (1X,A8,I2,5X,F7.3,F6.3,F5.1,15I4)
	   NCAYNO(N)=L
80	   CONTINUE
C
	   DO 120 N=1,NCOMMENT
	   READ (8,90) ICOMMENT(N),COMMENT(1,N)
90	   FORMAT (2X,I1,A76)
	   ICOMMENT(N)=JMAX0(ICOMMENT(N),1)
C
	   IF (ICOMMENT(N) .LT. 2) GO TO 120
	   L=ICOMMENT(N)
C
	      DO 100 J=2,L
100	      READ (8,110) COMMENT(J,N)
110	      FORMAT (3X,A76)
C
120	   CONTINUE
C
	   DO 130 N=1,NREFS
130	   READ (8,140) (IREFS(M,N),M=1,2),REF(N)
140	   FORMAT (I3,1X,I1,A75)
C
C -5- TEST FOR CORRECT MATCH BETWEEN CdS ("CAYNO") NUMBERS IN [Fe/H] LIST 
C      AND REFERENCE NUMBERS IN LIST OF REFERENCES
C
	   DO 165 N=1,NTOT
	   L=NCAYNO(N)
C
	      DO 160 J=1,L
	      M=0
C
	        DO 145 NN=1,NREFS
	        IF (CAYNO(J,N) .NE. IREFS(1,NN)) GO TO 145
	        M=1
	        FLAGREF(NN)=0
145	        CONTINUE
C
	      IF (M .GT. 0) GO TO 160
	      IF (NOMATCH .LT. 1) GO TO 155
C
	        DO 150 NN=1,NOMATCH
	        IF (CAYNO(J,N) .EQ. MATCH(NN)) GO TO 160
150	        CONTINUE
C
155	      NOMATCH=JMIN0(NOMATCH+1,200)
	      MATCH(NOMATCH)=CAYNO(J,N)
C
160	      CONTINUE
C
165	   CONTINUE
C
	IF (NOMATCH .GT. 0) GO TO 175
	PRINT 170
170	FORMAT (/1X,'All [Fe/H] CdS numbers have entries in the'
	1 ' reference list')
	GO TO 185
C
175	PRINT 180,(MATCH(NN),NN=1,NOMATCH)
180	FORMAT (/1X,'Add these CdS numbers to the reference list:'/
	1 (5X,10I4))
C
185	M=0
C
	   DO 195 N=1,NREFS
C
	   IF (N .GT. 1 .AND. IREFS(1,N) .EQ. NN) GO TO 195
	   NN=IREFS(1,N)
C
	   IF (FLAGREF(N) .GT. -1) GO TO 195
	   M=1
	   PRINT 190,IREFS(1,N)
190	   FORMAT (1X,'Delete entries with CdS number' I4,' from'
	1   ' the reference list')
C
195	   CONTINUE
C
	IF (M .LT. 1) PRINT 200
200	FORMAT (/1X,'All reference-list CdS numbers have entries'
	1  ' in the [Fe/H] list')
C
C -6- SAMPLING THE ADC/CDS FILE: SELECT INTERACTIVE MODE OR READ STAR-NUMBER
C      FILE 
C
205	N=-1
	NN=-1
C
210	PRINT 215
215	FORMAT (/1X,'Enter'/5X,'1 for interactive search,'/5X,
	1 '2 to read star-number file ',$)
	READ (5,*,ERR=210) N
	IF (N .LT. 1 .OR. N .GT. 2) GO TO 205
	IF (N .GT. 1) GO TO 230
C
220	PRINT 225
225 	FORMAT (1X,'Enter'/5X,'1 to confirm interactive search,'/5X,
	1 '2 to revise choice ',$)
	READ (5,*,ERR=220) NN
	IF (N .NE. 1 .OR. NN .NE. 1) GO TO 205
	GO TO 320
C
230	PRINT 235
235	FORMAT (1X,'Enter'/5X,'1 to revise choice,'/5X,
	1 '2 to confirm use of star-number file ',$)
	READ (5,*,ERR=230) NN
	IF (N .NE. 2 .OR. NN .NE. 2) GO TO 205
	GO TO 500
C
C -7- READ SAMPLES INTERACTIVELY AND PRINT OUT INTERACTIVELY
C
240	N=NOTHER/2
	NN=JMOD(NOTHER,2)
	N1=NHD+1
	N2=NHD+N
	N3=N2+NN
	N4=NN+N
C
	M=0
	PRINT 260
260	FORMAT (/1X,'Non-HD stars:'//2X,'ID #' 6X,'Name' 
	1 3X,'ID #' 6X,'Name')
	PRINT 270,(DASH,K=1,32)
270	FORMAT (1X,32A1)
C
	   DO 280 N=N1,N2
	   M=M+1
	   MM=M+N4
280	   PRINT 290,M,HDA(N),MM,HDA(N+N4)
290	   FORMAT (4X,I2,2X,A8,5X,I2,2X,A8)
C
	M=M+1
	IF (N3 .NE. N2) PRINT 290,M,HDA(N3)
	PRINT 295
295	FORMAT (1X,' ')
C
300	NN=0
305	PRINT 310,NOTHER
310	FORMAT (/1X,'Enter'/5X,'-1 to stop,'/6X,'0 or /'
	1 ' to skip to HD/HR numbers,'/6X,'1-' I2,' to select'
	2 ' an ID number from the above list ',$)
	READ (5,*,ERR=305) NN
C
	IF (NN .LT. 0) GO TO 700
	IF (NN .LT. 1) GO TO 320
	IF (NN .GT. NOTHER) GO TO 300
C
	N=NN+NHD
	L=3
	MM=3
	GO TO 370
C
320	NN=0
	L=1
	MM=2
	PRINT 330
330	FORMAT (/1X,'Enter'/5X,'-1 to stop,'/6X,'0 or / for an '
	1 'HD number,'/6X,'1 for an HR number,'/6X,'2 for a star'
	2 ' with a special name ',$)
	READ (5,*,ERR=320) NN
	IF (NN .LT. 0) GO TO 700
	IF (NN .GT. 2) GO TO 320
	IF (NN .GT. 1) GO TO 240
	NN=NN+1
C
335	PRINT 340,HDHR(NN,1)
340	FORMAT (/1X,'Enter ' A2,' number: ',$)
	READ (5,*,ERR=335) HD0
C
	   DO 350 N=1,NHD
	   IF (HDI(NN,N) .EQ. HD0) GO TO 370
350	   CONTINUE
C
	NTOT2=JMIN0(NTOT2+1,1200)
C
	IF (NN .GT. 1) GO TO 355
	WRITE (UNIT=HDA(NTOT2),FMT='(I8)') HD0
	GO TO 360
C
355	WRITE (UNIT=HRA(NTOT2),FMT='(I4)') HD0
C
360	PRINT 365,HDHR(NN,1),HD0
365	FORMAT (/1X,'*** ' A2,1X,I8,' is not in the [Fe/H]'
	1 ' database ***')
	GO TO 320
C
370	FLAGFEH(N)=1
C
	   DO 380 M=1,24
380	   PRINT 295
C
	PRINT 390,HDHR(L,1),HDA(N),HDHR(MM,1),HRA(N),(DASH,M=1,79),
	1 (FEH(M,N),M=1,3)  
390	FORMAT (/1X,'Star: ' A2,1X,A8,3X,A2,1X,A4/1X,79A1/3X,'[Fe/H] ='
	1 F7.3,' +/-' F6.3,2X,'Degrees of freedom:' F5.1)
C
	IF (CNO(N) .LT. 1) GO TO 410
	CFLAG=1
	FLAGCOM(CNO(N))=1
	L=ICOMMENT(CNO(N))
	PRINT 405,(DASH,M=1,79),(COMMENT(J,CNO(N)),J=1,L)
405	FORMAT (/1X,'Comment:'/1X,79A1/(3X,A76))
C
410	PRINT 415,(DASH,M=1,79)
415	FORMAT (/1X,'References:'/1X,79A1)
	L=NCAYNO(N)
C
	   DO 450 J=1,L
C
	      DO 435 M=1,NREFS
	      IF (IREFS(1,M) .NE. CAYNO(J,N)) GO TO 435
C
	      FLAGREF(M)=1
	      PRINT 420,CAYNO(J,N),REF(M)
420	      FORMAT (1X,I3,1X,A75)
C
	      N1=M+1
	      N2=M+IREFS(2,M)-1
	      IF ((N2-N1) .LT. 0) GO TO 450
C
	        DO 425 K=N1,N2
425	        PRINT 430,REF(K)
430	        FORMAT (5X,A75)
C
 	      GO TO 450
C
435	      CONTINUE
C
	   PRINT 440,CAYNO(J,N)  
440	   FORMAT (/1X,'Add CdS number' I4,' to the reference list')
C               
450	   CONTINUE
C
	GO TO 320
C
C -8- READ IN HD/HR NUMBERS FROM AN EXISTING FILE
C
500	READ (9,510,END=700,ERR=880) DUMMY2,DUMMY8
510	FORMAT (A2,A8)
	READ (UNIT=DUMMY8,ERR=530,FMT='(BN,I8)') HD0
C
	IF (HD0 .GT. 9110) GO TO 520
	IF (DUMMY2 .EQ. HDHR(2,1)) GO TO 590
	IF (DUMMY2 .EQ. HDHR(2,2)) GO TO 590
C
520	WRITE (UNIT=DUMMY8,FMT='(I8)') HD0
	GO TO 570
C
530	   DO 550 NN=1,7                                       
	   IF (DUMMY1(8) .NE. BLANK1) GO TO 570
C
	      DO 540 N=8,2,-1
540	      DUMMY1(N)=DUMMY1(N-1)
C
	   DUMMY1(1)=BLANK1
550	   CONTINUE
C
570	   DO 580 N=1,NTOT
	   IF (HDA(N) .NE. DUMMY8) GO TO 580
	   FLAGFEH(N)=1
	   GO TO 610
580	   CONTINUE
C
	NTOT2=JMIN0(NTOT2+1,1200)
	HDA(NTOT2)=DUMMY8
	GO TO 500
C
590	WRITE (UNIT=DUMMY4,FMT='(I4)') HD0
C
	   DO 600 N=1,NHD
	   IF (HRA(N) .NE. DUMMY4) GO TO 600
	   FLAGFEH(N)=1
	   GO TO 610
600	   CONTINUE
C
	NTOT2=JMIN0(NTOT2+1,1200)
	HRA(NTOT2)=DUMMY4
	GO TO 500
C
610	IF (CNO(N) .LT. 1) GO TO 620
	CFLAG=1
	FLAGCOM(CNO(N))=1
C
620	L=NCAYNO(N)
C
	   DO 640 J=1,L
C
	      DO 630 M=1,NREFS
	      IF (IREFS(1,M) .NE. CAYNO(J,N)) GO TO 630
	      FLAGREF(M)=1
	      GO TO 640
630	      CONTINUE
C
640	   CONTINUE
C
	GO TO 500
C
C -9- WRITE OUTPUT FILE
C
700	WRITE (10,710) (DASH,N=1,48)
710	FORMAT (4X,'HD' 5X,'HR' 2X,'Comment [Fe/H] Sigma' 2X,
	1 'Nu*  Sources'/1X,48A1)
C
	   DO 730 N=1,NTOT
	   IF (FLAGFEH(N) .LT. 1) GO TO 730
C
	   SIGN='  '
	   IF (CNO(N) .GT. 0) WRITE(UNIT=SIGN,FMT='(I2)') CNO(N)
	   L=NCAYNO(N)
C
	   WRITE (10,720) HDA(N),HRA(N),SIGN,(FEH(M,N),M=1,3),
	1   (CAYNO(J,N),J=1,L)
720	   FORMAT (1X,A8,1X,A4,4X,A2,F9.3,F6.3,F5.1,2X,14I4)
730	   CONTINUE
C
	IF (NTOT2 .EQ. NTOT) GO TO 760
	L=NTOT+1
	WRITE (10,740) (DASH,N=1,16)
740	FORMAT (/1X,'Not in database:'/4X,'HD' 5X,'HR'/1X,16A1)
	WRITE (10,750) (HDA(N),HRA(N),N=L,NTOT2)
750	FORMAT (1X,A8,1X,A4)
C
760	WRITE (10,770)
770	FORMAT (/1X,'*: "Nu" is the number of degrees of freedom'
	1 ' for sigma')
C
	IF (CFLAG .LT. 1) GO TO 820
	WRITE (10,780) (DASH,N=1,8)
780	FORMAT (//1X,'Comments:'/1X,8A1)
C
	   DO 810 N=1,NCOMMENT
	   IF (FLAGCOM(N) .LT. 1) GO TO 810
	   WRITE (10,790) N,COMMENT(1,N)
790	   FORMAT (1X,I2,1X,A76)
C
	   IF (ICOMMENT(N) .LT. 2) GO TO 810
	   L=ICOMMENT(N)
	   WRITE (10,800) (COMMENT(J,N),J=2,L)
800	   FORMAT (4X,A76)
C
810	   CONTINUE
C
820	WRITE (10,830) (DASH,N=1,19)
830	FORMAT (//1X,'Literature sources:'/1X,19A1)
	N=0
C
	   DO 860 K=1,NREFS
C
	   N=N+1
	   IF (N .GT. NREFS) GO TO 865
C
	   IF (FLAGREF(N) .LT. 1) GO TO 860
C
	   WRITE (10,840) IREFS(1,N),REF(N)
840	   FORMAT (1X,I3,1X,A75)
C
	   IF (IREFS(2,N) .LT. 2) GO TO 860
	   M=N+1
	   NN=N+IREFS(2,N)-1
	   WRITE (10,850) (REF(L),L=M,NN)
850	   FORMAT (5X,A75)
	   N=NN
C
860	   CONTINUE
C
865	PRINT 870
870	FORMAT (/1X,'Print out the output file of [Fe/H] values'
	1 ' in landscape mode')
	GO TO 900
C
880	PRINT 890
890	FORMAT (1X,'Error stop--user file of star numbers is'
	1 ' defective or no file is found')
	STOP666
C
900	STOP
	END
