Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Anyone good with fortran?

  1. Dec 13, 2005 #1
    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.
  2. jcsd
  3. Dec 13, 2005 #2
    the other program is writen in perl. not sure if that matters or not.
  4. Dec 13, 2005 #3


    User Avatar
    Staff Emeritus

    1) You could try the code found on this page:


    The programs are:


    2) Does Fortran not have IPC (interprocess communication)?
  5. Dec 13, 2005 #4
    Does anyone even use fortran any more.. or is this for educational purposes?
  6. Dec 13, 2005 #5

    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.
  7. Dec 13, 2005 #6


    User Avatar
    Staff Emeritus

    I do use a fortran program developed many years ago by a professor of mine but that's about it.
  8. Dec 13, 2005 #7
  9. Dec 13, 2005 #8


    User Avatar
    Staff Emeritus


    I think this about sums it up:

    [January 1995]
  10. Dec 13, 2005 #9
    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
    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
  11. Dec 13, 2005 #10


    User Avatar
    Staff Emeritus

    I did a google search and found this:

    CALL SYSTEM('yourprogram')
  12. Dec 13, 2005 #11

    And? The discussion is about C and C++ vs F90. Unless I missed something, that should still apply.
  13. Dec 13, 2005 #12
    Great, its works! Thanks
  14. Dec 14, 2005 #13


    User Avatar
    Science Advisor
    Gold Member

    Nice read - thanks, in many of our appls this applies :
  15. Apr 20, 2006 #14
    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
  16. May 14, 2006 #15
    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Anyone good with fortran?
  1. Good FORTRAN Compiler (Replies: 10)