111
|
1 ! { dg-do run }
|
|
2 ! Check real value edit descriptors
|
|
3 ! Also checks that rounding is performed correctly
|
|
4 program edit_real_1
|
|
5 character(len=20) s
|
|
6 character(len=20) x
|
|
7 character(len=200) t
|
|
8 parameter (x = "xxxxxxxxxxxxxxxxxxxx")
|
|
9
|
|
10 ! W append a "z" onto each test to check the field is the correct width
|
|
11 s = x
|
|
12 ! G -> F format
|
|
13 write (s, '(G10.3,A)') 12.36, "z"
|
131
|
14 if (s .ne. " 12.4 z") STOP 1
|
111
|
15 s = x
|
|
16 ! G -> E format
|
|
17 write (s, '(G10.3,A)') -0.0012346, "z"
|
131
|
18 if (s .ne. "-0.123E-02z") STOP 2
|
111
|
19 s = x
|
|
20 ! Gw.eEe format
|
|
21 write (s, '(G10.3e1,a)') 12.34, "z"
|
131
|
22 if (s .ne. " 12.3 z") STOP 3
|
111
|
23 ! E format with excessive precision
|
|
24 write (t, '(E199.192,A)') 1.5, "z"
|
131
|
25 if ((t(1:7) .ne. " 0.1500") .or. (t(194:200) .ne. "00E+01z")) STOP 4
|
111
|
26 ! EN format
|
|
27 s = x
|
|
28 write (s, '(EN15.3,A)') 12873.6, "z"
|
131
|
29 if (s .ne. " 12.874E+03z") STOP 5
|
111
|
30 ! EN format, negative exponent
|
|
31 s = x
|
|
32 write (s, '(EN15.3,A)') 12.345e-6, "z"
|
131
|
33 if (s .ne. " 12.345E-06z") STOP 6
|
111
|
34 ! ES format
|
|
35 s = x
|
|
36 write (s, '(ES10.3,A)') 16.235, "z"
|
131
|
37 if (s .ne. " 1.624E+01z") STOP 7
|
111
|
38 ! F format, small number
|
|
39 s = x
|
|
40 write (s, '(F10.8,A)') 1.0e-20, "z"
|
131
|
41 if (s .ne. "0.00000000z") STOP 8
|
111
|
42 ! E format, very large number.
|
|
43 ! Used to overflow with positive scale factor
|
|
44 s = x
|
|
45 write (s, '(1PE10.3,A)') huge(0d0), "z"
|
|
46 ! The actual value is target specific, so just do a basic check
|
|
47 if ((s(1:1) .eq. "*") .or. (s(7:7) .ne. "+") .or. &
|
131
|
48 (s(11:11) .ne. "z")) STOP 9
|
111
|
49 ! F format, round up with carry to most significant digit.
|
|
50 s = x
|
|
51 write (s, '(F10.3,A)') 0.9999, "z"
|
131
|
52 if (s .ne. " 1.000z") STOP 10
|
111
|
53 ! F format, round up with carry to most significant digit < 0.1.
|
|
54 s = x
|
|
55 write (s, '(F10.3,A)') 0.0099, "z"
|
131
|
56 if (s .ne. " 0.010z") STOP 11
|
111
|
57 ! E format, round up with carry to most significant digit.
|
|
58 s = x
|
|
59 write (s, '(E10.3,A)') 0.9999, "z"
|
131
|
60 if (s .ne. " 0.100E+01z") STOP 12
|
111
|
61 ! EN format, round up with carry to most significant digit.
|
|
62 s = x
|
|
63 write (s, '(EN15.3,A)') 999.9999, "z"
|
131
|
64 if (s .ne. " 1.000E+03z") STOP 13
|
111
|
65 ! E format, positive scale factor
|
|
66 s = x
|
|
67 write (s, '(2PE10.4,A)') 1.2345, "z"
|
131
|
68 if (s .ne. '12.345E-01z') STOP 14
|
111
|
69 ! E format, negative scale factor
|
|
70 s = x
|
|
71 write (s, '(-2PE10.4,A)') 1.250001, "z"
|
131
|
72 if (s .ne. '0.0013E+03z') STOP 15
|
111
|
73 ! E format, single digit precision
|
|
74 s = x
|
|
75 write (s, '(E10.1,A)') 1.1, "z"
|
131
|
76 if (s .ne. ' 0.1E+01z') STOP 16
|
111
|
77 end
|
|
78
|