WARNING:This example assumes the output is sent to a printer, and as a result, every formatted output contains printer control.

1 1 2 2 3 3 4 4 5 5 6 6 7 7 ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5 1 2.00000 0.69315E+00 0.69315E+000 6.93147E-01 693.14718E-03 2 1.80000 0.58779E+00 0.58779E+000 5.87787E-01 587.78661E-03 3 1.60000 0.47000E+00 0.47000E+000 4.70004E-01 470.00358E-03 : : : 10 0.20000 -0.16094E+01 -0.16094E+001 -1.60944E+00 -1.60944E+00

ClickPROGRAM LogFunction IMPLICIT NONE REAL, PARAMETER :: Initial = 2.0 REAL, PARAMETER :: Final = 0.0 REAL, PARAMETER :: Step = -0.2 REAL :: x INTEGER :: Count CHARACTER(LEN=80) :: FMT FMT = "(I3, F10.5, E15.5, E15.5E3, ES15.5, EN15.5)" Count = 1 x = Initial DO IF (x <= Final) EXIT WRITE(*,FMT) Count, x, LOG(x), LOG(x), LOG(x), LOG(x) x = x + Step Count = Count + 1 END DO END PROGRAM LogFunction

1 1 2 2 3 3 4 4 5 5 6 6 7 7 ....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5 1 2.00000 0.69315E+00 0.69315E+000 6.93147E-01 693.14718E-03 2 1.80000 0.58779E+00 0.58779E+000 5.87787E-01 587.78661E-03 3 1.60000 0.47000E+00 0.47000E+000 4.70004E-01 470.00358E-03 4 1.40000 0.33647E+00 0.33647E+000 3.36472E-01 336.47212E-03 5 1.20000 0.18232E+00 0.18232E+000 1.82321E-01 182.32140E-03 6 1.00000 -0.17881E-06 -0.17881E-006 -1.78814E-07 -178.81395E-09 7 0.80000 -0.22314E+00 -0.22314E+000 -2.23144E-01 -223.14376E-03 8 0.60000 -0.51083E+00 -0.51083E+000 -5.10826E-01 -510.82587E-03 9 0.40000 -0.91629E+00 -0.91629E+000 -9.16291E-01 -916.29112E-03 10 0.20000 -0.16094E+01 -0.16094E+001 -1.60944E+00 -1.60944E+00

- Since from 2.0 down to 0.2 with a step size 0.2 has only 10
numbers, the sequence number has no more than 2 digits and can be
printed with
**I3**with the first position being space. - For each of the remaining
**REAL**values, we shall use five positions for the fractional part. Therefore, the value of**x**is printed**F10.5**. The four**LOG(x)**values are printed with**E15.5**,**E15.5E3**with three positions for the exponent,**ES15.5**and**EN15.5**. Hence, the format isCHARACTER(LEN=80) :: FMT FMT = "(I3, F10.5, E15.5, E15.5E3, ES15.5, EN15.5)"

- Since the last four values are the same but printed with different
edit descriptors, you can compare their appearances. Of the last
four values, the first and second are almost identical, except
that the former has two positions for the exponent while the
latter uses three. The third is printed with the
**ES**descriptor, the integral part always has a non-zero digit and, as a result, the exponent value is one less than those using**E**. The last value uses**EN**, which causes**Fortran**to use no more than three digits in the integral part. For example, the value of**LOG(2.0)**(the first row) when printed with**E15.5**is**0.69315E+00**. If it is printed using**EN15.5**, the decimal point is shifted to the right three positions and the exponent is decreased by 3 generating an output**693.14718E-03**. For the last value(*i.e.*, 0.2), we have**-0.16094E+01**using the**E**edit descriptor. If it is printed using the**EN**edit descriptor, the result is**-1.60944E+00**.**Why?**Recall that for the engineering notation, the exponent is a multiple of three and therefore, the possible values are 0, 3, -3, 6, -6, 9, -9, and so on. Since moving the decimal point in**-0.16094E+01**to the right one position makes the exponent a zero, the printed result is**-1.60944E+00**.