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

Fortran help: Open and Write functions

  1. Apr 25, 2013 #1
    How can I have an open statement:


    and be able to later have a write statement:

    15 FORMAT('Data was collected from ',????,'file:')

    where the ??? would call in the file name. Also, when I type 'file:', it creates a link to something. How do I stop that or do I need to just do something else instead?
  2. jcsd
  3. Apr 25, 2013 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    'data.txt' can be the value of a variable of type CHARACTER. You would replace the ???? in yourFORMAT statement with an A descriptor and use the name of the CHARACTER variable on the corresponding WRITE statement.

    For your last question, could you clarify what you are asking?
  4. Apr 25, 2013 #3
    Thank you, I should have realized that sooner. With my second question, when I went to type my write statement, once I had the ':' after file, it became blue and underlined. I am still new to fortran and I have never seen or had to use a feature that did that. Is it something that can be suppressed or do I have to use a different character instead of ':' after the word 'file'?
  5. Apr 25, 2013 #4


    User Avatar

    Staff: Mentor

    What are you using for writing your code? That sounds like something Microsoft Word would do. :yuck:
  6. Apr 25, 2013 #5


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Some programming editors use different colors to display statements according to their use in the program. For instance, declaration statements may be one color, comments another, executable statements another, etc. The final color sometimes cannot be determined until the statement is completely entered.
  7. Apr 25, 2013 #6
    Needless to say, this highlighting of characters or entire words has nothing to with the Fortran program per se and are not part of the syntax, nor persist once you save the file to disk and quit whatever editor you are using...it is simply a convenience offered by some text editors to make it easier to the human eye to tell things apart...just wanted to mention this since nobody seemed to have said it and it seems that you could benefit from such commentary, too.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook