[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Access GSL library routines using fortran

From: Larry Hotchkiss
Subject: [Help-gsl] Access GSL library routines using fortran
Date: Mon, 1 Mar 2010 01:26:09 -0500 (EST)


I have been trying to execute GSL routines using fortran but can't identify the 
library to the fortran compiler. Some details:

    Windows XP
    Cygwin 1.7
    GSL just installed
    gcc and g95 compilers

I found one web site that showed how to create a "wrapper" C function to be 
called by fortran --

Here is the code and compile/link sequence proposed in an example there:

#include <gsl/gsl_sf_bessel.h>

void wrapper_j0_(double* y, double* x){
   *y = gsl_sf_bessel_J0(*x);

Then the fortran code

program test_gsl
      double precision x, y
      x = 1d0
      call wrapper_j0(y,x)
      print*, y
end program test_gsl

And the how to compile and link

$ g95 -fno-second-underscore -c test_gsl.f90
$ gcc -c c2f_gsl_sf_bessel_J0.c
$ g95 -fno-second-undercore test_gsl.o c2f_gsl_sf_bessel_J0.o -lgsl -lgslcblas 
-L<location of your gsl library>

I have not been able to determine the "location of your gsl library." I 
expected it to be in /cygdrive/c/cygwin/usr/lib, but that directory was empty 
until I copied some stuff from the download into it, e.g., libgsl.a, 
libgsl.dll.a (which didn't help :-) ).

Not surprisingly, I get error messages that the GSL routines are "undefined 

I've seen various web references to the need to compile the GSL library. But I 
thought I downloaded a binary distribution. And I have been able to execute 
four examples of gsl routines using C. Seems like it should not be difficult to 
locate the gsl library. The include files are easy to spot. So is the 
documentation, but the library. ???  I finally found the README file buried 
several directories deep in the download, zipped and tarred. It refers to an 
INSTALL file which I haven't been able to locate.

Thanks a bunch,

Larry Hotchkiss

reply via email to

[Prev in Thread] Current Thread [Next in Thread]