fortran-lang / stdlib

Fortran Standard Library
https://stdlib.fortran-lang.org
MIT License
1.08k stars 166 forks source link

No specific subroutine for the generic 'sort_index' #719

Closed Xeno-Hypster closed 1 year ago

Xeno-Hypster commented 1 year ago

Description

I have been returning this error when trying to call the sort_index subroutine. I have no issues calling sort or ord_sort using the below steps

Steps to reproduce:

program test_sort
use stdlib_sorting
implicit none
integer, dimension(3) :: idx
integer :: i
double precision, dimension(3) :: A
A(1) = 3.0d0
A(2) = 2.0d0
A(3) = 1.5d0
call sort_index(A, idx) ! does not work
! call sort(A) ! works
do i = 1,3
print *, A(i), idx(i)
end do
end program test_sort

compiled with gfortran -o test_sort test_sort.f90 $(STDLIB64)/libfortran_stdlib.a -I$(STDLIBINC) returns


test_sort.f90:11:25
   11 |    call sort_index(A, idx)
      |                          1
Error: There is no specific subroutine for the generic 'sort index' at (1) 

### Expected Behaviour

I would expect this at stdout:

1.50000000 3
2.00000000 2
3.00000000 1

### Version of stdlib

Master branch, commit: 7143c086a4bac2b0f23660c4a7092d9561b3399a

### Platform and Architecture

GNU/Linux, 64 bit

### Additional Information

_No response_
jvdp1 commented 1 year ago

I believe idx should be declared as integer(int64)

Le sam. 10 juin 2023 à 08:24, Xeno-Hypster @.***> a écrit :

Description

I have been returning this error when trying to call the sort_index subroutine. I have no issues calling sort or ord_sort using the below steps

Steps to reproduce:

program test_sort use stdlib_sorting implicit none integer, dimension(3) :: idx integer :: i double precision, dimension(3) :: A A(1) = 3.0d0 A(2) = 2.0d0 A(3) = 1.5d0 call sort_index(A, idx) ! does not work ! call sort(A) ! works do i = 1,3 print *, A(i), idx(i) end do end program test_sort

compiled with gfortran -o test_sort test_sort.f90 $(STDLIB64)/libfortran_stdlib.a -I$(STDLIBINC) returns

test_sort.f90:11:25 11 | call sort_index(A, idx) | 1 Error: There is no specific subroutine for the generic 'sort index' at (1)

Expected Behaviour

I would expect this at stdout:

1.50000000 3 2.00000000 2 3.00000000 1

Version of stdlib

Master branch, commit: 7143c086a4bac2b0f23660c4a7092d9561b3399a

Platform and Architecture

GNU/Linux, 64 bit

Additional Information

No response

— Reply to this email directly, view it on GitHub https://github.com/fortran-lang/stdlib/issues/719, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD5RO7FHOOHBJSFHSY5JQIDXKQHKFANCNFSM6AAAAAAZBPQDGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Xeno-Hypster commented 1 year ago

Ah, that works. Turns out too that I should have declared it as integer(int_size). That was a rookie mistake on my end. Thanks, closing!