Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Puzzled by console line length

OP1
New Contributor I
182 Views

This code (compiled with 17 Update 1)

PROGRAM P
USE ISO_FORTRAN_ENV
IMPLICIT NONE
INTEGER :: RECLENGTH
INQUIRE(UNIT=OUTPUT_UNIT,RECL=RECLENGTH)
WRITE(OUTPUT_UNIT,'(I4)') RECLENGTH
WRITE(OUTPUT_UNIT,'(A)') '<------ This character string is exactly 80 characters long, believe me! ------>'
WRITE(OUTPUT_UNIT,'(A)') 'Oops!'
END PROGRAM P

when run in a console window with a 80-character long line, produces the output:

 132
<------ This character string is exactly 80 characters long, believe me! ------>

Oops!

Why is there a blank line between the two lines of text?

0 Kudos
9 Replies
Steve_Lionel
Black Belt Retired Employee
182 Views

I don't see that:

D:\Projects>t.exe
 132
<------ This character string is exactly 80 characters long, believe me! ------>
Oops!

 

Arjen_Markus
Valued Contributor III
182 Views

It may be a consequence of the terminal/console detecting that the line was written up to the end of the visible line and therefore inserting a carriage return/line feed.

andrew_4619
Honored Contributor I
182 Views

So if you 80 char string is 85 long it it wrapping at 80?

OP1
New Contributor I
182 Views

Yes, it the string is 85 long it will wrap at 80. I am puzzled by the fact that when 80 long it 'wraps' and prints out a blank line. The RECL is also ignored, independently of what the /wrap-margin compiler option is (if the console is wider that 132 characters no wrapping happens).

Arjen may be onto something... I am not sure how to disable this though. It seems that Steve cannot reproduce this.

This is purely cosmetic of course, but a bit disconcerting. I oftentimes output to the console 'delimiter strings' which have the width of the console, to keep the output of my code neat; and now it is inserting a blank line afterwards. Strange.

Steve_Lionel
Black Belt Retired Employee
182 Views

I don't think it's Intel Fortran doing the wrapping. The options you mention apply to list-directed output only.

jimdempseyatthecove
Black Belt
182 Views

The line wrap when text printed hits right margin (80 in this case), followed by anything, even non-advancing character (except maybe back space), will line advance (depending on terminal emulator). This includes CR, LF, CRLF.

This has been with us since the 1980's. Think of it as a "feature".

Jim Dempsey

jimdempseyatthecove
Black Belt
182 Views

BTW

Windows, in text edit box/window has an equally goofy line advance issue depending on if window has vertical scroll bar and/or boarder design.

Jim Dempsey

andrew_4619
Honored Contributor I
182 Views

You can set and control console attributes using windows api routines but some work is involved.

OP1
New Contributor I
182 Views

Thanks to all for the answers - yes, it looks as if this is a Windows console behavior that cannot be controlled "easily" from my code.

Reply