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

Writting 2D array to a file

  1. Dec 25, 2008 #1
    Hello,

    i have a problem and i was wondering whether anyone in here can give me a hand. I want to write a 2D array to a file in format that can be read from another program in order to make a 3D graph. I'm using fortran. In few words i want to place the data in columns and rows in the file exactly as they are writen to the array.

    I appreciate any help and i thank you in advance.


    John
     
  2. jcsd
  3. Dec 25, 2008 #2

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    I'm not at all clear what you want to do here. I thought for a moment that you wanted to be able to just "print" the data file on the screen or printer, but you talk about "read from another program". HOW you save the data isn't important (they will, in any case, be saved linearly). As long as your other program reads the data back in exactly the same way the file was written you will get back exactly the same 2D array and can do whatever you want with it. That's one reason why most people today use "Object Oriented Programming": with the routines for writing to and reading from a file are part of the data definition, you are sure to do it right.
     
  4. Dec 25, 2008 #3

    Defennder

    User Avatar
    Homework Helper

    I'm puzzled as to where the 3D graph comes from.
     
  5. Dec 25, 2008 #4
    I give an example. Let's say i have an array like this:


    1 2 3 4 5
    6 7 8 9 10
    11 12 13 14 15


    I want to be writen in the file as it is and not like this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15


    Is that possible?


    John
     
  6. Dec 25, 2008 #5
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Writting 2D array to a file
  1. FORTRAN 90 2d arrays (Replies: 6)

Loading...