CHARACTER Input: The A Descriptor

The Aw and A descriptors are used for CHARACTER input. The general forms are:

rAw     and      rA

The meaning of r and w are:

• A is for CHARACTER
• w is the width of field, which indicates that an character string should be read in from the next w positions.
• If w is missing, then its value is equal to the length of the CHARACTER variable.
• There are three cases to consider:
1. w is equal to the length of the CHARACTER variable : We have an exact match and the content of the w positions is stored into the CHARACTER variable completely.
2. w is larger than the length of the CHARACTER variable : If the length of the CHARACTER variable is k, then the content of the right-most k positions will be taken and stored in the length k CHARACTER variable.
3. w is less than the length of the CHARACTER variable : In this case, the input CHARACTER variable has more positions than the input and spaces are appended.
• The content in the w positions can be a combination of letters, digits and symbols.
• r is the repetition indicator, which gives the number of times the edit descriptor should be repeated. For example, 3A5 is equivalent to A5, A5, A5.

Examples

Suppose we have the following input and the system ignores spaces.
```         1    1    2
....5....0....5....0
ABCDEFGHIJKLMNOPQRST
```
• What are the values in each variable after reading in the above input?
```CHARACTER(LEN=5) :: a, b, c
CHARACTER(LEN=3) :: d

READ(*,"(A4, A5, A7, A")  a, b, c, d
```
Variable a takes the first four positions (i.e., A, B, C and D). Since the length of a is five, which is larger than w=4, a space is appended to the right. Therefore, a receives "ABCD ". Variable b takes the next five positions (i.e., E, F, G, H and I). Since w=5 which is equal to the length of b, b receives all five characters "EFGHI". Variable c takes the next seven positions (i.e., J, K, L, M, N, O and P). Since w=7 is larger than the length of the variable, only the right-most five positions will be taken. Thus, variable c receives "LMNOP". Finally, variable d uses A. Since the length of variable d is 3, this A edit descriptor is equivalent to A3 and hence d takes the next three positions (i.e., Q, R and S). As a result, variable d receives "QRS".
• What are the values in each variable after reading in the above input?
```CHARACTER(LEN=5) :: a, b*3, c*7, d*4
INTEGER :: a, b, c, d