# REAL Input: The F and E Descriptors The Fw.d, Ew.d, ESw.d, ENw.d, Ew.dEe, ESw.dEe and ENw.dEe descriptors are used for REAL input; however, they all have the same effect as Fw.d. Therefore, we shall only discuss Fw.d. The general form of the Fw.d descriptor is as follows:

rFw.d

The meaning of r, w and m are:

• F is for REAL
• w is the width of field, which indicates that a real number should be read in from the next w positions.
• d is the number of digits in the fractional part. There are two possibilities:
1. If the number in the w contains a decimal point, d is ignored and the value read is the number described in the w positions.
2. If the number in the w positions does not have a decimal point, then the right most d positions are considered to be the fractional point. More precisely, a decimal point is inserted between the d and the d+1 positions from the right.
Please note that spaces may be ignored or treated as zeros. Therefore, adding a decimal point in your input is a wise choice.

For example, suppose we have the following:

```REAL :: u, v, w

```
and the input is
```         1    1
....5....0....5
1 2 3 4.5 1 9.4
```
Let us assume that spaces are ignored. u takes the first five positions which contains 1, a space, 2, a space and 3. Since F5.2 is used to read this number (i.e., 123) which does not have a decimal point, a decimal point is inserted between 1 and 2. Hence, u receives 1.23. Variable v takes the next five positions, which contains a space, 4.5 and another space. Since this value contains a decimal point, it is read as is and v receives 4.5. Variable w takes the last five positions, which contain 1, a space, and 9.4. This gives 19.4 and therefore w receives 19.4.

Suppose spaces are treated as zeros. The first five positions are 1, space, 2, space and 3, which is equivalent to 10203. Therefore, u receives 102.03. Similarly, variables v and w receive 4.5 and 109.4, respectively.

• The number in the w positions can contain a E followed by the value of the exponent.
• The w positions must contain a legal real number with an optional sign and/or an E followed by an exponent. The exponent, if any, must be an integer.

A real number without a decimal point in the w positions consists of an optional sign, followed by a sequence of digits. In this case, the place of the decimal point is determined by the value of d.

A real number with a decimal point starts with an optional sign, followed by zero or more digits (the integral part), followed by a decimal point, followed by zero or more digits (the fractional part). Thus, -.345, 0.345, +123 are all correct input real numbers. Note that the integral part or the fractional part must have one digit. As a result, -. is not a correct input real number.

A real number with an exponent starts with a real number, with or without a decimal point, followed by E, followed by an optional sign, followed by an integer. Thus, 12345E-9 and 12.345E-23 are correct real numbers. If the input real number contains an exponent, then d applies to the number itself. For example, if we have

```REAL :: u

```
and the input is
```         1
....5....0
12345E20
```
then u takes the first ten positions. If spaces are ignored, the exponent is 20 and 12345 is read in with 4 digits in the fractional part. Therefore, the actual value read in is 1.2345×1020. If spaces are treated as zeros, the value read in becomes 1.2345×102000. For most computers, this value could be too larger to be stored in memory.

No other symbols can be used; otherwise, the READ statement that uses this format will report an error and stop. If all w positions are spaces, the value is treated as a zero.

• Converting an input real number to a number in computer memory cannot be exact, because the input number is in base-10 representation and most computers use base-2 or base-16 internal representation for real numbers.
• r is the repetition indicator, which gives the number of times the edit descriptor should be repeated. For example, 3F5.3 is equivalent to F5.3, F5.3, F5.3. ### Examples

Suppose we have the following input and the system ignores spaces.
```         1    1    2
....5....0....5....0
12 3.4  56E 78.  90
```
• What are the values in each variable after reading in the above input?
```REAL :: a, b, c, d

READ(*,"(F3.0, F4.1, F6.2, F7.3)")  a, b, c, d
```
Suppose spaces are ignored. Variable a takes the first three positions, which contains 1, 2 and a space. After removing spaces, we have 12 and since F3.0 states no digits for the fractional part, the value read in is 12.0. Variable b takes the next four positions, which contain 3, a decimal point, a 4 and a space. After removing all spaces, we have 3.4. Since there is a decimal point, the value will be read in as is. Thus, b receives 3.4. Variable c takes the next six positions, which contain a space, 5, 6, E, a space and 7. After removing all spaces, we have 56E7. Thus, the exponent is 7 and 56 is read with F6.2 (i.e., two digits after the decimal point). Therefore, variable c receives 0.56×107. Variable d takes the next seven positions, which contain a 8, a decimal point, two spaces, 9, 0 and a space. After removing all spaces, we have 8.90. Since it contains a decimal point, the value will be read in as is and d receives 8.9

If the system treats spaces as zeros, a, b, c and d receive 120, 3.4, 0.56×107, and 8.009, respectively.

• What are the values in each variable after reading in the above input?
```REAL :: a, b, c, d

READ(*,"(F6.1, F3.2, F5.0, F6.1)")  a, b, c, d
```
Variable a takes the first 6 positions, which contain 1, 2, a space, 3, a decimal point and 4. Thus, a receives 123.4. Variable b takes the next three positions, which contain two spaces and 5. Thus, b receives 0.05. Variable c takes the next five positions, which contains 6, E, a space, 7 and 8. Hence, c receives 6×1078. Finally, d takes the next six positions, which contains a decimal point, two spaces, 9, 0 and a space. Hence, d receives 0.9.

If the system treats spaces as zeros, a, b, c and d receive 1203.4, 0.05, 6×1078 and 0.009, respectively.