Hi
I just discovered the GNU scientific library, which has a lot of pre written code that one can use.
I tried out an example program, just to see and learn how to properly call the gsl functions using the ISO_C_BINDING, but I got errors when trying to compile
PROGRAM c_binding_test
USE ISO_C_BINDING
IMPLICIT NONE
INTERFACE GSL_CumulativeChiSq_Prob_Upper
FUNCTION gsl_cdf_chisq_Q (x, nu) BIND (C, name="gsl_cdf_chisq_Q")
IMPORT
REAL (KIND=c_double) :: gsl_cdf_chisq_Q
REAL (KIND=c_double), VALUE, INTENT(IN) :: x
REAL (KIND=c_double), VALUE,INTENT(IN) :: nu
END FUNCTION gsl_cdf_chisq_Q
END INTERFACE GSL_CumulativeChiSq_Prob_Upper
REAL (KIND=c_double) :: chisq_value
REAL (KIND=c_double) :: DoF
REAL (KIND=c_double) :: Upper_Tail_Prob
PRINT *, "Calculates cumulative upper-tail probability for Chi-Square dis"
PRINT *, "Input Chisq value, Degrees of Freedom"
READ *, chisq_value,DoF
Upper_Tail_Prob = gsl_cdf_chisq_Q (chisq_value,DoF)
PRINT *, "Probability is: ",Upper_Tail_Prob
END PROGRAM c_binding_test
Command used to compile:
gfortran -O3 c_binding_test.f90 -o c_binding_test
I get this error:
/usr/bin/ld: /tmp/ccnF6X0E.o: in function `MAIN__':
c_binding_test.f90:(.text+0xf1): undefined reference to `gsl_cdf_chisq_Q'
collect2: error: ld returned 1 exit status
How can I correct this error ?
I got the code from here :