@@ -48,7 +48,8 @@ subroutine collect_np(testsuite)
48
48
new_unittest(" npz_load_arr_cmplx" , npz_load_arr_cmplx), &
49
49
new_unittest(" npz_load_two_arr_iint64_rdp" , npz_load_two_arr_iint64_rdp), &
50
50
new_unittest(" npz_load_two_arr_iint64_rdp_comp" , npz_load_two_arr_iint64_rdp_comp), &
51
- new_unittest(" npz_add_to_empty_arr" , npz_add_to_empty_arr), &
51
+ new_unittest(" npz_add_arr_to_empty" , npz_add_arr_to_empty), &
52
+ new_unittest(" npz_add_two_arrays" , npz_add_two_arrays), &
52
53
new_unittest(" npz_save_empty_array_input" , npz_save_empty_array_input, should_fail= .true. ) &
53
54
]
54
55
end subroutine collect_np
@@ -934,12 +935,11 @@ subroutine npz_load_two_arr_iint64_rdp_comp(error)
934
935
end select
935
936
end
936
937
937
- subroutine npz_add_to_empty_arr (error )
938
+ subroutine npz_add_arr_to_empty (error )
938
939
type (error_type), allocatable , intent (out ) :: error
939
940
940
941
type (t_array_wrapper), allocatable :: arrays(:)
941
942
integer :: stat
942
- character (* ), parameter :: filename = " npz_add_arr.npz"
943
943
real (dp), allocatable :: input_array(:,:)
944
944
945
945
allocate (input_array(10 , 4 ))
@@ -959,10 +959,44 @@ subroutine npz_add_to_empty_arr(error)
959
959
" Precision loss when adding array." )
960
960
if (allocated (error)) return
961
961
class default
962
- call test_failed(error, " Array in ' " // filename // " ' is of wrong type." )
962
+ call test_failed(error, " Array is of wrong type." )
963
963
end select
964
964
end
965
965
966
+ subroutine npz_add_two_arrays (error )
967
+ type (error_type), allocatable , intent (out ) :: error
968
+
969
+ type (t_array_wrapper), allocatable :: arrays(:)
970
+ integer :: stat
971
+ real (dp), allocatable :: array_1(:,:)
972
+ real (sp), allocatable :: array_2(:)
973
+
974
+ allocate (array_1(10 , 4 ))
975
+ call random_number (array_1)
976
+ call add_array(arrays, array_1, stat)
977
+ call check(error, stat, " Error adding an array to the list of arrays." )
978
+ if (allocated (error)) return
979
+ call check(error, size (arrays) == 1 , " Array was not added to the list of arrays." )
980
+ if (allocated (error)) return
981
+ call check(error, arrays(1 )% array% name == " arr_0.npy" , " Wrong array name." )
982
+ if (allocated (error)) return
983
+ select type (typed_array = > arrays(1 )% array)
984
+ class is (t_array_rdp_2)
985
+ call check(error, size (typed_array% values), size (array_1), " Array sizes to not match." )
986
+ if (allocated (error)) return
987
+ call check(error, any (abs (typed_array% values - array_1) <= epsilon (1.0_dp )), &
988
+ " Precision loss when adding array." )
989
+ if (allocated (error)) return
990
+ class default
991
+ call test_failed(error, " Array 1 is of wrong type." )
992
+ end select
993
+
994
+ allocate (array_2(10 ))
995
+ call random_number (array_2)
996
+ call add_array(arrays, array_2, stat)
997
+ call check(error, stat, " Error adding an array to the list of arrays." )
998
+ end
999
+
966
1000
! subroutine npz_add_arr(error)
967
1001
! type(error_type), allocatable, intent(out) :: error
968
1002
0 commit comments