Skip to content

Commit

Permalink
feat(Fortran): add first assumed-rank unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rouson committed Dec 8, 2023
1 parent 6dadc3d commit 6cddb98
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions Fortran/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
add_subdirectory(hello)
add_subdirectory(fcvs21_f95) # NIST Fortran Compiler Validation Suite
add_subdirectory(finalization)
add_subdirectory(assumed-rank)
3 changes: 3 additions & 0 deletions Fortran/UnitTests/assumed-rank/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
llvm_singlesource()

file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
69 changes: 69 additions & 0 deletions Fortran/UnitTests/assumed-rank/dummy-select-intrinsic.f90
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions Fortran/UnitTests/assumed-rank/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.traditional_output = True
config.single_source = True

0 comments on commit 6cddb98

Please sign in to comment.