Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Format in Fortran

jivifair
Beginner
2,096 Views

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

0 Kudos
3 Replies
Steven_L_Intel1
Employee
2,096 Views

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.

0 Kudos
Steven_L_Intel1
Employee
2,096 Views

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!"

0 Kudos
jivifair
Beginner
2,096 Views

Thank you Steve, the option:

10 FORMAT (*(G0,1X)),

formally solved the problem.

0 Kudos
Reply