::::::::::
nlg.ada
::::::::::

---- NLG.ADA
-- This package is a generic package of
-- generic procedures, where a generic formal parameter of the
-- generic package is a generic formal parameter of the generic
-- function.  This package implements a namelist function in ADA.
-- The data is read in from a user defined file and stored in
-- a character array(VAR_ARRAY). This array is indexed
-- by a enumerated type which is the name of the
-- variable with VAL tacked on to the end.  The initialization of
-- VAR_ARRAY is done by the procedure INIT_NAMELIST.
-- The data is transfered to the program
-- variables by the generic procedures GET_VAL
-- and GET_VAL_V.  GET_VALUE is not a generic procedure and
-- reads in data of predefined type STRING.
-- Vectors and two dimensional arrays can be read in.
-- NL_PRINT_FLAG controls the print out: if NL_PRINT_FLAG = 1 the
-- data lines will be sent to the current output device as
-- they are read in.  In addition, the values as they are
-- stored in VAR_ARRAY are printed out.
--
-- Written by David Kwong...finished 10/86
-- 11/86 changed FILE_NAME to NAMELIST_FILE_NAME and
--       moved declaration to package specification

	WITH TEXT_IO; USE TEXT_IO;
	WITH INTEGER_TEXT_IO;
GENERIC
	TYPE VAR IS (<>);
	WITH PROCEDURE GET(FROM: IN STRING; ITEM: OUT VAR;
		LAST: OUT POSITIVE) IS <>;
PACKAGE NAMELIST_GENERIC IS

	-- Define Global Variables
	SUBTYPE INSTRING IS STRING(1..120);
	NAMELIST_FILE_NAME: STRING(1..30) :="                              ";
	TYPE VAR_ARRAY_T IS ARRAY (VAR) OF INSTRING;
	VAR_ARRAY:VAR_ARRAY_T; -- Array containing all all the data
	NL_PRINT_FLAG : INTEGER := 0; -- Flag controlling
	                              -- printing of information
	-- This constant string is used to check if a value has
	-- been changed.  This string cannot be used as an
	-- input to the namelist.
	NOT_CHANGED: CONSTANT STRING(1..3):=(ASCII.FF,
	                                      ASCII.ESC,ASCII.FF);

-- Procedure used to initialized VAR_ARRAY with values from the
-- input file

	PROCEDURE INIT_NAMELIST(FNAME: IN STRING := NOT_CHANGED);

-- Function used to read strings from the namelist

	PROCEDURE GET_VALUE (OUT_STRING: IN OUT STRING; INDEX: IN VAR);

-- Generic procedure used to read integer, floating point
-- and enumerated types from the namelist.

	GENERIC
		TYPE OUT_VAL IS PRIVATE;
		WITH PROCEDURE GET(FROM: IN INSTRING; ITEM: OUT OUT_VAL;
		                   LAST: OUT POSITIVE) IS <>;
	PROCEDURE GET_VAL (VALUE: IN OUT OUT_VAL; INDEX: IN VAR);

-- Generic procedure used to read 1 dimensional arrays or vectors
-- from the namelist

	GENERIC
		TYPE COMP_TYPE IS PRIVATE;
		TYPE VINDEX IS (<>);
		TYPE VECT IS ARRAY (VINDEX RANGE <>) OF COMP_TYPE;
		WITH PROCEDURE GET(FROM: IN INSTRING; ITEM: OUT COMP_TYPE;
		                   LAST: OUT POSITIVE) IS <>;
	PROCEDURE GET_VAL_V (OUT_VECT: IN OUT VECT; INDEX: IN VAR);

-- Generic procedure used to read 2 dimensional arrays or matrices
-- from the namelist

	GENERIC
		TYPE COMP_TYPE IS PRIVATE;
		TYPE MINDEX IS (<>);
		TYPE MATRIX IS ARRAY (MINDEX RANGE <>, MINDEX RANGE <>)
									 OF COMP_TYPE;
		WITH PROCEDURE GET(FROM: IN INSTRING; ITEM: OUT COMP_TYPE;
		                   LAST: OUT POSITIVE) IS <>;
	PROCEDURE GET_VAL_M (OUT_MAT: IN OUT MATRIX; INDEX: IN VAR);

END NAMELIST_GENERIC;


PACKAGE BODY NAMELIST_GENERIC IS

-- This procedure  will read a file and initialize the data array used in
-- the package NAMELIST_GENERIC.

	PROCEDURE INIT_NAMELIST(FNAME: IN STRING := NOT_CHANGED) IS

		USE INTEGER_TEXT_IO;

		CVAL: INSTRING;
		DATALINE: STRING(1..132); -- Max size of line in input file
		INDEX: VAR; -- Emumerated type which indexes VAR_ARRAY
		LAST: INTEGER;
		LASTJ: INTEGER; -- Last value of index J in string CVAL
		NL_FILE: FILE_TYPE;
		NLINES: INTEGER := 0;
		NCHAR: INTEGER;-- Total number of characters in input line
		NCHARD: INTEGER; -- Number of data
		                 -- characters in input DATALINE
		NROWS: INTEGER := 1; -- Number of rows in two
		                     -- dimensional matrix
		INDEXS: INTEGER :=1; -- Index of beginning
		                     -- of matrix data element

	BEGIN

		IF(FNAME(1..3) = NOT_CHANGED) THEN
			PUT("PLEASE ENTER NAME OF NAME LIST FILE: ");
			GET_LINE(NAMELIST_FILE_NAME,NCHAR);
			NEW_LINE;
		ELSE
			NCHAR := FNAME'LAST;
			NAMELIST_FILE_NAME(1..NCHAR) := FNAME;
		END IF;

		OPEN(FILE=>NL_FILE, MODE=>IN_FILE,
			NAME=>NAMELIST_FILE_NAME(1..NCHAR));

		-- Initialize VAR_ARRAY 
		FOR II IN VAR_ARRAY'RANGE LOOP
			VAR_ARRAY(II)(1..3) := NOT_CHANGED;
		END LOOP;

		FOR I IN 1..200 LOOP -- reads up to 200 entries

			IF(END_OF_FILE(NL_FILE)) THEN
				EXIT;
			END IF;
			NLINES := NLINES + 1;

			-- INITIALIZE DATALINE
			FOR I IN DATALINE'RANGE LOOP
				DATALINE(I) := ' ';
			END LOOP;
			-- Read line from input file
			GET_LINE(NL_FILE,DATALINE,NCHARD);
			-- Look for comments
			FOR I IN 2..NCHARD LOOP
				IF((DATALINE(I)='-') AND (DATALINE(I-1)='-')) THEN
					NCHARD := I-2; -- NCHARD = 0 is ok
					EXIT;
				END IF;
			END LOOP;

			IF(NL_PRINT_FLAG = 1) THEN
				NEW_LINE;
				PUT (DATALINE(1..NCHARD));
			END IF;

			-- PARSE STRING AND INPUT INTO ARRAY

			FOR I IN 1..NCHARD LOOP

				-- Check to see if variable is matrix
				IF (DATALINE(I) = '(') THEN

					GET(DATALINE(1..I-1),INDEX,NCHAR); -- Get index

					FOR J IN I..NCHARD LOOP

						IF(DATALINE(J) = ',')THEN -- Get num of rows
							GET(DATALINE((I+1)..(J-1)),NROWS,LAST);
						END IF;

						-- read in first line of data
						IF (DATALINE(J) = '=') THEN -- Look for "="
							FOR K IN J+1..NCHARD LOOP
								CVAL(K-J) := DATALINE(K);
							END LOOP;
							LASTJ := NCHARD-J; -- Last used pos in CVAL
							EXIT;
						END IF;

					END LOOP;

					-- Read in additional datalines for matrix
					-- Loop on number of rows-1 in matrix
					FOR K IN 1..NROWS-1 LOOP

						-- INITIALIZE DATALINE
						FOR I IN DATALINE'RANGE LOOP
							DATALINE(I) := ' ';
						END LOOP;
						-- Read line from input file
						GET_LINE(NL_FILE,DATALINE,NCHARD);
						IF(NL_PRINT_FLAG = 1) THEN
							NEW_LINE;
							PUT (DATALINE(1..NCHARD));
						END IF;

						INDEXS :=1;
						FOR I IN 2..NCHARD LOOP
							-- Look for comments
							IF((DATALINE(I)='-') AND
							   (DATALINE(I-1)='-')) THEN
								NCHARD := I-2; -- NCHARD = 0 is ok
								EXIT;
							END IF;
							-- Find beginning of data strip
							-- leading blanks and tabs
							IF(INDEXS = 1 AND DATALINE(I) /=' '
								AND DATALINE(I) /= ASCII.HT) THEN
								INDEXS :=I;
							END IF;
						END LOOP;

						-- Make sure data can fit in CVAL
						IF(CVAL'LAST>=LASTJ+NCHARD-INDEXS+1) THEN
							FOR J IN INDEXS..NCHARD LOOP
								CVAL(J+LASTJ-INDEXS+1):= DATALINE(J);
							END LOOP;
							LASTJ := NCHARD-INDEXS+1+LASTJ;
						ELSE
							NEW_LINE;
							PUT(" DATALINE FOR MATRIX TOO LONG");
							NEW_LINE;
							PUT("FIX BY INCREASING CVAL'LAST");
							RAISE CONSTRAINT_ERROR;
						END IF;

					END LOOP;

					-- Pad with blanks
					FOR J IN LASTJ+1..CVAL'LAST LOOP
						CVAL(J) := ' ';
					END LOOP;

					-- Put read in data into VAR_ARRAY
					VAR_ARRAY(INDEX) := CVAL;
					IF(NL_PRINT_FLAG = 1) THEN
						NEW_LINE;
						PUT(" CVAL =");
						PUT(CVAL);
					END IF;
					EXIT;

				ELSIF (DATALINE(I) = '=') THEN -- Look for "="

					GET(DATALINE(1..I-1),INDEX,NCHAR); -- Get index
					IF (CVAL'LAST <= NCHARD-I) THEN
						-- Read in data for value when input data
						-- is greater than CVAL print out warning
						NEW_LINE;
						PUT("INPUT LINE IS TOO LARGE");
						PUT("FOR VALUE: ");PUT(DATALINE(1..I-1));
						NEW_LINE; PUT("TRUNCATING AND CONTINUING");
						NEW_LINE;
						PUT("FIX BY INCREASING CVAL'LAST");
						FOR J IN CVAL'RANGE LOOP
							CVAL(J):=DATALINE(I+J);
						END LOOP;
					ELSE
						-- Read in data for value when input data
						-- is smaller than CVAL
						FOR J IN 1..NCHARD-I LOOP
							CVAL(J):=DATALINE(I+J);
						END LOOP;
						-- Pad with blanks
						FOR J IN NCHARD-I+1..CVAL'LAST LOOP
							CVAL(J) := ' ';
						END LOOP;
					END IF;

					-- Put read in data into VAR_ARRAY
					VAR_ARRAY(INDEX) := CVAL;
					IF(NL_PRINT_FLAG = 1) THEN
						NEW_LINE;
						PUT(" CVAL =");
						PUT(CVAL);
					END IF;
					EXIT;

				END IF;

			END LOOP;

		END LOOP;

		CLOSE(NL_FILE);

		IF(NL_PRINT_FLAG = 1) THEN
			NEW_LINE;
			PUT(NLINES);
			PUT("  LINES READ INTO NAMELIST");
			NEW_LINE;
		END IF;
	EXCEPTION
		WHEN DATA_ERROR =>
			NEW_LINE(STANDARD_OUTPUT);
			PUT(STANDARD_OUTPUT," ERROR IN NAME LIST: ");
			PUT(STANDARD_OUTPUT," VARIABLE NAME NOT CORRECT?(xxxVAL)");
			RAISE;
		WHEN OTHERS =>
			RAISE;

	END INIT_NAMELIST;


-- This procedure reads in strings to string variables

	PROCEDURE GET_VALUE (OUT_STRING: IN OUT STRING; INDEX: IN VAR) IS

		Q1,Q2:INTEGER := 0;
		DINDEX: INTEGER;
		DATA: INSTRING := VAR_ARRAY(INDEX);

	BEGIN

		-- Check to see if value has been changed
		IF(VAR_ARRAY(INDEX)(1..3) = NOT_CHANGED) THEN
			RETURN;
		END IF;

		-- Find the quotes
		FOR I IN INSTRING'RANGE LOOP
			IF(DATA(I) = '"') THEN
				IF(Q1 = 0) THEN
					Q1 := I;
				ELSE
					Q2 := I;
				END IF;
			END IF;
		END LOOP;
		-- Place characters between quotes into out string.
		-- If out string is too short, characters are truncated
		-- from right side.  If out string is too long, blanks
		-- are added to right side.
		DINDEX := Q1;
		FOR I IN OUT_STRING'RANGE LOOP
			DINDEX := DINDEX+1;
			IF((DINDEX) >= Q1) AND (DINDEX < Q2 ) THEN
				OUT_STRING(I) := DATA(DINDEX);
			ELSE
				OUT_STRING(I) := ' ';
			END IF;
		END LOOP;

	EXCEPTION

		WHEN DATA_ERROR =>
			NEW_LINE(STANDARD_OUTPUT);
			PUT(STANDARD_OUTPUT," ERROR IN NAME LIST INPUT DATA: ");
			PUT(STANDARD_OUTPUT," CHECK SYNTAX OF INPUT FILE");
			RAISE;
		WHEN OTHERS =>
			RAISE;

	END GET_VALUE;


-- This generic procedure can be instantiated for integer, float
-- and enumerated
-- types.  "GET" for that type must be defined as a generic parameter.

	PROCEDURE GET_VAL (VALUE: IN OUT OUT_VAL; INDEX: IN VAR) IS

		LAST:POSITIVE;

	BEGIN

		-- Check to see if value has been changed
		IF(VAR_ARRAY(INDEX)(1..3) = NOT_CHANGED) THEN
			RETURN;
		END IF;

		GET(VAR_ARRAY(INDEX),VALUE,LAST);

	EXCEPTION

		WHEN DATA_ERROR =>
			NEW_LINE(STANDARD_OUTPUT);
			PUT(STANDARD_OUTPUT," ERROR IN NAME LIST INPUT DATA: ");
			PUT(STANDARD_OUTPUT," CHECK SYNTAX OF INPUT FILE");
			RAISE;
		WHEN OTHERS =>
			RAISE;

	END GET_VAL;


-- This generic procedure is used to read in the values for a one
-- dimensional array or vector.

	PROCEDURE GET_VAL_V (OUT_VECT: IN OUT VECT; INDEX: IN VAR) IS

		C1,C2:INTEGER := 1;
		LAST : INTEGER;
		DATA: INSTRING := VAR_ARRAY(INDEX);
		VALUE: COMP_TYPE;

	BEGIN

		-- Check to see if value has been changed
		IF(VAR_ARRAY(INDEX)(1..3) = NOT_CHANGED) THEN
			RETURN;
		END IF;

		-- Find the commas
		FOR M IN OUT_VECT'RANGE LOOP
			FOR I IN C1..DATA'LAST LOOP
				IF M = OUT_VECT'LAST THEN
					C2 := DATA'LAST;
					EXIT;
				END IF;
				IF(DATA(I) = ',') THEN
					C2 := I-1;
					EXIT;
				END IF;
			END LOOP;

			-- Place characters between commas into the correct
			-- element of the vector 
			GET(VAR_ARRAY(INDEX)(C1..C2),VALUE,LAST);

			OUT_VECT(M) := VALUE;

			C1 := C2+2;

		END LOOP;

	EXCEPTION

		WHEN DATA_ERROR =>
			NEW_LINE(STANDARD_OUTPUT);
			PUT(STANDARD_OUTPUT," ERROR IN NAME LIST INPUT DATA: ");
			PUT(STANDARD_OUTPUT," CHECK SYNTAX OF INPUT FILE");
			RAISE;
		WHEN OTHERS =>
			RAISE;

	END GET_VAL_V;


-- This generic procedure is used to read in the values for a two
-- dimensional array or matrix.

	PROCEDURE GET_VAL_M (OUT_MAT: IN OUT MATRIX; INDEX: IN VAR) IS

		C1,C2:INTEGER := 1;
		LAST : INTEGER;
		DATA: INSTRING := VAR_ARRAY(INDEX);
		VALUE: COMP_TYPE;

	BEGIN

		-- Check to see if value has been changed
		IF(VAR_ARRAY(INDEX)(1..3) = NOT_CHANGED) THEN
			RETURN;
		END IF;

		-- Find the commas and place into correct part of matrix
		FOR I IN OUT_MAT'RANGE(1) LOOP -- Loop on rows
			FOR J IN OUT_MAT'RANGE(2) LOOP -- Loop on columns

				FOR K IN C1..DATA'LAST LOOP
					IF (I = OUT_MAT'LAST(1)) AND -- Pick up last value
					   (J = OUT_MAT'LAST(2)) THEN
						C2 := DATA'LAST;
						EXIT;
					END IF;
					IF(DATA(K) = ',') THEN
						C2 := K-1;
						EXIT;
					END IF;
				END LOOP;

				-- Place characters between commas into the correct
				-- element of the matrix
				GET(VAR_ARRAY(INDEX)(C1..C2),VALUE,LAST);

				OUT_MAT(I,J) := VALUE;

				C1 := C2+2;

			END LOOP;

		END LOOP;

	EXCEPTION

		WHEN DATA_ERROR =>
			NEW_LINE(STANDARD_OUTPUT);
			PUT(STANDARD_OUTPUT," ERROR IN NAME LIST INPUT DATA: ");
			PUT(STANDARD_OUTPUT," CHECK SYNTAX OF INPUT FILE");
			RAISE;
		WHEN OTHERS =>
			RAISE;


	END GET_VAL_M;


END NAMELIST_GENERIC;
::::::::::
tnl.ada
::::::::::

---  TNL.ADA
-- This program tests the name list PROCEDUREs
-- by instantiating the file NLG.ADA

	WITH NAMELIST_GENERIC;
	WITH TEXT_IO; USE TEXT_IO;
	WITH INTEGER_TEXT_IO; USE INTEGER_TEXT_IO;
	WITH FLOAT_TEXT_IO; USE FLOAT_TEXT_IO;

PROCEDURE TNL IS

	TYPE VAR IS
	 (FYVAL,IVAL,M1VAL,M2VAL,M3VAL,M4VAL,MIVAL
	 ,TITLE1VAL,TITLE2VAL,TITLE3VAL,V1VAL
	 ,V12VAL,V2VAL,V3VAL,V4VAL,VACVAL,XVAL,YVAL);

	PACKAGE ENUM_IO IS NEW ENUMERATION_IO(VAR);
	USE ENUM_IO;

	PACKAGE NL IS NEW NAMELIST_GENERIC(VAR);
	USE NL;

-- test enumerated type

	TYPE DAYS IS (MON,TUES,WED,THUR,FRI,SAT,SUN);

	PACKAGE DAYS_IO IS NEW ENUMERATION_IO(DAYS);
	USE DAYS_IO;

-- Test Fixed point type

	TYPE FIXED IS DELTA 2.0 RANGE -20.0..18.0;

	PACKAGE FIXED_TEXT_IO IS NEW FIXED_IO(FIXED);
	USE FIXED_TEXT_IO;

-- Vector types
	TYPE VECTOR_F IS ARRAY(INTEGER RANGE <> ) OF FLOAT;
	TYPE VECTOR_E IS ARRAY(DAYS RANGE <> ) OF FLOAT;
	TYPE VECTOR_D IS ARRAY(INTEGER RANGE <> ) OF DAYS;

-- Matrix types
	TYPE MATRIX_F IS ARRAY(INTEGER RANGE <>, INTEGER RANGE <>) OF FLOAT;
	TYPE MATRIX_I IS ARRAY(INTEGER RANGE <>, INTEGER RANGE <>) OF INTEGER;
	TYPE MATRIX_E IS ARRAY(DAYS RANGE <>, DAYS RANGE <>) OF FLOAT;
	TYPE MATRIX_D IS ARRAY(INTEGER RANGE <>, INTEGER RANGE <>) OF DAYS;

-- Instantiate procedures for scalar types
	PROCEDURE GET_VALUE IS NEW GET_VAL(DAYS);
	PROCEDURE GET_VALUE IS NEW GET_VAL(FLOAT);
	PROCEDURE GET_VALUE IS NEW GET_VAL(FIXED);
	PROCEDURE GET_VALUE IS NEW GET_VAL(INTEGER);

-- Instantiate procedures for vector types
	PROCEDURE GET_VALUE IS NEW GET_VAL_V(FLOAT,INTEGER,VECTOR_F);
	PROCEDURE GET_VALUE IS NEW GET_VAL_V(FLOAT,DAYS,VECTOR_E);
	PROCEDURE GET_VALUE IS NEW GET_VAL_V(DAYS,INTEGER,VECTOR_D);

-- Instantiate procedures for 2 dimensional array types
	PROCEDURE GET_VALUE IS NEW GET_VAL_M(FLOAT,INTEGER,MATRIX_F);
	PROCEDURE GET_VALUE IS NEW GET_VAL_M(INTEGER,INTEGER,MATRIX_I);
	PROCEDURE GET_VALUE IS NEW GET_VAL_M(FLOAT,DAYS,MATRIX_E);
	PROCEDURE GET_VALUE IS NEW GET_VAL_M(DAYS,INTEGER,MATRIX_D);

	Y,X:FLOAT:= 0.0;
	I:INTEGER:= 0;
	VAC: DAYS:= FRI;
	FY:FIXED := 4.0;

	V1:VECTOR_F(1..5);
	V2:VECTOR_F(-1..1);
	V3:VECTOR_E(MON..FRI);
	V4:VECTOR_D(3..5);

	M1:MATRIX_F(1..3,1..3);
	M2:MATRIX_F(1..2,-1..1);
	MI:MATRIX_I(-1..0,-1..0);
	M3:MATRIX_E(THUR..FRI,WED..FRI);
	M4:MATRIX_D(0..2,-1..0);


	TITLE1: STRING(1..10);
	TITLE2: STRING(1..22):=" Whats your problem?!!";
	TITLE3: STRING(1..40);

	FNAME: STRING(1..30);
	OUTFILE: FILE_TYPE;
	NCHAR: INTEGER;

BEGIN

-- READ IN DATA FROM FILE AND INITIALIZE THE DATA ARRAY
	NL_PRINT_FLAG := 1;
	INIT_NAMELIST;

-- Open up output file
	NEW_LINE;
	PUT("PLEASE ENTER NAME OF OUTPUT FILE: ");
	GET_LINE(FNAME,NCHAR);
	NEW_LINE;
	CREATE(FILE=>OUTFILE, MODE=> OUT_FILE, NAME=> FNAME(1..NCHAR));
	SET_OUTPUT(OUTFILE);

	NEW_LINE(2);
	PUT("THIS IS A TEST: The following are the translated values");
	NEW_LINE(2);

-- Floating point scalars
	GET_VALUE(X,XVAL);
	PUT("X:FLOAT TYPE=");
	PUT(X);

	NEW_LINE(2);
	GET_VALUE(Y,YVAL);
	PUT("Y: FLOAT TYPE=");
	PUT(Y);

-- Fixed point scalar
	NEW_LINE(2);
	GET_VALUE(FY,FYVAL);
	PUT("FY: FIXED POINT  TYPE=");
	PUT(FY);

-- Integer scalar
	NEW_LINE(2);
	GET_VALUE(I,IVAL);
	PUT("I: INTEGER TYPE=");
	PUT(I);

-- Enumerated scalar
	NEW_LINE(2);
	GET_VALUE(VAC,VACVAL);
	PUT("VAC: ENUMERATION TYPE=");
	PUT(VAC);

-- Strings
	NEW_LINE(2);
	GET_VALUE(TITLE1,TITLE1VAL);
	PUT("TITLE1(STRING(1..10))=");
	PUT(TITLE1);

	NEW_LINE(2);
	GET_VALUE(TITLE2,TITLE2VAL);
	PUT("TITLE2(STRING)(DEFAULT VALUE)=");
	PUT(TITLE2);

	NEW_LINE(2);
	GET_VALUE(TITLE3,TITLE3VAL);
	PUT("TITLE3: STRING(1..40)=");
	PUT(TITLE3);

-- Floating point element of vector
	NEW_LINE(2);
	GET_VALUE(V1(2),V12VAL);
	PUT("V1(2):ELEMENT OF VECTOR=");
	NEW_LINE;
	PUT(V1(2));

-- Floating point vectors
	NEW_LINE(2);
	GET_VALUE(V1,V1VAL);
	PUT("V1: VECTOR(1..5) OF FLOAT TYPE=");
	NEW_LINE;
	FOR K IN V1'RANGE LOOP
		PUT(V1(K));
	END LOOP;


	NEW_LINE(2);
	GET_VALUE(V2,V2VAL);
	PUT("V2: VECTOR(-1..1) OF FLOAT TYPE=");
	NEW_LINE;
	FOR K IN V2'RANGE LOOP
		PUT(V2(K));
	END LOOP;

-- Vector indexed by enumerated type of floating point
	NEW_LINE(2);
	GET_VALUE(V3,V3VAL);
	PUT("V3: VECTOR(MON..FRI) OF FLOAT TYPE=");
	NEW_LINE;
	FOR K IN V3'RANGE LOOP
		PUT(V3(K));
	END LOOP;

-- Vector of  enumerated type DAYS
	NEW_LINE(2);
	GET_VALUE(V4,V4VAL);
	PUT("V4: VECTOR(3..5) OF ENUMERATED TYPE=");
	NEW_LINE;
	FOR K IN V4'RANGE LOOP
		PUT(V4(K));PUT(" ");
	END LOOP;


-- 3x3 Matrix of floating point
	NEW_LINE(2);
	GET_VALUE(M1,M1VAL);
	PUT("M1: MATRIX(3,3) OF FLOAT TYPE=");
	NEW_LINE;
	FOR K IN M1'RANGE(1) LOOP
		PUT(M1(K,1));
		PUT(M1(K,2));
		PUT(M1(K,3));
		NEW_LINE;
	END LOOP;

-- 2x3 Matrix of floating point
	NEW_LINE(2);
	GET_VALUE(M2,M2VAL);
	PUT("M2: MATRIX(2,3) OF FLOAT TYPE=");
	NEW_LINE;
	FOR K IN M2'RANGE(1) LOOP
		PUT(M2(K,-1));
		PUT(M2(K,0));
		PUT(M2(K,1));
		NEW_LINE;
	END LOOP;

-- 2x2 Matrix of integer
	NEW_LINE(2);
	GET_VALUE(MI,MIVAL);
	PUT("MI: MATRIX(2,2) OF INTEGER TYPE=");
	NEW_LINE;
	FOR K IN MI'RANGE(1) LOOP
		PUT(MI(K,-1));
		PUT(MI(K,0));
		NEW_LINE;
	END LOOP;

-- 2x3 Matrix of indexed by enumerated type DAYS of floating point
	NEW_LINE(2);
	GET_VALUE(M3,M3VAL);
	PUT("M3: MATRIX(2,3) INDEX BY ENUMERATED TYPE; OF FLOAT TYPE=");
	NEW_LINE;
	FOR K IN M3'RANGE(1) LOOP
		PUT(M3(K,WED));
		PUT(M3(K,THUR));
		PUT(M3(K,FRI));
		NEW_LINE;
	END LOOP;

-- 3x2 Matrix of type DAYS indexed by INTEGER
	NEW_LINE(2);
	GET_VALUE(M4,M4VAL);
	PUT("M4: MATRIX(3,2)of ENUMERATED TYPE=");
	NEW_LINE;
	FOR K IN M4'RANGE(1) LOOP
		PUT(M4(K,-1));PUT(" ");
		PUT(M4(K,0));
		NEW_LINE;
	END LOOP;

	CLOSE(OUTFILE);

END TNL;
::::::::::
test1.dat
::::::::::

-- TEST1.DAT  File to test capabilities of NAMELIST

     YVAL= 234234.0

-- Fixed point type

		FYVAL = 12.0

-- 5 Element vector 
 V1VAL = 2.0,3.0,4.0,5.0,6.0

-- One element of vector
	v12val = 12.0
  IVAL = 9909
	VACVAL = SAT


	TITLE1VAL = "This is the first title"
TITLE3VAL = "  ``single quotes'' 2 DOUBLE QUOTES " "  SDF    "

-- Vector Input

	V2VAL = 34.5,67.8,90.1

	v3val = 2.0,3.0,0.234,4.0,5.0  -- Vector indexed by enumerated type of floating

	v4val = FRI,FRI,SAT -- Vector of enumerated type

-- Matrix inputs


-- FLOATING POINT MATRIX
M1VAL(3,3)= 1.0,2.0,3.0, -- FIRST ROW
	    4.0,5.0,6.0,-- SECOND ROW
	    7.0,8.0,9.0 -- THIRD ROW

M2VAL(2,2)=	1.0,2.0,3.0,
		4.0,5.0,6.0

-- INTEGER MATRIX
MIVAL(2,2)= 11, 12,
	        13, 14

	M3VAL(2,3) = 123.45,2345.476,35.0,
		   123.45,2345.476,35.0

	M4VAL(3,2) = 	MON,MON,
				TUES,TUES,
				SAT,SUN

-- End of File
::::::::::
outnl.dat
::::::::::


THIS IS A TEST: The following are the translated values

X:FLOAT TYPE= 0.00000E+00

Y: FLOAT TYPE= 2.34234E+05

FY: FIXED POINT  TYPE= 12.0

I: INTEGER TYPE=       9909

VAC: ENUMERATION TYPE=SAT

TITLE1(STRING(1..10))=This is th

TITLE2(STRING)(DEFAULT VALUE)= Whats your problem?!!

TITLE3: STRING(1..40)=  ``single quotes'' 2 DOUBLE QUOTES " " 

V1(2):ELEMENT OF VECTOR=
 1.20000E+01

V1: VECTOR(1..5) OF FLOAT TYPE=
 2.00000E+00 3.00000E+00 4.00000E+00 5.00000E+00 6.00000E+00

V2: VECTOR(-1..1) OF FLOAT TYPE=
 3.45000E+01 6.78000E+01 9.01000E+01

V3: VECTOR(MON..FRI) OF FLOAT TYPE=
 2.00000E+00 3.00000E+00 2.34000E-01 4.00000E+00 5.00000E+00

V4: VECTOR(3..5) OF ENUMERATED TYPE=
FRI FRI SAT 

M1: MATRIX(3,3) OF FLOAT TYPE=
 1.00000E+00 2.00000E+00 3.00000E+00
 4.00000E+00 5.00000E+00 6.00000E+00
 7.00000E+00 8.00000E+00 9.00000E+00


M2: MATRIX(2,3) OF FLOAT TYPE=
 1.00000E+00 2.00000E+00 3.00000E+00
 4.00000E+00 5.00000E+00 6.00000E+00


MI: MATRIX(2,2) OF INTEGER TYPE=
         11         12
         13         14


M3: MATRIX(2,3) INDEX BY ENUMERATED TYPE; OF FLOAT TYPE=
 1.23450E+02 2.34548E+03 3.50000E+01
 1.23450E+02 2.34548E+03 3.50000E+01


M4: MATRIX(3,2)of ENUMERATED TYPE=
MON MON
TUES TUES
SAT SUN
