Simple quick Fortran question involving write command

Discussion in 'Mac Programming' started by Spanky Deluxe, Aug 25, 2010.

  1. Spanky Deluxe macrumors 601

    Spanky Deluxe

    Joined:
    Mar 17, 2005
    Location:
    London, UK
    #1
    Is there a simple way to write to the display at the same time as writing to a disk?

    I've just been putting together a quick program to scan through some data and have written it so that it spits out everything to the screen using write(*,*) commands.

    I'd like it to create a dump of this stuff to a file too. Obviously, I could just go through and duplicate every write command but is there a simpler more elegant way to do it?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Nothing Fortran-specific, but:
    tee will allow you to write to a file while displaying to the screen, so you could run your program through that.

    You could also: write directly to a file, but fork and exec tail -f on that file when you start, but after the file is created.

    -Lee

    Edit: also, write(*,*)? so lazy! =) Fortran is an odd choice for a quick parse script. Might be time to learn a little perl.
     
  3. crackpip macrumors regular

    Joined:
    Jul 23, 2002
    #3
    Along the lines of what lee1210 posted, why don't you wrap the Fortran binary in a 2-line shell script using tee or tail.

    Crackpip
     
  4. Spanky Deluxe thread starter macrumors 601

    Spanky Deluxe

    Joined:
    Mar 17, 2005
    Location:
    London, UK
    #4
    Yeah tee will work but ideally this will be off running on a cluster so I'd like to keep it as internal as possible. The rest of my code's in Fortran so I'm used to using it. I'm normally dealing with equations and stuff not input/output so I'm a bit rusty on that and write(*,*) and write(*,linenumber) with a format string does the job on the whole.

    I might just do that. :)
     

Share This Page