aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/inquire_recl_f2018.f90
blob: dfb4092a45f8d91f045dc67182d74761c555653c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
! { dg-do run }
! PR 53796 INQUIRE(RECL=...)
program inqrecl
  implicit none
  integer(8) :: r
  integer :: r4
  ! F2018 (N2137) 12.10.2.26: recl for unconnected should be -1
  inquire(10, recl=r)
  if (r /= -1) then
     STOP 1
  end if
  
  ! Formatted sequential
  open(10, status="scratch")
  inquire(10, recl=r)
  inquire(10, recl=r4)
  close(10)
  if (r /= huge(0_8) - huge(0_4) - 1) then
     STOP 2
  end if
  if (r4 /= huge(0)) then
     STOP 3
  end if

  ! Formatted sequential with recl= specifier
  open(10, status="scratch", recl=100)
  inquire(10, recl=r)
  close(10)
  if (r /= 100) then
     STOP 4
  end if

  ! Formatted stream
  ! F2018 (N2137) 12.10.2.26: If unit is connected
  ! for stream access, recl should be assigned the value -2.
  open(10, status="scratch", access="stream")
  inquire(10, recl=r)
  close(10)
  if (r /= -2) then
     STOP 5
  end if

  ! Also inquire by filename for a non-opened unit is considered
  ! unconnected similar to the first test.
  inquire(file='unconnectedfile.txt', recl=r)
  if (r /= -1) then
     stop 6
  end if
end program inqrecl