| 1 |
! { dg-do run } |
| 2 |
! Test reading/writing of integer, real and character BOZ |
| 3 |
! non-integer BOZ are not valid in standard Fortran, however. |
| 4 |
! PR fortran/29625 |
| 5 |
program real_boz |
| 6 |
implicit none |
| 7 |
integer(4) :: i,i2 |
| 8 |
real(4) :: r,r2 |
| 9 |
complex(4) :: z,z2 |
| 10 |
character :: c,c2 |
| 11 |
character(len=100) :: str,fmt |
| 12 |
|
| 13 |
i = 43 |
| 14 |
r = 325.56 |
| 15 |
z = cmplx(14.456, 345342.456) |
| 16 |
c ='g' |
| 17 |
|
| 18 |
write(str,'(b0)') i |
| 19 |
write(fmt,'(a,i0,a)') '(b',len_trim(str),')' |
| 20 |
read(str,fmt) i2 |
| 21 |
if(i /= i2) STOP 1 |
| 22 |
|
| 23 |
write(str,'(o0)') i |
| 24 |
write(fmt,'(a,i0,a)') '(o',len_trim(str),')' |
| 25 |
read(str,fmt) i2 |
| 26 |
if(i /= i2) STOP 2 |
| 27 |
|
| 28 |
write(str,'(z0)') i |
| 29 |
write(fmt,'(a,i0,a)') '(z',len_trim(str),')' |
| 30 |
read(str,fmt) i2 |
| 31 |
if(i /= i2) STOP 3 |
| 32 |
|
| 33 |
|
| 34 |
write(str,'(b0)') r |
| 35 |
write(fmt,'(a,i0,a)') '(b',len_trim(str),')' |
| 36 |
read(str,fmt) r2 |
| 37 |
if(r /= r2) STOP 4 |
| 38 |
|
| 39 |
write(str,'(o0)') r |
| 40 |
write(fmt,'(a,i0,a)') '(o',len_trim(str),')' |
| 41 |
read(str,fmt) r2 |
| 42 |
if(r /= r2) STOP 5 |
| 43 |
|
| 44 |
write(str,'(z0)') r |
| 45 |
write(fmt,'(a,i0,a)') '(z',len_trim(str),')' |
| 46 |
read(str,fmt) r2 |
| 47 |
if(r /= r2) STOP 6 |
| 48 |
|
| 49 |
|
| 50 |
write(str,'(b0)') c |
| 51 |
write(fmt,'(a,i0,a)') '(b',len_trim(str),')' |
| 52 |
read(str,fmt) c2 |
| 53 |
if(c /= c2) STOP 7 |
| 54 |
|
| 55 |
write(str,'(o0)') c |
| 56 |
write(fmt,'(a,i0,a)') '(o',len_trim(str),')' |
| 57 |
read(str,fmt) c2 |
| 58 |
if(c /= c2) STOP 8 |
| 59 |
|
| 60 |
write(str,'(z0)') c |
| 61 |
write(fmt,'(a,i0,a)') '(z',len_trim(str),')' |
| 62 |
read(str,fmt) c2 |
| 63 |
if(c /= c2) STOP 9 |
| 64 |
|
| 65 |
end program real_boz |
| 66 |
|