WARNING:This example assumes spaces are ignored for theIandFdescriptors.

Write a1 1 2 2 3 3 4 4 5 ....5....0....5....0....5....0....5....0....5....0 5 12.3 1234 1.234 3.14 1.2E-3 3341 1.2E-5 1.23E+1 7.69E-3 2314 12.34E-9 2.44E-1 12345 3309 1 3 4 5 7.64E-2 77 88 1953 7 5 3.34E+1

Note that the first position is always for printer control.1 1 2 2 ....5....0....5....0....5 Input Number List ================= 1 - 12.34 3.14 2 - 33.41 12.30 3 - 23.14 0.24 4 - 33.09 0.08 5 - 19.53 33.40 --------------------- Sum = 1110.17

ClickPROGRAM Select_Numbers IMPLICIT NONE INTEGER :: Number, i REAL :: u, v, x, y, Sum CHARACTER(LEN=40) :: ReadIn, WriteOut ReadIn = "(2F10.2,F20.2,F10.2)" WriteOut = "(I5, A, 2F7.2)" READ(*,"(I5)") Number Sum = 0.0 WRITE(*,"(A, A)") " ", "Input Number List" WRITE(*,"(A, A)") " ", "=================" DO i = 1, Number READ(*,ReadIn) u, v, x, y WRITE(*,WriteOut) i, " - ", v, y Sum = Sum + v*y END DO WRITE(*,"(A, A)") " ", "---------------------" WRITE(*,"(A, A, F7.2)") " ", "Sum = ", Sum END PROGRAM Select_Numbers

1 1 2 2 3 3 ....5....0....5....0....5....0....5 Input Number List ================= 1 - 12.34 3.14 2 - 33.41 12.30 3 - 23.14 0.24 4 - 33.09 0.08 5 - 19.53 33.40 --------------------- Sum = 1110.17

- The input format is
**(2F10.2,F20.2,F10.2)**. Since each field has 10 positions except for the third one which has 20, we use**2F10.2**to read the first two numbers,**F20.2**for the third, and**F10.2**for the fourth. - We read all four numbers in and only use the second and the fourth one. The remaining parts are easy.