next up previous index
Next: J200 Print Large Up: CERNLIB Previous: I302 Format-Free Input

I303 Read a Format-Free Number

Routine ID: I303
Author(s): G. KozlovskyLibrary: KERNLIB
Submitter: Submitted: 07.09.1986
Language: FortranRevised:

OBSOLETE

Please note that this routine has been obsoleted in CNL 219. Users are advised not to use it any longer and to replace it in older programs. No maintenance for it will take place and it will eventually disappear.
Suggested replacement: CHPACK (M432)

RDWORD is a lexical analyser which reads numbers, alphabetic names and special characters from its internal buffer in format free form. The definitions of the three above mentioned lexical entities are as follows:

A number has the form sd.dEsdx.

s:
'+' or '-' or null;
d:
Zero or more decimal digits;
.:
Decimal point or may be omitted;
E:
'e' or 'E' or null;
x:
Terminating character which may be a blank, a letter, a special character, a second appearance of '.' or 'E', a '+' or a '-' followed by a digit.
The sequence d.d must contain at least one digit ( 0. or .0 are valid numbers, but not a decimal point alone). If E is omitted, the following sd must be omitted. If E is present, it must be followed by a d containing at least one digit.

An alphabetic name has the form ax and an alphanumeric name the form ady.

a:
One or more alphabetic characters ( a,...,z,A,...,Z);
d:
Zero or more decimal digits;
x:
Terminating character, which can be any non-alphabetic character;
y:
Terminating character, which can be any character except an alphabetic character or a decimal digit.
A special character is any character except an alphabetic character, decimal digit or blank.

Lexical entities may be separated by any number of blanks. The internal buffer has a length of 80 characters. A blank is added logically as an 81st character.

Structure:

SUBROUTINE subprograms
User Entry Names: RDWORD, RDLOAD, RDSKIP, RDENDB
Internal Entry Names:
RALPH, RDIGI, RDINT, RDMANT, RDNAME, RDNEXT, RDSKPB, RDUPCH,
RDUPST

Usage:

    CALL RDLOAD(STRING)
Puts STRING (of type CHARACTER*(*)) into the internal buffer of RDWORD and sets the internal pointer to the first position of the buffer. If STRING is shorter than the buffer length the rest of the buffer is filled with blanks. If STRING is longer than the buffer (80 characters), the remainder of it will be truncated.

    CALL RDWORD(INUM,FPNUM,NAME,KTYPE)
Causes the next object (if any) to be read from the internal buffer starting from the current position of the internal pointer to the buffer while skipping leading blanks until the first non-blank character or the end of the buffer is encountered, and positions the internal pointer to the terminating character of the object.

On exit, the arguments have the following values:
When an integer or floating point number was read:

INUM
( INTEGER) The integer or the integer part of the floating point number read.
FPNUM
( REAL) The number read.
NAME
( CHARACTER*(*)) Filled with blanks.
KTYPE
( INTEGER) Type of object read:
= 1: Floating point number;
= 2: Integer number.
Reading and conversion by RDWORD takes place from an internal file. I-format is used to read integers and F-format is used to read floating point numbers (this format can handle an exponent on input). Consequently, in the case of wrong input format, an error message may be issued by a Fortran system input routine.

When a name or special character was read:

INUM
( INTEGER) Zero.
FPNUM
( REAL) Zero.
NAME
( CHARACTER*(*)) The name in UPPERCASE (for alphabetic) characters or the special character, left justified and filled with blanks.
KTYPE
( INTEGER) Type of object read:
= 0: Special character;
= -1: Name.
If the name read is longer than allowed by NAME, it is truncated and an error message
    ERROR IN RDWORD: NAME READ IS TOO LONG. IT IS TRUNCATED TO: NTRUNC
is printed. NTRUNC stands for the truncated name.

When an "end of buffer" is reached:

INUM
( INTEGER) Zero.
FPNUM
( REAL) Zero.
NAME
( CHARACTER*(*)) Filled with blanks.
KTYPE
( INTEGER) = -100 .
    CALL RDSKIP
Sets the internal pointer to 81 which means "end of buffer".
    CALL RDMODE(I)
A call with I=2 will force RDWORD to read, as variables of type CHARACTER, sets of alphanumeric characters starting with a letter, such as ALPHA99.

The default mode (purely alphabetic names that will be terminated by a digit will be restored by a call with I=1 .
In any expression of type LOGICAL

    RDENDB()
has the value .TRUE. if the end of the buffer was reached, and .FALSE. otherwise. RDENDB is of type LOGICAL.

Output and Graphical Data Presentation

J200



next up previous index
Next: J200 Print Large Up: CERNLIB Previous: I302 Format-Free Input


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995