1program strarray_3
2  character(len=5), dimension(2) :: c
3
4  c(1) = "Hello"
5  c(2) = "World"
6
7  call foo1(c)
8  call foo2(c, 2)
9  call foo3(c, 5)
10  call foo4(c, 5, 2)
11  call foo5(c(2:1:-1))
12contains
13subroutine foo1(a)
14  implicit none
15  character(len=5), dimension(2)  :: a
16
17  if ((a(1) .ne. "Hello") .or. (a(2) .ne. "World")) call abort
18end subroutine
19
20subroutine foo2(a, m)
21  implicit none
22  integer  m
23  character(len=5), dimension(m)  :: a
24
25  if ((a(1) .ne. "Hello") .or. (a(2) .ne. "World")) call abort
26end subroutine
27
28subroutine foo3(a, n)
29  implicit none
30  integer n
31  character(len=n), dimension(:)  :: a
32
33  if ((a(1) .ne. "Hello") .or. (a(2) .ne. "World")) call abort
34end subroutine
35
36subroutine foo4(a, n, m)
37  implicit none
38  integer n, m
39  character(len=n), dimension(m)  :: a
40
41  if ((a(1) .ne. "Hello") .or. (a(2) .ne. "World")) call abort
42end subroutine
43
44subroutine foo5(a)
45  implicit none
46  character(len=2), dimension(5)  :: a
47
48  if ((a(1) .ne. "Wo") .or. (a(3) .ne. "dH") .or. (a(5) .ne. "lo")) call abort
49end subroutine
50end program
51