From 6cddb98856f67ced507da64584882e4f86b58b09 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Fri, 8 Dec 2023 14:52:36 -0800 Subject: [PATCH 1/8] feat(Fortran): add first assumed-rank unit test --- Fortran/UnitTests/CMakeLists.txt | 1 + Fortran/UnitTests/assumed-rank/CMakeLists.txt | 3 + .../assumed-rank/dummy-select-intrinsic.f90 | 69 +++++++++++++++++++ .../dummy-select-intrinsic.reference_output | 17 +++++ Fortran/UnitTests/assumed-rank/lit.local.cfg | 2 + 5 files changed, 92 insertions(+) create mode 100644 Fortran/UnitTests/assumed-rank/CMakeLists.txt create mode 100644 Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 create mode 100644 Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output create mode 100644 Fortran/UnitTests/assumed-rank/lit.local.cfg diff --git a/Fortran/UnitTests/CMakeLists.txt b/Fortran/UnitTests/CMakeLists.txt index 84979dd70f..a8e17338a1 100644 --- a/Fortran/UnitTests/CMakeLists.txt +++ b/Fortran/UnitTests/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(hello) add_subdirectory(fcvs21_f95) # NIST Fortran Compiler Validation Suite add_subdirectory(finalization) +add_subdirectory(assumed-rank) diff --git a/Fortran/UnitTests/assumed-rank/CMakeLists.txt b/Fortran/UnitTests/assumed-rank/CMakeLists.txt new file mode 100644 index 0000000000..8b9f2da57c --- /dev/null +++ b/Fortran/UnitTests/assumed-rank/CMakeLists.txt @@ -0,0 +1,3 @@ +llvm_singlesource() + +file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 new file mode 100644 index 0000000000..dfc81ffcb4 --- /dev/null +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -0,0 +1,69 @@ +program rank_dummy_select_intrinsic + implicit none + integer a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + integer a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + integer a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + integer a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + +contains + + subroutine print_rank(a) + integer a(..) + character(len=*), parameter :: format_='(a,i2)' + + select rank(a) + rank(0) + print format_,"rank(a) = ",rank(a) + rank(1) + print format_,"rank(a) = ",rank(a) + rank(2) + print format_,"rank(a) = ",rank(a) + rank(3) + print format_,"rank(a) = ",rank(a) + rank(4) + print format_,"rank(a) = ",rank(a) + rank(5) + print format_,"rank(a) = ",rank(a) + rank(6) + print format_,"rank(a) = ",rank(a) + rank(7) + print format_,"rank(a) = ",rank(a) + rank(8) + print format_,"rank(a) = ",rank(a) + rank(9) + print format_,"rank(a) = ",rank(a) + rank(10) + print format_,"rank(a) = ",rank(a) + rank(11) + print format_,"rank(a) = ",rank(a) + rank(12) + print format_,"rank(a) = ",rank(a) + rank(13) + print format_,"rank(a) = ",rank(a) + rank(14) + print format_,"rank(a) = ",rank(a) + rank(15) + print format_,"rank(a) = ",rank(a) + rank default + error stop "unrecognized rank" + end select + end subroutine + +end program rank_dummy_select_intrinsic diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output new file mode 100644 index 0000000000..dc0acd6ab5 --- /dev/null +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output @@ -0,0 +1,17 @@ +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 +exit 0 diff --git a/Fortran/UnitTests/assumed-rank/lit.local.cfg b/Fortran/UnitTests/assumed-rank/lit.local.cfg new file mode 100644 index 0000000000..1166820260 --- /dev/null +++ b/Fortran/UnitTests/assumed-rank/lit.local.cfg @@ -0,0 +1,2 @@ +config.traditional_output = True +config.single_source = True From 05746d9f5bba7c88369b7b1d693c8907684af1e7 Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Wed, 27 Mar 2024 15:27:28 -0700 Subject: [PATCH 2/8] Add new subroutine `check-rank` to test to add another sanity check that the `select-rank-construct` and the `rank` intrinsic work correctly. --- .../assumed-rank/dummy-select-intrinsic.f90 | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index dfc81ffcb4..47ce7ec343 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -26,44 +26,53 @@ program rank_dummy_select_intrinsic subroutine print_rank(a) integer a(..) - character(len=*), parameter :: format_='(a,i2)' select rank(a) rank(0) - print format_,"rank(a) = ",rank(a) + call check_rank(0,rank(a)) rank(1) - print format_,"rank(a) = ",rank(a) + call check_rank(1,rank(a)) rank(2) - print format_,"rank(a) = ",rank(a) + call check_rank(2,rank(a)) rank(3) - print format_,"rank(a) = ",rank(a) + call check_rank(3,rank(a)) rank(4) - print format_,"rank(a) = ",rank(a) + call check_rank(4,rank(a)) rank(5) - print format_,"rank(a) = ",rank(a) + call check_rank(5,rank(a)) rank(6) - print format_,"rank(a) = ",rank(a) + call check_rank(6,rank(a)) rank(7) - print format_,"rank(a) = ",rank(a) + call check_rank(7,rank(a)) rank(8) - print format_,"rank(a) = ",rank(a) + call check_rank(8,rank(a)) rank(9) - print format_,"rank(a) = ",rank(a) + call check_rank(9,rank(a)) rank(10) - print format_,"rank(a) = ",rank(a) + call check_rank(10,rank(a)) rank(11) - print format_,"rank(a) = ",rank(a) + call check_rank(11,rank(a)) rank(12) - print format_,"rank(a) = ",rank(a) + call check_rank(12,rank(a)) rank(13) - print format_,"rank(a) = ",rank(a) + call check_rank(13,rank(a)) rank(14) - print format_,"rank(a) = ",rank(a) + call check_rank(14,rank(a)) rank(15) - print format_,"rank(a) = ",rank(a) + call check_rank(15,rank(a)) rank default error stop "unrecognized rank" end select end subroutine + subroutine check_rank(select_val, intrinsic_val) + integer, intent(in) :: select_val, intrinsic_val + + if (select_val.eq.intrinsic_val) then + print '(a,i2)', "rank(a) = ", intrinsic_val + else + print *, "select rank value ", select_val, "doesn't match rank reported from `rank` intrinsic ", intrinsic_val + end if + end subroutine + end program rank_dummy_select_intrinsic From db986f1800d99a72fe2403fa4884963fb7f2f98d Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Wed, 27 Mar 2024 15:37:30 -0700 Subject: [PATCH 3/8] Move subroutines into new module --- .../assumed-rank/dummy-select-intrinsic.f90 | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index 47ce7ec343..037eea846b 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -1,26 +1,7 @@ -program rank_dummy_select_intrinsic - implicit none - integer a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) - integer a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) - integer a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) - integer a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) +module check_rank_utilities - call print_rank(a) - call print_rank(a1) - call print_rank(a2) - call print_rank(a3) - call print_rank(a4) - call print_rank(a5) - call print_rank(a6) - call print_rank(a7) - call print_rank(a8) - call print_rank(a9) - call print_rank(a10) - call print_rank(a11) - call print_rank(a12) - call print_rank(a13) - call print_rank(a14) - call print_rank(a15) + private + public :: print_rank contains @@ -75,4 +56,31 @@ subroutine check_rank(select_val, intrinsic_val) end if end subroutine +end module + +program rank_dummy_select_intrinsic + use check_rank_utilities, only: print_rank + implicit none + integer a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + integer a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + integer a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + integer a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end program rank_dummy_select_intrinsic From 5c7afb2bce08bdfc2100067a225551b855a4995e Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Wed, 27 Mar 2024 15:41:01 -0700 Subject: [PATCH 4/8] Move calls to `print_rank` into new subroutine `check_integer` --- .../assumed-rank/dummy-select-intrinsic.f90 | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index 037eea846b..a084838527 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -61,26 +61,33 @@ subroutine check_rank(select_val, intrinsic_val) program rank_dummy_select_intrinsic use check_rank_utilities, only: print_rank implicit none - integer a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) - integer a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) - integer a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) - integer a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) - call print_rank(a) - call print_rank(a1) - call print_rank(a2) - call print_rank(a3) - call print_rank(a4) - call print_rank(a5) - call print_rank(a6) - call print_rank(a7) - call print_rank(a8) - call print_rank(a9) - call print_rank(a10) - call print_rank(a11) - call print_rank(a12) - call print_rank(a13) - call print_rank(a14) - call print_rank(a15) + call check_integer + +contains + + subroutine check_integer + integer a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + integer a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + integer a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + integer a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_integer end program rank_dummy_select_intrinsic From 54d9dfda57a4ae964cfefc77ac6cdfa73da2b2e1 Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Thu, 28 Mar 2024 17:16:56 -0700 Subject: [PATCH 5/8] Add another intrinsic type, real, to assumed-rank test --- .../assumed-rank/dummy-select-intrinsic.f90 | 27 ++++++++++++++++++- .../dummy-select-intrinsic.reference_output | 16 +++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index a084838527..04cb2824b9 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -6,7 +6,7 @@ module check_rank_utilities contains subroutine print_rank(a) - integer a(..) + class(*) a(..) select rank(a) rank(0) @@ -63,6 +63,7 @@ program rank_dummy_select_intrinsic implicit none call check_integer + call check_real contains @@ -90,4 +91,28 @@ subroutine check_integer call print_rank(a15) end subroutine check_integer + subroutine check_real + real a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + real a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + real a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + real a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_real + end program rank_dummy_select_intrinsic diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output index dc0acd6ab5..a21966e386 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output @@ -14,4 +14,20 @@ rank(a) = 12 rank(a) = 13 rank(a) = 14 rank(a) = 15 +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 exit 0 From f34f48a18a87b17d29ef07153fd4a296163cc70c Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Thu, 28 Mar 2024 17:32:17 -0700 Subject: [PATCH 6/8] Add remaining intrinsic types to assumed-rank test --- .../assumed-rank/dummy-select-intrinsic.f90 | 100 ++++++++++++++++++ .../dummy-select-intrinsic.reference_output | 64 +++++++++++ 2 files changed, 164 insertions(+) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index 04cb2824b9..25afb76800 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -64,6 +64,10 @@ program rank_dummy_select_intrinsic call check_integer call check_real + call check_double_precision + call check_complex + call check_character + call check_logical contains @@ -115,4 +119,100 @@ subroutine check_real call print_rank(a15) end subroutine check_real + subroutine check_double_precision + double precision a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + double precision a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + double precision a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + double precision a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_double_precision + + subroutine check_complex + complex a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + complex a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + complex a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + complex a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_complex + + subroutine check_character + character(len=1) a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + character(len=1) a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + character(len=1) a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + character(len=1) a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_character + + subroutine check_logical + logical a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + logical a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + logical a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + logical a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_logical + end program rank_dummy_select_intrinsic diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output index a21966e386..e368335ce9 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output @@ -30,4 +30,68 @@ rank(a) = 12 rank(a) = 13 rank(a) = 14 rank(a) = 15 +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 exit 0 From ea9338a46e469502e8e293044f2c0191956d317d Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Thu, 28 Mar 2024 17:38:35 -0700 Subject: [PATCH 7/8] Add a derived type to assumed-rank test --- .../assumed-rank/dummy-select-intrinsic.f90 | 31 ++++++++++++++++++- .../dummy-select-intrinsic.reference_output | 16 ++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index 25afb76800..0a38c12189 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -3,6 +3,10 @@ module check_rank_utilities private public :: print_rank + type, public :: derived_type + integer :: x,y + end type + contains subroutine print_rank(a) @@ -59,7 +63,7 @@ subroutine check_rank(select_val, intrinsic_val) end module program rank_dummy_select_intrinsic - use check_rank_utilities, only: print_rank + use check_rank_utilities, only: print_rank, derived_type implicit none call check_integer @@ -68,6 +72,7 @@ program rank_dummy_select_intrinsic call check_complex call check_character call check_logical + call check_derived_type contains @@ -215,4 +220,28 @@ subroutine check_logical call print_rank(a15) end subroutine check_logical + subroutine check_derived_type + type(derived_type) a, a1(1), a2(1,1), a3(1,1,1), a4(1,1,1, 1), a5(1,1,1, 1,1), a6(1,1,1, 1,1,1), a7(1,1,1, 1,1,1, 1) + type(derived_type) a8(1,1,1, 1,1,1, 1,1), a9(1,1,1, 1,1,1, 1,1,1), a10(1,1,1, 1,1,1, 1,1,1, 1), a11(1,1,1, 1,1,1, 1,1,1, 1,1) + type(derived_type) a12(1,1,1, 1,1,1, 1,1,1, 1,1,1), a13(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1), a14(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1) + type(derived_type) a15(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) + + call print_rank(a) + call print_rank(a1) + call print_rank(a2) + call print_rank(a3) + call print_rank(a4) + call print_rank(a5) + call print_rank(a6) + call print_rank(a7) + call print_rank(a8) + call print_rank(a9) + call print_rank(a10) + call print_rank(a11) + call print_rank(a12) + call print_rank(a13) + call print_rank(a14) + call print_rank(a15) + end subroutine check_derived_type + end program rank_dummy_select_intrinsic diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output index e368335ce9..443973a0a1 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output @@ -94,4 +94,20 @@ rank(a) = 12 rank(a) = 13 rank(a) = 14 rank(a) = 15 +rank(a) = 0 +rank(a) = 1 +rank(a) = 2 +rank(a) = 3 +rank(a) = 4 +rank(a) = 5 +rank(a) = 6 +rank(a) = 7 +rank(a) = 8 +rank(a) = 9 +rank(a) = 10 +rank(a) = 11 +rank(a) = 12 +rank(a) = 13 +rank(a) = 14 +rank(a) = 15 exit 0 From 145e6176c533980ce4c2cf1bba5d4ed7e9d290bf Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Thu, 28 Mar 2024 17:49:40 -0700 Subject: [PATCH 8/8] Add sanity check for an assumed rank arg that is also type(*) and has the contiguous and target attributes --- .../assumed-rank/dummy-select-intrinsic.f90 | 20 ++++++++++++++++--- .../dummy-select-intrinsic.reference_output | 3 +++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 index 0a38c12189..a1e699232f 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90 @@ -1,7 +1,7 @@ module check_rank_utilities private - public :: print_rank + public :: print_rank, check_contiguous_assumed_rank_arg type, public :: derived_type integer :: x,y @@ -9,6 +9,16 @@ module check_rank_utilities contains + subroutine check_contiguous_assumed_rank_arg(arg) + type(*), intent(in), contiguous, target :: arg(..) + + if (is_contiguous(arg)) then + print '(a)', "Assumed rank arg with contiguous and target attribute is contiguous" + else + print '(a)', "Assumed rank arg with contiguous and target attribute is NOT contiguous" + end if + end subroutine + subroutine print_rank(a) class(*) a(..) @@ -56,15 +66,16 @@ subroutine check_rank(select_val, intrinsic_val) if (select_val.eq.intrinsic_val) then print '(a,i2)', "rank(a) = ", intrinsic_val else - print *, "select rank value ", select_val, "doesn't match rank reported from `rank` intrinsic ", intrinsic_val + print '(a)', "select rank value ", select_val, "doesn't match rank reported from `rank` intrinsic ", intrinsic_val end if end subroutine end module program rank_dummy_select_intrinsic - use check_rank_utilities, only: print_rank, derived_type + use check_rank_utilities, only: print_rank, derived_type, check_contiguous_assumed_rank_arg implicit none + integer :: scalar = 1, rank1_arr(10) = 1, rank2_arr(6,6) = 1 call check_integer call check_real @@ -73,6 +84,9 @@ program rank_dummy_select_intrinsic call check_character call check_logical call check_derived_type + call check_contiguous_assumed_rank_arg(scalar); + call check_contiguous_assumed_rank_arg(rank1_arr(1:6:2)); + call check_contiguous_assumed_rank_arg(rank2_arr); contains diff --git a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output index 443973a0a1..690d713d92 100644 --- a/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output +++ b/Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.reference_output @@ -110,4 +110,7 @@ rank(a) = 12 rank(a) = 13 rank(a) = 14 rank(a) = 15 +Assumed rank arg with contiguous and target attribute is contiguous +Assumed rank arg with contiguous and target attribute is contiguous +Assumed rank arg with contiguous and target attribute is contiguous exit 0