Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
337 Views

Maximum line length for WRITE statement

Hi all, I'm running in an error:

"forrtl: severe (66): output statement overflows record"

ifort - v says I'm running "Intel(R) 64, Version 17.0.2.187 Build 20170213" in MS Studio Community 2015

I am writing a very long line to a file with 1007 columns, the following statement gives the error

WRITE(16,'(2G13.3, 2I3, 2G10.2, I4, 1200(1X,G15.8,1X,E12.6))')
     & X, Y, N, IH, ZT, ZB, NH,  ( PROP(M), FLAG(M) , M=1, SIZE(PROP) )    

Note:
-statement simplified for this post
-unit 16 is well defined
-the value of '1200' in the format is always larger than SIZE(PROP)

I changed the code to first do an internal write to "out_test", where this variable has a large enough size:

CHARACTER(35000) :: out_test

so instead of the above, I do

WRITE(out_test,  <SAME FORMAT ETC.>

this works until I try to write it to a file:

WRITE(16,'(A)') trim(out_test)

Again same error.

this however works (but contains line breaks in the output I want to avoid):

WRITE(16,*) trim(out_test)

Any hints?

Cheers

-Ralf

 

0 Kudos
4 Replies
Highlighted
Valued Contributor III
337 Views

The default record  length for the file is not long enough I think. Add a RECL= to the open statement.

 

0 Kudos
Highlighted
Black Belt Retired Employee
337 Views

Show us the OPEN statement for unit 16. The documented maximum record length for a formatted, variable-length record is 2147483640 bytes. As far as I know, you should not need to specify RECL. Can you post a small but complete program that shows the problem?

0 Kudos
Highlighted
Valued Contributor III
337 Views

really confused now. I thought there was some problem with records over 132 characters as I have had problems in the past. I can even look at code where i have added record lengths as a fix. Try as I might I cannot replicate this problem. Maybe with some other /older compiler perhaps ......

0 Kudos
Highlighted
Beginner
337 Views

Thanks Andrew and Steve,

indeed it was the OPEN statement:

 OPEN(16,FILE=OUTF,STATUS='UNKNOWN',RECL=8192)

which I changed to

 OPEN(16,FILE=OUTF,STATUS='UNKNOWN')

This worked.

 

Cheers

-Ralf

 

0 Kudos