@@ -13,7 +13,6 @@ module test_sparse_spmv
1313
1414contains
1515
16-
1716 !> Collect all exported unit tests
1817 subroutine collect_suite(testsuite)
1918 !> Collection of tests
@@ -30,7 +29,8 @@ contains
3029 new_unittest('diagonal', test_diagonal), &
3130 new_unittest('add_get_values', test_add_get_values), &
3231 new_unittest('sparse_operators', test_sparse_operators), &
33- new_unittest('add_block_symmetric_skip', test_add_block_symmetric_skip) &
32+ new_unittest('add_block_symmetric_skip', test_add_block_symmetric_skip), &
33+ new_unittest('csc2dense', test_csc2dense) &
3434 ]
3535 end subroutine
3636
@@ -579,10 +579,40 @@ contains
579579 #:endfor
580580
581581 end subroutine
582+
583+ subroutine test_csc2dense(error)
584+ !> Error handling
585+ type(error_type), allocatable, intent(out) :: error
586+ #:for k1, t1, s1 in (KINDS_TYPES)
587+ block
588+ integer, parameter :: wp = ${k1}$
589+ type(COO_${s1}$_type) :: COO
590+ type(CSC_${s1}$_type) :: CSC
591+ ${t1}$, allocatable :: dense_original(:,:), dense_converted(:,:)
592+
593+ ! 1. Create a baseline dense 4x4 matrix
594+ allocate( dense_original(4,4) , source = &
595+ reshape(real([1,0,0,5, &
596+ 0,2,0,0, &
597+ 0,6,3,0, &
598+ 0,0,7,4],kind=wp),[4,4]) )
599+
600+ ! 2. Convert Dense -> COO -> CSC (Standard pipeline)
601+ call dense2coo( dense_original , COO )
602+ call coo2csc( COO, CSC )
603+
604+ ! 3. Execute the csc2dense conversion
605+ call csc2dense( CSC, dense_converted )
606+
607+ ! 4. Verify the converted matrix perfectly matches the original
608+ call check(error, all(dense_original == dense_converted), "Error: csc2dense conversion failed for kind ${s1}$")
609+ if (allocated(error)) return
610+ end block
611+ #:endfor
612+ end subroutine
582613
583614end module
584615
585-
586616program tester
587617 use, intrinsic :: iso_fortran_env, only : error_unit
588618 use testdrive, only : run_testsuite, new_testsuite, testsuite_type
@@ -607,4 +637,4 @@ program tester
607637 write(error_unit, '(i0, 1x, a)') stat, "test(s) failed!"
608638 error stop
609639 end if
610- end program
640+ end program
0 commit comments