2011-05-23 Tom de Vries <tom@codesourcery.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / namelist_42.f90
blobf15914ff1175cc4c913f96e6b5acb84705a8e21d
1 ! { dg-do run { target fd_truncate } }
2 ! { dg-add-options ieee }
3 ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
5 ! PR fortran/34427
7 ! Check that namelists and the real values Inf, NaN, Infinity
8 ! properly coexist.
10 PROGRAM TEST
11 IMPLICIT NONE
12 real , DIMENSION(11) ::foo
13 integer :: infinity
14 NAMELIST /nl/ foo
15 NAMELIST /nl/ infinity
16 foo = -1.0
17 infinity = -1
19 open (10, status="scratch")
20 ! Works:
21 write (10,*) " &nl foo = 5, 5, 5, nan, infinity, infinity "
22 write (10,*)
23 write (10,*) " = 1, /"
24 rewind (10)
25 READ (10, NML = nl)
26 close (10)
28 if(infinity /= 1) call abort()
29 if(any(foo(1:3) /= [5.0, 5.0, 5.0]) .or. .not.isnan(foo(4)) &
30 .or. foo(5) <= huge(foo) .or. any(foo(6:11) /= -1.0)) &
31 call abort()
32 ! Works too:
33 foo = -1.0
34 infinity = -1
36 open (10, status="scratch")
37 rewind (10)
38 write (10,'(a)') "&nl foo = 5, 5, 5, nan, infinity, infinity"
39 write (10,'(a)') "=1,/"
40 rewind (10)
41 READ (10, NML = nl)
42 CLOSE (10)
44 if(infinity /= 1) call abort()
45 if(any(foo(1:3) /= [5.0, 5.0, 5.0]) .or. .not.isnan(foo(4)) &
46 .or. foo(5) <= huge(foo) .or. any(foo(6:11) /= -1.0)) &
47 call abort()
48 END PROGRAM TEST