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

How to read files while running fortran program?

  1. Jun 25, 2013 #1
    Hi,

    I am trying to run a simulation written mostly in Fortran on Linux. The User's Manual says that "To run a simulation one needs to read several input files." Then, it lists a bunch of files. I was wondering what it means by that and how I "read" the files?

    Thanks in advance,

    Naomi
     
  2. jcsd
  3. Jun 25, 2013 #2

    jtbell

    User Avatar

    Staff: Mentor

  4. Jun 25, 2013 #3
    @jtbell, thank you but no. I'm not trying read files within the program. The program is all completely written. But now when I run it, I think I need to link to those files or something, I'm not sure.
     
  5. Jun 25, 2013 #4

    Mark44

    Staff: Mentor

    "Link" has a very specific meaning in compiled programming languages such as Fortran, and is not applicable in your case. Your program needs to open the files and read from them, as described in the link that jtbell provided.

    Your program needs to know the names of the files that it will be getting input from. The names of these files could be hardcoded in strings in the program, taken as input at run time, or passed on the command line when the program begins running. Without seeing the source code of your program, we can't say what you need to do to run it.
     
  6. Jun 25, 2013 #5
    Nevermind, I figured it out. I just included the file as < file.txt > in the command line where I ran the program.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to read files while running fortran program?
  1. Read file in fortran (Replies: 2)

Loading...