File: select_char_1.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 (77 lines) | stat: -rw-r--r-- 2,104 bytes parent folder | download | duplicates (3)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
! { dg-do run }
integer function char_select (s)
  character(len=*), intent(in) :: s

  select case(s)
    case ("foo")
      char_select = 1
    case ("bar", "gee")
      char_select = 2
    case ("111", "999")
      char_select = 3
    case ("1024", "1900")
      char_select = 4
    case ("12", "17890")
      char_select = 5
    case default
      char_select = -1
  end select
end function char_select

integer function char_select2 (s)
  character(len=*), intent(in) :: s

  char_select2 = -1
  select case(s)
    case ("foo")
      char_select2 = 1
    case ("bar", "gee")
      char_select2 = 2
    case ("111", "999")
      char_select2 = 3
    case ("1024", "1900")
      char_select2 = 4
    case ("12", "17890")
      char_select2 = 5
  end select
end function char_select2


program test
  interface
    integer function char_select (s)
      character(len=*), intent(in) :: s
    end function char_select
    integer function char_select2 (s)
      character(len=*), intent(in) :: s
    end function char_select2
  end interface

  if (char_select("foo") /= 1) STOP 1
  if (char_select("foo ") /= 1) STOP 2
  if (char_select("foo2 ") /= -1) STOP 3
  if (char_select("bar") /= 2) STOP 4
  if (char_select("gee") /= 2) STOP 5
  if (char_select("000") /= -1) STOP 6
  if (char_select("101") /= -1) STOP 7
  if (char_select("109") /= -1) STOP 8
  if (char_select("111") /= 3) STOP 9
  if (char_select("254") /= -1) STOP 10
  if (char_select("999") /= 3) STOP 11
  if (char_select("9989") /= -1) STOP 12
  if (char_select("1882") /= -1) STOP 13

  if (char_select2("foo") /= 1) STOP 14
  if (char_select2("foo ") /= 1) STOP 15
  if (char_select2("foo2 ") /= -1) STOP 16
  if (char_select2("bar") /= 2) STOP 17
  if (char_select2("gee") /= 2) STOP 18
  if (char_select2("000") /= -1) STOP 19
  if (char_select2("101") /= -1) STOP 20
  if (char_select2("109") /= -1) STOP 21
  if (char_select2("111") /= 3) STOP 22
  if (char_select2("254") /= -1) STOP 23
  if (char_select2("999") /= 3) STOP 24
  if (char_select2("9989") /= -1) STOP 25
  if (char_select2("1882") /= -1) STOP 26
end program test