line breaks

line breaks

jand@uvic.ca的头像

Hi, and here another question:

I noticed that standard output (e.g. print* or write(*,*)) gives me line breaks when outputting to stdout or files.

I would like to change the default behaviour of this. I can do something like

RECL=1024

in open statements but I'd much rather change the default behaviour since I do not want to change code. I have never noticed this with compilers I used before (mostly Pathscale but also Portland, absoft, etc.). Am I missing something?

Thanks, Jan

4 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Steve Lionel (Intel)的头像

I suppose what you are missing is that the language provides great freedom for the implementation to start new records in list-directed output. Not only that, but the actual formatting chosen can vary. If you want a specific layout, then use an explicit format. Our compiler starts new lines with the assumption that one is viewing the output on a typical console display with 80-column width.

You can define an environment variable before starting your program, FORT_FMT_RECL, to be the value you want for the default RECL. I recommend against using this, though and suggest that you switch to an explicit format.

Steve
rudi-gaelzer的头像

Regarding this old post, I'm rather puzzled by the unexpected behaviour of list-directed output.
I want to write on the console the value of a quad-precision (REAL*16) complex variable, say z.
As expected, print*, z or write(*,*)z prints out its value in 2 lines, with the record broken after the comma.

Then I tried to modify the list-directed output so that the record is printed on a single line. This is what I did:
(Using Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.0.0.079 Build 2012073)

...
USE IFPORT
logical :; tesva
...
tesva= setenvqq("FORT_FMT_RECL=100")
write(*,*)z
...

The output is exactly the same (record broken into 2 lines) regardless if I set the value of FORT_FMT_RECL as 100, 1000 or 10000...

What am I doing wrong here?

jimdempseyatthecove的头像

The environment variable needs to be set _before_ the program starts.
The record length is captured during the "file" open. stdout (*) is opened prior to your above tesva= setenvqq("FORT_FMT_RECL=100")

Jim Dempsey

www.quickthreadprogramming.com

登陆并发表评论。