View Full Version : anyone good with fortran?
Im writing a program in fortran 90. what im trying to get it to do is to open an input file for another program, change a few variables. then run that program. Then when the program is done running it will change the variables in the input file again and run the program. This will be a Do loop.
I know how to do all of this except how to run the other program from inside the fortran program.
the other program is writen in perl. not sure if that matters or not.
dduardo
Dec13-05, 04:25 PM
1) You could try the code found on this page:
http://www.jcameron.com/vms/fortran.htm
The programs are:
MAILBOX_A.FOR
MAILBOX_B.FOR
2) Does Fortran not have IPC (interprocess communication)?
Anttech
Dec13-05, 04:25 PM
Does anyone even use fortran any more.. or is this for educational purposes?
franznietzsche
Dec13-05, 04:37 PM
Does anyone even use fortran any more.. or is this for educational purposes?
In computer science no. In scientific work, yes. Fortran compilers produce faster code for straight numerical calculations than any other language. Plus its easier to learn than C or C++. All the work I do with Los Alamos is Fortran for simulations. I also use perl when I need to process text outputs from other people's codes into more useful formats.
I've never needed top run a seperate program by calling it from a fortran program though, and I have no idea how one would do this. That said, I don't see the advantage to using Fortran to do what you are asking at all. It would probably be much easier to do in Perl (which is designed for manipulating text). Unless the input files are binary, not text? If so, I would suggest writing a program in Fortran to convert them to text, call that from a Perl script, open the text version with the perl script, perform the necessary changes. Then if necessary, call a second Fortran program to take the new text version and convert it back to binary to be opened by the final program. I would suggest (as is my own practice) to use Perl for calling other programs, rather than using fortran to do it.
dduardo
Dec13-05, 04:38 PM
I do use a fortran program developed many years ago by a professor of mine but that's about it.
franznietzsche
Dec13-05, 04:47 PM
See this http://www.lahey.com/PRENTICE.HTM . Sums things up fairly well.
dduardo
Dec13-05, 05:28 PM
:tongue2:
I think this about sums it up:
[January 1995]
The problem is that I have this program that I need to run around 50+ times. Each time I have to change a variable in an input file. In this case its a volume measurment that I need to increase a little each time. The program will take about 5 hours to run one calculation. I wanted to make a fortran program that would change the variable and run the program. That way I could just run it and check back in a week to see if it finished. Im using fortran because its all I can really program with. So the program would look like this
Loop
1. (this part is easy, no problems here)
- open file (text file)
- read variable
- change a variable based on iteration of loop
-close file
2. Run program (I have no idea)
end loop
dduardo
Dec13-05, 06:44 PM
I did a google search and found this:
CALL SYSTEM('yourprogram')
franznietzsche
Dec13-05, 07:24 PM
:tongue2:
I think this about sums it up:
[January 1995]
And? The discussion is about C and C++ vs F90. Unless I missed something, that should still apply.
I did a google search and found this:
CALL SYSTEM('yourprogram')
Great, its works! Thanks
PerennialII
Dec14-05, 05:11 PM
See this http://www.lahey.com/PRENTICE.HTM . Sums things up fairly well.
Nice read - thanks, in many of our appls this applies :
However, unlike C and C++, Fortran 90 is designed to generate executable codes that are highly optimized and thus run extremely fast.
Im just about done with this program but Im having one major problem. I have the CALL SYSTEM subroutine inside a loop. I need the loop to pause and wait for the other program to finish running before going through the loop again. If thats hard to understand it would look something like this:
DO i=1,100
Call System('program')
pause and wait for program to finish
end do
And? The discussion is about C and C++ vs F90. Unless I missed something, that should still apply.
C++ compilers have come a long way since 1995. Also C++ coding techniques. For example, most compilers allow one to specify strict aliasing. Can you post a simple example of Fortran that cannot be translated into C++ that will run just as fast?
BTW, I'm not saying that C++ isn't ugly. But processors don't run C++ or Fortran; therefore there is no intrinsic reason for one or the other to be faster.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.