3 character(len=:), allocatable :: strA(:), strA2
4 character(len=:), pointer :: strP(:), strP2
5 !$omp declare target enter(strA,strA2,strP,strP2)
7 subroutine opt_map(str1, str2, str3)
8 character(len=:), allocatable :: str1, str2, str3, str4
11 if (.not.present(str2)) error stop
12 if (present(str3)) error stop
14 !$omp target map(str1,str2,str3,str4)
15 if (allocated(str1)) error stop
16 if (allocated(str2)) error stop
17 if (present(str3)) error stop
18 if (allocated(str4)) error stop
22 character(len=:), allocatable :: str1, str2
23 call opt_map(str1, str2)
27 if (.not. allocated(strA)) error stop
28 !if (.not. allocated(strA2)) error stop
29 if (.not. associated(strP)) error stop
30 !if (.not. associated(strP2)) error stop
32 ! ensure length was updated as well
33 if (len(strA) /= 3) error stop
34 if (len(strA2) /= 5) error stop
35 if (len(strP) /= 4) error stop
36 if (len(strP2) /= 8) error stop
37 ! if (any (strA /= ['Hav', 'e f', 'un!'])) error stop
38 ! if (strA2 /= 'Hello') error stop
39 ! if (any (strP /= ['abcd', 'efgh', 'ijkl'])) error stop
40 ! if (strP2 /= 'TestCase') error stop
42 ! strA = ['123', '456', '789']
44 ! strP = ['ABCD', 'EFGH', 'IJKL']
54 strA = ['Hav', 'e f', 'un!']
56 allocate(character(len=4) :: strP(3))
57 strP = ['abcd', 'efgh', 'ijkl']
58 allocate(character(len=8) :: strP2)
61 !$omp target enter data map(always, to: strA, strA2)
62 !$omp target enter data map(to: strP, strP2)
66 !$omp target exit data map(always, from: strA, strA2, strP, strP2)
68 if (len(strA) /= 3) error stop
69 if (len(strA2) /= 5) error stop
70 if (len(strP) /= 4) error stop
71 if (len(strP2) /= 8) error stop
72 ! if (any (strA /= ['123', '456', '789'])) error stop
73 ! if (strA2 /= 'World') error stop
74 ! if (any(strP /= ['ABCD', 'EFGH', 'IJKL'])) error stop
75 ! if (strP2 /= 'Passed!!') error stop
77 ! deallocate(strP, strP2, strA, strA2)