The slash edit descriptor / is used to terminate the current input/output line. The general forms of this descriptor are as follows:
is equivalent toREAD(*,"(I3,5X,I5,/,/,T15,F10.0)") ......
READ(*,"(I3,5X,I5//T15,F10.0)") ......
1
....5....0
123 456
789 012
345 678
Suppose this input is read by the following READ statement.
The reading starts with the first input line. I5 is for reading an integer for a. Thus, a receives a value of 123. Since the next edit descriptor is a /, the content on the current input line is ignored. As a result, the next available position for b is the first position on the second input line and b receives 789. After this, we see a second / which causes ignoring the remaining of the second input line. Therefore, the value for c is taken from the first five positions on the third input line and c receives 345.INTEGER :: a, b, c READ(*,"(I5/I5/I5)") a, b, c
Note that the above READ statement consumes three input lines. The first line is read using the edit descriptors between the opening left parenthesis ( and the first /, the second input line is read using the edit descriptors between the two /s, and the third input line is read using the edit descriptors between the second / and the closing right parenthesis ).
1
....5....0
123 456
789 012
345 678
901 234
567 890
135
Suppose this input is read by the following READ statement.
a is read in using I5 from the first five positions of the first line. Thus, it receives 123. After this, we see a /, which terminates the use of the first input line and jumps to the second. Then, we see another /, which terminates the use of the second input line and jumps to the third. Now, we have I5 for variable b. Therefore, b receives 345 from the third input line. After reading b, we have a / and c will use the fourth input line. Hence, c receives 901. But, immediately after this I5, there is another / and as a result this fourth line is also skipped. Thus, we are on the fifth line. Then, we reach the end of the format and there is no variables remains. Thus, the first READ completes. Note that after the first READ completes, five lives have been read.INTEGER :: a, b, c, d READ(*,"(I5//I5/I5/)") a, b, c READ(*,"(I5)") d
When the second READ starts, the sixth input line is read and d receives 135.
The above discussion is illustrated with the figure below.
When this WRITE starts, the format begins with I5. Since this is an edit descriptor that requires a value, the format scanning stops here and puts the value 123 into positions 1 to 5 of the first output line:WRITE(*,"(I5//I6/1X,A)") 123, 456, "+-*/"
1
....5....0
123
After printing the value of 123, format scanning starts with
/. This causes the end of the current line.
Then, we see another /, which terminates the second
output line. The next edit descriptor is I6. Since it is
an edit descriptor that requires a value, 456 is printed in
positions 1 to 6 on the third output line:
1
....5....0
123
456
Then, format scanning resumes with /, which terminates the
third output line.
The next is 1X, followed by A. Hence, the first
position of the next (i.e., fourth) output line is a space
(i.e., 1X), followed by +-*/.
After printing this item,
the end of format is reached. Since all data items have been
printed, this WRITE completes. In summary, this
WRITE prints four output lines. Of these four lines, the
second one is a blank line generated by the two adjacent slashes.
1
....5....0
123
456
+-*/
When the first WRITE starts, format scan begins with the first /. This terminates the first output line. Then, we see a second / which terminates the second line. Thus, we have two blank lines. The next edit descriptor is 1X, which moves to position 2 of the third output line. Now, we see A, which requires a data value. Therefore, "Title" is printed in positions 2 to 6 on the third line:WRITE(*,"(//1X,A,A/)") "Title", " ABC" WRITE(*,"(1X,A,I5)") "Data --> ", 123
1
....5....0
<--- line 1, printed by /
<--- line 2, printed by /
Title
Format scanning continues and encounters the second A.
Thus, "  ABC" is printed in positions 7 to 11.
Then, we see a / which terminates the third output line.
After this, the end of format is reached and no
data items remains, the first WRITE completes with
the fourth output line being a blank one:
1 1
....5....0....5
<--- line 1, printed by /
<--- line 2, printed by /
Title ABC <--- line 3, printed by 1X, A, A/
<--- line 4, printed by the closing parenthesis
The second WRITE prints its content on the fifth line
and the final result is shown below:
1 1
....5....0....5
Title ABC
Data --> 123 <--- line 5, printed by 1X, A, I5
In summary, the first WRITE prints four lines. Of these
four, the first is generated by the opening left parenthesis
and the first slash, the second is generated by the two adjacent
slashes, the third is generated by 1X,A,A/, and the fourth
is generated by the third slash and the closing parenthesis.
Note that the first, second and fourth output
lines are blank lines.
The above discussion is summarized in the figure below: