First, create a C file, say crexp.c:
#include <mpfr.h>
double exp_(double *x) {
double y ;
mpfr_t z ;
mpfr_init2 (z, 53);
mpfr_set_d(z, *x, GMP_RNDN) ;
mpfr_exp(z, z, GMP_RNDN) ;
y = mpfr_get_d(z, GMP_RNDN) ;
mpfr_clear(z) ;
return(y) ;
}
Then, create a Fortran program, say toto.f90:
program toto real(kind=8) :: x, y real(kind=8),external :: exp x = 1.D0 y = exp(x) print*,'y=',y end program totoFinally, compile with:
gfortran -c toto.f90 -o toto.o gcc -c crexp.c -o crexp.o gfortran -o a.out toto.o crexp.o -lmpfr ./a.out