R
rudra
dear friends,
i am new to C/C++ and i need to call ranlux routine from my fortran
code...here is a toy fortran code, which is calling the C++ program
that uses ranlux(its actually C code given in gsl manual, i transferd
it to C++ headers. hope this is fine)
i have read the available sources, but with little luck.
can anybody show me how to call it from the fortran code?
#include <iostream>
#include <gsl/gsl_rng.h>
using namespace std;
extern "C" /* this line should be omitted in C */
{
float hello_()
{
const gsl_rng_type * T;
gsl_rng * r;
int i, n = 10;
gsl_rng_env_setup();
T = gsl_rng_default;
r = gsl_rng_alloc (T);
for (i = 0; i < n; i++)
{
double u = gsl_rng_uniform (r);
printf ("%.5f\n", u);
}
gsl_rng_free (r);
return 0;
}
}
extern "C" int mymain_();
int main()
{
return mymain_();
}
and corresponding fortran code looks like:
SUBROUTINE MYMAIN
CHARACTER*11 NAME
INTEG=42
NAME='HELLO WORLD'
CALL hello()
RETURN
END
can anybody plz let me know fault?
i am new to C/C++ and i need to call ranlux routine from my fortran
code...here is a toy fortran code, which is calling the C++ program
that uses ranlux(its actually C code given in gsl manual, i transferd
it to C++ headers. hope this is fine)
i have read the available sources, but with little luck.
can anybody show me how to call it from the fortran code?
#include <iostream>
#include <gsl/gsl_rng.h>
using namespace std;
extern "C" /* this line should be omitted in C */
{
float hello_()
{
const gsl_rng_type * T;
gsl_rng * r;
int i, n = 10;
gsl_rng_env_setup();
T = gsl_rng_default;
r = gsl_rng_alloc (T);
for (i = 0; i < n; i++)
{
double u = gsl_rng_uniform (r);
printf ("%.5f\n", u);
}
gsl_rng_free (r);
return 0;
}
}
extern "C" int mymain_();
int main()
{
return mymain_();
}
and corresponding fortran code looks like:
SUBROUTINE MYMAIN
CHARACTER*11 NAME
INTEG=42
NAME='HELLO WORLD'
CALL hello()
RETURN
END
can anybody plz let me know fault?