Thread Closed

running a Fortran 77 program in a C++ enviorment/program

 
Share Thread Thread Tools
Apr3-08, 09:41 PM   #1
 

running a Fortran 77 program in a C++ enviorment/program


I hope someone out there can help me out on this one. I have intermediate C++ experience, just a working level knowledge, however my prof. threw me a project to work on and where I am at now I have no experience with.

So this is whats up, I have a massive fortran 77 program...that does some heavy, calculations with a but load of data which can take days to execute on a supercomputer. However, I was told not to mess with the fortran77 program even though most of the code is 'homegrown' and there are extensive libraries out now that can take away pages of code.

So my task is to vary the input file this program is running off of, run the fortran program and get the output files and loop it over again at another interval.

So some how I need to run this fortran program within a C++ program that I am going to write, more to the point inside a loop that will change the input file, run fortran, get output files...rename output files to match interval it was intially ran at, and change interval and do it all over again.

How in the hell do you run a fortran77 program within a C++ program?
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Ants and carnivorous plants conspire for mutualistic feeding
>> Forecast for Titan: Wild weather could be ahead
>> Researchers stitch defects into the world's thinnest semiconductor
Apr3-08, 10:57 PM   #2
 
If the fortran code is already compiled (so you have "something.exe" sat in your working directory) then you could try something like:

#include <stdlib.h>
....
system("something.exe");
....

If you want to run fortran code in c++ then there is a wrapper, called "f2c" (I think you just need a header file, "f2c.h"). I've never used this so I have no idea how it works... but I hope this helps.
Apr3-08, 11:50 PM   #3
 
Yes that helps, I figured it had to be something like that but I had no clue where to look, I figured as for simplistically and efficiency I should just run the executable within the C++ program, b/c well my next task after I write this piece of serial code...is to parallelize the loop and I thought it would be better for me and the program to just run the executable.
Thanks much
Thread Closed
Thread Tools


Similar Threads for: running a Fortran 77 program in a C++ enviorment/program
Thread Forum Replies
help with fortran program Programming & Comp Sci 6
Help! need to write fortran program Programming & Comp Sci 8
fortran program structuring.. Programming & Comp Sci 2
problem in fortran program Programming & Comp Sci 0
help with simple Fortran program Programming & Comp Sci 1