File: ISO_Fortran_binding_4.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (55 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
! { dg-do  run }
! PR fortran/89384 - this used to give a wrong results
! with contiguous.
! The subroutine substr is a test to check a problem found while
! debugging PR90355.
!
! Test case by Reinhold Bader.
!
module mod_ctg
  implicit none

contains

  subroutine ctg(x) BIND(C)
    real, contiguous :: x(:)
    if (any(abs(x - [2.,4.,6.]) > 1.e-6)) stop 1
    x = [2.,4.,6.]*10.0
  end subroutine

  subroutine substr(str) BIND(C)
    character(*) :: str(:)
    if (str(1) .ne. "bcd") stop 2
    if (str(2) .ne. "ghi") stop 3
    str = ['uvw','xyz']
  end subroutine

  subroutine substr4(str4) BIND(C)
    character(*, kind=4) :: str4(:)
    print *, str4(1)
    print *, str4(2)
    if (str4(1) .ne. 4_"bcd") stop 4
    if (str4(2) .ne. 4_"ghi") stop 5
    str4 = [4_'uvw', 4_'xyz']
  end subroutine

end module

program p
  use mod_ctg
  implicit none
  real :: x(6)
  character(5)         :: str(2)  = ['abcde', 'fghij']
  character(5, kind=4) :: str4(2) = [4_'abcde', 4_'fghij']
  integer :: i

  x = [ (real(i), i=1, size(x)) ]
  call ctg(x(2::2))
  if (any (abs (x - [1.,20.,3.,40.,5.,60.]) > 1.e-6)) stop 3

  !call substr(str(:)(2:4))
  !if (any (str .ne. ['auvwe','fxyzj'])) stop 4

  call substr4(str4(:)(2:4))
  if (any (str4 .ne. [4_'auvwe', 4_'fxyzj'])) stop 4
end program