File: coshape.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (86 lines) | stat: -rw-r--r-- 2,886 bytes parent folder | download | duplicates (11)
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
78
79
80
81
82
83
84
85
86
! RUN: %python %S/test_errors.py %s %flang_fc1
! XFAIL: *
! Check for semantic errors in coshape() function,
! as defined in section 16.9.55 of the Fortran
! 2018 standard

program coshape_tests
  use iso_c_binding, only : c_int32_t, c_int64_t
  implicit none

  integer array(1), non_coarray(1), scalar_coarray[*], array_coarray(1)[*], non_constant, scalar_result
  real real_coarray[*]
  complex complex_coarray[*]
  character char_array(1)
  logical non_integer, logical_coarray[*]
  integer, allocatable :: codimensions(:)

  !___ standard-conforming statement with no optional arguments present ___
  codimensions = coshape(scalar_coarray)
  codimensions = coshape(array_coarray)
  codimensions = coshape(array_coarray(1))
  codimensions = coshape(scalar_coarray[1])
  codimensions = coshape(real_coarray)
  codimensions = coshape(logical_coarray)
  codimensions = coshape(complex_coarray)
  codimensions = coshape(coarray=scalar_coarray)

  !___ standard-conforming statements with optional kind argument present ___
  codimensions = coshape(scalar_coarray, c_int32_t)
  codimensions = coshape(real_coarray, kind=c_int32_t)
  codimensions = coshape(coarray=logical_coarray, kind=c_int32_t)
  codimensions = coshape(kind=c_int32_t, coarray=complex_coarray)

  !___ non-conforming statements ___
  ! coarray argument must be a coarray
  codimensions = coshape(non_coarray)

  ! kind argument must be an integer
  codimensions = coshape(scalar_coarray, non_integer)

  ! kind argument must be a constant expression
  codimensions = coshape(real_coarray, non_constant)

  ! kind argument must be an integer scalar
  codimensions = coshape(complex_coarray, array)

  ! missing all arguments
  codimensions = coshape()

  ! missing mandatory argument
  codimensions = coshape(kind=c_int32_t)

  ! incorrect typing for mandatory argument
  codimensions = coshape(3.4)

  ! incorrect typing for coarray argument
  codimensions = coshape(coarray=3.4)

  ! too many arguments
  codimensions = coshape(scalar_coarray, c_int32_t, 0)

  ! incorrect typing with correct keyword for coarray argument
  codimensions = coshape(coarray=non_coarray)

  ! correct typing with incorrect keyword for coarray argument
  codimensions = coshape(c=real_coarray)

  ! incorrect typing with correct keyword for kind argument
  codimensions = coshape(complex_coarray, kind=non_integer)

  ! correct typing with incorrect keyword for kind argument
  codimensions = coshape(logical_coarray, kinds=c_int32_t)

  ! repeated keyword for coarray argument
  codimensions = coshape(coarray=scalar_coarray, coarray=real_coarray)

  ! repeated keyword for kind argument
  codimensions = coshape(real_coarray, kind=c_int32_t, kind=c_int64_t)

  ! result must be a rank 1 array
  scalar_result = coshape(scalar_coarray)

  ! result must be an integer array
  char_array = coshape(real_coarray)

end program coshape_tests