LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-23-2008, 12:52 AM   #1
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 264

Rep: Reputation: 23
calling C from fortran


dear friend, i have a C++ routine(badly written):

Code:
main()
{
  ofstream myfile;
/********* PART 1: Checking machine bit *********/

FILE *stream;
char sys[6],*sysptr;
int bit;
sysptr = &sys[0];
sys[6] = 0x0;
stream=popen("/bin/uname -m","r");
fread(sysptr,1,6,stream);
pclose(stream);
//printf("%s\n",sysptr);

if ((strncmp(sysptr, "i686",4)==0)||
   (strncmp(sysptr, "i386",4)==0)) 
    {
	bit=32;
     }
     else {
     bit=64;
          }
    myfile.open ("machine");
    myfile << bit<<"\n";
  myfile.close();
	printf("This is a %d bit machine \n",bit);
}
wose output is written in "machine" file. a f90 program is supposed to read it as

Code:
open(2,file="machine",status="old")
read(2,*) bit
close(2)
I want to use the C code as a function of the f90 program.
can anybody tell me how can i do that?
 
  


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
calling ranlux from fortran RudraB Programming 0 04-25-2008 08:23 AM
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
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 01:25 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