Skip to content

Commit 450247e

Browse files
committed
sort_index: add fypp variable to reduce code size
1 parent c3128ac commit 450247e

File tree

2 files changed

+19
-442
lines changed

2 files changed

+19
-442
lines changed

src/stdlib_sorting.fypp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -435,40 +435,24 @@ module stdlib_sorting
435435
!! with a value of `.TRUE.` the indices correspond to a non-increasing sort.
436436

437437
#:for k1 in INT_KINDS
438+
#:for k1, t1 in IR_KINDS_TYPES
438439
module subroutine ${k1}$_sort_index( array, index, work, iwork, &
439440
reverse )
440441
!! Version: experimental
441442
!!
442-
!! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `INTEGER(${k1}$)`
443+
!! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `${t1}$`
443444
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
444445
!! and returns the sorted `ARRAY` and an array `INDEX of indices in the
445446
!! order that would sort the input `ARRAY` in the desired direction.
446-
integer(${k1}$), intent(inout) :: array(0:)
447+
${t1}$, intent(inout) :: array(0:)
447448
integer(int_size), intent(inout) :: index(0:)
448-
integer(${k1}$), intent(inout), optional :: work(0:)
449+
${t1}$, intent(inout), optional :: work(0:)
449450
integer(int_size), intent(inout), optional :: iwork(0:)
450451
logical, intent(in), optional :: reverse
451452
end subroutine ${k1}$_sort_index
452453

453454
#:endfor
454455

455-
#:for k1 in REAL_KINDS
456-
module subroutine ${k1}$_sort_index( array, index, work, iwork, &
457-
reverse )
458-
!! Version: experimental
459-
!!
460-
!! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `REAL(${k1}$)`
461-
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
462-
!! and returns the sorted `ARRAY` and an array `INDEX of indices in the
463-
!! order that would sort the input `ARRAY` in the desired direction.
464-
real(${k1}$), intent(inout) :: array(0:)
465-
integer(int_size), intent(inout) :: index(0:)
466-
real(${k1}$), intent(inout), optional :: work(0:)
467-
integer(int_size), intent(inout), optional :: iwork(0:)
468-
logical, intent(in), optional :: reverse
469-
end subroutine ${k1}$_sort_index
470-
471-
#:endfor
472456
module subroutine char_sort_index( array, index, work, iwork, &
473457
reverse )
474458
!! Version: experimental

0 commit comments

Comments
 (0)