LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-25-2008, 08:23 AM   #1
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Rep: Reputation: 23
calling ranlux from fortran


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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
g77 in gcc 4.1.0 not found only gfortran fortran 95 compiler! I need fortran 77. TheBrick Linux - Software 3 07-04-2007 06:39 AM
where is fortran.h? songqsh Programming 8 04-19-2006 05:42 PM
Gnu Fortran versus Intel Fortran tomatoefish Linux - Software 3 02-20-2006 01:31 PM
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM
odd recursion: calling "by hand" vs calling by cronscript... prx Programming 4 02-12-2005 04:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration