- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I'm attempting to write a file data that it's a matrix (851*851), but when I try to write more than 80 col. in a line, the rest of the line is written on the next line. Is there a way to write in 1 line, and undetermined number of columns? I tried with:
Write(99,10) zeonmatch(ii,:)
10 FORMAT (A851)
but neither worked.
Thank you all,
Adrian
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume that your first try was with list-directed output (format *). With that, you are allowing the compiler to choose a line break wherever it wants. You can open the unit with a long value for RECL and list-directed formatting will use that. In a future version we'll enable some more control over this.
Your second try encountered an obscure language feature called "format reversion". When the closing parenthesis of a format is reached and there are still more items to process, a new record is started and the format "reverts" to the left parenthesis matching the last right parenthesis seen. I don't think you really meant A851 here, as that is a single character item that is 851 characters long. Anyway, here is what you want to use:
10 FORMAT (*(G0,1X))
The * is a Fortran 2008 feature called "unlimited format repeat count" which repeats the following format group as many times as is needed to satisfy the I/O list. G0 is a general purpose format that will accept any datatype. You can substitute any format edit descriptor you want there, such as E, I or A. If you like G but want to specify a number of digits to the right of the decimal point, use G0.4, for example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As it happens I wrote a blog post about format reversion - read it for all the gory details. Doctor Fortran in "Revert! Revert! The End (of the format) is Nigh!"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve, the option:
10 FORMAT (*(G0,1X)),
formally solved the problem.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page