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
Click here to download this program.PROGRAM 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
CHARACTER(LEN=80) :: FMT FMT = "(I3, F10.5, E15.5, E15.5E3, ES15.5, EN15.5)"