1program strarray_4
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, 2)
10contains
11subroutine foo1(a)
12  implicit none
13  character(len=5), dimension(2)  :: a
14  character(len=5), dimension(2)  :: b
15
16  b = a;
17  if ((b(1) .ne. "Hello") .or. (b(2) .ne. "World")) STOP 1
18end subroutine
19
20subroutine foo2(a, m)
21  implicit none
22  integer  m
23  character(len=5), dimension(m)  :: a
24  character(len=5), dimension(m)  :: b
25
26  b = a
27  if ((b(1) .ne. "Hello") .or. (b(2) .ne. "World")) STOP 2
28end subroutine
29
30subroutine foo3(a, n, m)
31  implicit none
32  integer n, m
33  character(len=n), dimension(m)  :: a
34  character(len=n), dimension(m)  :: b
35
36  b = a
37  if ((b(1) .ne. "Hello") .or. (b(2) .ne. "World")) STOP 3
38end subroutine
39end program
40