FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 1   

GETLIN.FTN   	/TR:BLOCKS/WR


        C

        C

        C

        C

        C	GETLIN -- GET A LINE OF INPUT

        C

        C

        C

        C	COPYRIGHT (C) 1976

        C	DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

        C

        C	THIS SOFTWARE IS FURNISHED UNDER  A LICENSE FOR USE ONLY  ON  A

        C	SINGLE COMPUTER SYSTEM AND MAY BE  COPIED ONLY WITH  THE INCLU-

        C	SION OF  THE  ABOVE  COPYRIGHT NOTICE.  THIS SOFTWARE,  OR  ANY

        C	OTHER COPIES THEREOF, MAY NOT BE  PROVIDED  OR  OTHERWISE  MADE

        C	AVAILABLE TO ANY OTHER PERSON EXCEPT  FOR  USE  ON  SUCH SYSTEM

        C	AND TO  ONE WHO AGREES  TO  THESE LICENSE  TERMS.  TITLE TO AND

        C	OWNERSHIP OF THE SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

        C

        C	THE INFORMATION IN THIS SOFTWARE  IS  SUBJECT TO CHANGE WITHOUT

        C	NOTICE AND SHOULD NOT BE CONSTRUED  AS  A COMMITMENT BY DIGITAL

        C	EQUIPMENT CORPORATION.

        C

        C	DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS

        C	SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

        C

        C

        C	K.D. MORSE	22-NOV-76

        C

        C

        C

        C

        C	THIS SUBROUTINE PRODUCES THE RECORD SPECIFIED BY ITS RECORD NUMBER,

        C	IRECNM.  IT DECIDES WHETHER THE RECORD IS IN THE BUFFER ALREADY

        C	OF IF THE BUFFER CAN BE UPDATED BY MOVING OUT LINES ALREADY MAPPED

        C	AND READING NEW ONES.  IF THE BUFFER IS FULL, THEN IT READS THE 

        C	RECORD AND REPOSITIONS THE FILE TO THE NEXT RECORD TO BE READ

        C	TO UPDATE THE BUFFER.

        C

        C

        C

        C  MODIFICATIONS

        C

        C  NO.		DATE		PROGRAMMER		PURPOSE

        C  ---		----		----------		-------

        C

FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 2   

GETLIN.FTN   	/TR:BLOCKS/WR


         

        C

        C

        C  VARIABLES:

        C

        C

        C	BUFPNT--POINTER INTO ARRAY BUFR TO THE DESIRED RECORD

        C	BUFR--ARRAY HOLDING EDITTED RECORDS FROM INPUT AND COMPARE FILES

        C	      (N,1) CORRESPONDS TO INPUT RECORDS, (N,2) TO COMPARE RECORDS

        C	IERR1--ERROR INDICATOR FROM FORTRAN ROUTINES

        C	IERR2--ERROR INDICATOR FROM MACRO ROUTINES

        C	IFIRST--RECORD NUMBER OF THE FIRST RECORD HELD IN THE ARRAY BUFR

        C	IFREE--POINTER TO THE FIRST UNUSED BYTE IN ARRAY BUFR

        C	IHOLD--ARRAY HOLDING LENGTHS OF RECORDS CONTAINED IN THE ARRAY BUFR

        C	ILUN--CHANNEL ON WHICH FILE IS OPEN

        C	INMLNG--LENGTH OF INPUT FILE NAME

        C	INPNAM--NAME OF INPUT FILE

        C	IRECNM--SEQUENTIAL LINE NUMBER OF RECORD TO BE OUTPUT

        C	IRECSZ--SIZE OF RECORD BUFFER

        C	ISTAT--INDICATOR FOR TYPE OF CLOSE TO PERFORM ON INPUT FILE

        C	ISUB--INDICATOR FOR INPUT- OR COMPARE-FILE, I.E., 1=INPUT AND

        C		2=COMPARE, USED TO SUBSCRIPT INTO TABLES AND POINTERS

        C	ITYPE--INDICATOR FOR TYPE OF OPEN TO PERFORM ON INPUT FILE

        C	LAST--RECORD NUMBER OF THE LAST RECORD HELD IN THE ARRAY BUFR

        C	LENINP--LENGTH OF RECORD

        C	LSTMAP--RECORD NUMBER OF THE LAST RECORD MAPPED

        C	LSTMAT--RECORD NUMBER OF THE LAST RECORD MATCHED IN THE FILE

        C	MRKPNT--POINTERS TO THE NEXT RECORD TO BE READ FROM THE INPUT

        C	        AND COMPARE FILES FOR THE ARRAY BUFR

        C	NINCOR--MAXIMUM NUMBER OF RECORDS HELD IN STORAGE ARRAY BUFR

        C	RECORD--BUFFER TO HOLD ONE RECORD

FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 3   

GETLIN.FTN   	/TR:BLOCKS/WR


         

0001    	SUBROUTINE GETLIN(ILUN,RECORD,LENINP,ISTAT,INPNAM,INMLNG,

        	1ITYPE,IRECNM)

         

0002    	COMMON MAP(100,2),NUMLIN,MAPTOP(2),LSTMAP(2),MLUN,

        	1IHOLD(30,2),NINCOR,IFREE(2),IFIRST(2),LAST(2),MAXBUF,

        	2BUFR,ISWTCH,COMCHR,NSWVAL(10),LSTMAT(2),IRECSZ,

        	3MRKPNT(4,2),INOUT,MAPEND(2),LINSIZ,MAPNAM,MNMLNG,MTYPE,MSTAT

        	4,IERR1,IERR2,IKIND,OLUN,MAPMRK(3,2),MPRINT,BARCHR

         

0003    	INTEGER BUFPNT,OLUN

         

0004    	BYTE RECORD(1),BUFR(7680,2),COMCHR(16),INPNAM(1),MAPNAM(12)

0005    	BYTE BARCHR

         

        C

        C	CHECK THAT THERE ARE NOT TOO MANY RECORDS IN THE FILE FOR DIF TO

        C	HANDLE, I.E., THE RECORD NUMBER MUST NOT OVERFLOW A WORD, 32767.

        C	IF IT IS, THEN SIMPLY STATE THAT THE FILE ENDS HERE.

        C

0006    	IF (IRECNM .EQ. 32767) GOTO 75

        C

        C	DECIDE WHICH FILE TO READ.

        C

0007    	ISUB=1

0008    	IF (ILUN .EQ. 3) ISUB=2

        C

        C	SAVE THE LUN IN CASE OF EOF.

        C

        C

        C	IS RECORD IN BUFFER?

        C

0009    10	IERR1=1

0010    	IERR2=1

0011    	IF (IRECNM .GT. LAST(ISUB)) GOTO 60

        C

        C	YES, GET IT AND LENGTH AND RETURN.

        C

0012    	J=IRECNM-IFIRST(ISUB)+1

0013    	LENINP=IHOLD(J,ISUB)

0014    	IF (LENINP .EQ. 0) GOTO 40

0015    	BUFPNT=0

0016    	IF (J .EQ. 1) GOTO 25

0017    	DO 20 I=1,J-1

0018    20	BUFPNT=BUFPNT + IHOLD(I,ISUB)

0019    25	DO 30 I=1,LENINP

0020    30	RECORD(I)=BUFR(BUFPNT+I,ISUB)

0021    	GOTO 200

        C

        C	BLANK RECORD, MUST CLEAR BUFFER.

        C

0022    40	DO 50 I=1,IRECSZ

0023    50	RECORD(I)=127

0024    	GOTO 200

        C

        C	NO, RECORD IS NOT IN BUFFER.  IS ALL BUFFER UNMATCHED?

FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 4   

GETLIN.FTN   	/TR:BLOCKS/WR


        C

0025    60	IF (LSTMAT(ISUB) .GT. IFIRST(ISUB)) GOTO 80

        C

        C	YES, THEN READ FILE SEQUENTIALLY UNTIL DESIRED RECORD IS FOUND.

        C

0026    	I=IRECNM-LAST(ISUB)

0027    	DO 70 J=1,I

0028    	IF (INOUT .EQ. 0) CALL INEDIT(ILUN,RECORD,LENINP)

0029    	IF (INOUT .GT. 0) CALL OUTEDT(ILUN,RECORD,LENINP)

0030    	IF (IERR2 .EQ. 0) GOTO 75

0031    70	IF (IERR1 .LT. 0) GOTO 200

0032    	GOTO 77

0033    75	IRECNM=0

0034    	IERR1=1

        C

        C	REPOSITION FILE FOR NEXT BUFFER READ.

        C

0035    77	CALL CLSFIL(ILUN,ISTAT,IERR2)

0036    	IF (IERR2 .LE. 0) GOTO 92

0037    	CALL OPNFIL(INPNAM,INMLNG,ILUN,RECORD,IRECSZ,ITYPE,IERR2)

0038    	IF (IERR2 .LE. 0) GOTO 93

0039    	CALL PNTREC(ILUN,MRKPNT(1,ISUB),IERR2)

0040    	IF (IERR2 .LT. 0) GOTO 94

0041    	GOTO 200

        C

        C	NO, MOVE OUT MATCHED RECORDS AND LENGTHS AND READ IN NEW ONES.

        C	I = NUMBER OF RECORDS TO GET RID OF.

        C	BUFPNT = ADDRESS OF LAST BYTE TO ELIMINATE.

        C	MOVSIZ = NUMBER OF BYTES TO MOVE UP IN BUFFER.

        C

0042    80	I=LSTMAT(ISUB) - IFIRST(ISUB) + 1

0043    	IF (I .GE. NINCOR) GOTO 115

0044    	BUFPNT=0

0045    	DO 90 J=1,I

0046    90	BUFPNT=BUFPNT+IHOLD(J,ISUB)

0047    	MOVSIZ=0

0048    	I=I+1

0049    	DO 100 J=I,NINCOR

0050    	MOVSIZ=MOVSIZ+IHOLD(J,ISUB)

0051    100	IHOLD(J-I+1,ISUB)=IHOLD(J,ISUB)

0052    	IF (MOVSIZ .EQ. 0) GOTO 114

0053    	DO 110 J=1,MOVSIZ

0054    110	BUFR(J,ISUB)=BUFR(BUFPNT+J,ISUB)

0055    	GOTO 116

0056    115	I=NINCOR+1

0057    114	J=1

0058    116	IFREE(ISUB)=J

        C

        C	NOW RESET UNUSED RECORD LENGTHS TO ZERO.

        C

0059    	DO 120 J=0,I-2

0060    120	IHOLD(NINCOR-J,ISUB)=0

0061    	IFIRST(ISUB)=IFIRST(ISUB)+I-1

0062    	IF (LAST(ISUB) .LT. IFIRST(ISUB))IFIRST(ISUB)=LAST(ISUB) + 1

0063    	MOV=1

        C

FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 5   

GETLIN.FTN   	/TR:BLOCKS/WR


        C	NOW FILL UP REST OF BUFFER.  THEN SEE IF RECORD DESIRED IS IN THE BUFFER.

        C

0064    	CALL FILBUF(ILUN,RECORD,LENINP,ISTAT,INPNAM,INMLNG,ITYPE)

0065    	IF (IERR2 .EQ. 0) GOTO 10

0066    	IF (IERR1 .LT. 0) GOTO 200

0067    	GOTO 10

        C

        C	ERROR RETURNS.

        C

0068    92	IERR1=-13

0069    	GOTO 150

0070    93	IERR1=-12

0071    	GOTO 150

0072    94	IERR1=-15

0073    150	IF (ISUB .EQ. 2) IERR1=IERR1-8

0074    200	RETURN

0075    	END

FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 6   

GETLIN.FTN   	/TR:BLOCKS/WR


PROGRAM SECTIONS



NUMBER	 NAME	    SIZE		ATTRIBUTES



  1	$CODE1	002074   542		RW,I,CON,LCL

  3	$IDATA	000104    34		RW,D,CON,LCL

  4	$VARS	000014     6		RW,D,CON,LCL

  5	$TEMPS	000002     1		RW,D,CON,LCL

  6	.$$$$.	037222  8009		RW,D,OVR,GBL





ENTRY POINTS



 NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS   



 GETLIN	      1-000000





VARIABLES



 NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS    NAME   TYPE  ADDRESS   



 BARCHR	L*1   6-037220	 BUFPNT	I*2   4-000000	 I	I*2   4-000006	 IERR1	I*2   6-037172	 IERR2	I*2   6-037174

 IKIND	I*2   6-037176	 ILUN	I*2   F-000002*	 INMLNG	I*2   F-000014*	 INOUT	I*2   6-037140	 IRECNM	I*2   F-000020*

 IRECSZ	I*2   6-037116	 ISTAT	I*2   F-000010*	 ISUB	I*2   4-000002	 ISWTCH	I*2   6-037044	 ITYPE	I*2   F-000016*

 J	I*2   4-000004	 LENINP	I*2   F-000006*	 LINSIZ	I*2   6-037146	 MAXBUF	I*2   6-001042	 MLUN	I*2   6-000632

 MNMLNG	I*2   6-037164	 MOV	I*2   4-000012	 MOVSIZ	I*2   4-000010	 MPRINT	I*2   6-037216	 MSTAT	I*2   6-037170

 MTYPE	I*2   6-037166	 NINCOR	I*2   6-001024	 NUMLIN	I*2   6-000620	 OLUN	I*2   6-037200





ARRAYS



 NAME   TYPE  ADDRESS	    SIZE 	DIMENSIONS



 BUFR	L*1   6-001044	036000  7680	(7680,2)

 COMCHR	L*1   6-037046	000020     8	(16)

 IFIRST	I*2   6-001032	000004     2	(2)

 IFREE	I*2   6-001026	000004     2	(2)

 IHOLD	I*2   6-000634	000170    60	(30,2)

 INPNAM	L*1   F-000012*	000001     0	(1)

 LAST	I*2   6-001036	000004     2	(2)

 LSTMAP	I*2   6-000626	000004     2	(2)

 LSTMAT	I*2   6-037112	000004     2	(2)

 MAP	I*2   6-000000	000620   200	(100,2)

 MAPEND	I*2   6-037142	000004     2	(2)

 MAPMRK	I*2   6-037202	000014     6	(3,2)

 MAPNAM	L*1   6-037150	000014     6	(12)

 MAPTOP	I*2   6-000622	000004     2	(2)

 MRKPNT	I*2   6-037120	000020     8	(4,2)

 NSWVAL	I*2   6-037066	000024    10	(10)

 RECORD	L*1   F-000004*	000001     0	(1)





LABELS



 LABEL   ADDRESS 	 LABEL   ADDRESS 	 LABEL   ADDRESS 	 LABEL   ADDRESS 	 LABEL   ADDRESS 	

FORTRAN IV-PLUS V02-51D		02:40:58    22-AUG-78		PAGE 7   

GETLIN.FTN   	/TR:BLOCKS/WR




 10	 1-000116	 20	    **   	 25	 1-000304	 30	    **   	 40	 1-000400

 50	    **   	 60	 1-000454	 70	    **   	 75	 1-000702	 77	 1-000722

 80	 1-001136	 90	    **   	 92	 1-001776	 93	 1-002014	 94	 1-002032

 100	    **   	 110	    **   	 114	 1-001474	 115	 1-001454	 116	 1-001510

 120	    **   	 150	 1-002046	 200	 1-002072





FUNCTIONS AND SUBROUTINES REFERENCED



 CLSFIL	 FILBUF	 INEDIT	 OPNFIL	 OUTEDT	 PNTREC





TOTAL SPACE ALLOCATED = 041440  8592



NO FPP INSTRUCTIONS GENERATED



OBJ$:GETLIN,LIS$:GETLIN/-SP=SRC$:GETLIN

