Hi!
I am trying to use the function gsl_sort_vector(V) from the gsl library in
my fortran90 code. I use a linux based operating system with gfortran-4.9
as the fortran compiler. I have previously compiled a c-function with the
fortran90 as main program but now with gsl I couldn't do so.
Here goes the code
!-----------------------------------------------------------------------------------------------------------------!
program test_gsl
use, intrinsic :: ISO_C_BINDING
implicit none
integer, parameter :: dp = selected_real_kind(12)
integer :: j
integer, dimension(1:2) :: order1 = (/2,1/)
real(dp), dimension(1:9) :: A
real(dp), dimension(:,:), allocatable :: tidx, tsort
interface
! gsl C function void gsl_sort_vector(gsl vector * v) ascending order
function gsl_sort_vector(data) bind(C,name="gsl_sort_vector")
result(tsort)
use, intrinsic :: ISO_C_BINDING
implicit none
real(kind=C_DOUBLE), intent(IN) :: data(*)
real(kind=C_DOUBLE) :: tsort
end function gsl_sort_vector
end interface
allocate(tidx(1:3,1:3), tsort(1:3,1))
A = (/1,2,3,4,5,6,7,8,9/)
tidx = RESHAPE(A, (/3,3/), ORDER=order1 )
print *, (tidx(j,:),j=1,3)
tsort = gsl_sort_vector(tidx(:,1))
print *, tsort
! print *, (tsort(j,:),j=1,3)
end program test_gsl
!--------------------------------------------------------------------------------------------------------------------!
It would be really nice to get some suggestion on linking as well.
Best regards,
BRijesh