Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Maximum CHARACTER(:) length on WRITE?

pedro_gonnet
Beginner
923 Views
I'm trying to write a rather large CHARACTER buffer:

CHARACTER(LEN=MAXLINE) :: buff
INTEGER :: buff_length
[...]
WRITE(*,'(A)') buff(1:buff_length)

and get the following error

Input/Output Error 154: Wrong length record

In Procedure: main program
At Line: 356

Statement: Formatted WRITE
Unit: 6
Connected To: Stdout
Form: Formatted (contains List-Directed records)
Access: Sequential
Records Read : 0
Records Written: 27

End of diagnostics

when buff_length is greater than 1024. The following

CHARACTER(LEN=MAXLINE) :: buff, buff_format
INTEGER :: buff_length
[...]
WRITE(buff_format,'(A,I0,A)') '(A', buff_length, ')'
WRITE(*,buff_fromat) buff(1:buff_length)

doesn't fix the problem, i.e. I get the same error.

I've checked the Programmer's Reference found no mention of a maximum string or output size and hence no way of getting around this problem. Wrapping the WRITE-statement in a loop and writing buff piecewise works, but it is not elegant.

Did I miss something in the Programmer's Reference or is this a bug in the I/O routines?

Cheers and many thanks in advance
Pedro
0 Kudos
5 Replies
Steven_L_Intel1
Employee
923 Views
What version are you using? Please spell out the full package ID (l_fc_????)
0 Kudos
pedro_gonnet
Beginner
923 Views
ifc -V says

Intel Fortran Compiler for 32-bit applications, Version 7.1 Build 20030307Z
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY

GNU ld version 2.14 20030612
Supported emulations:
elf_i386
i386linux

Cheers and thanks
Pedro
0 Kudos
Steven_L_Intel1
Employee
923 Views
An old 7.1, hmm. I am not familiar with the I/O implementation of 7.1. I know it is very different in 8.0 and you should not have this problem there.
0 Kudos
pedro_gonnet
Beginner
923 Views
The problem with version 8.0 is that it woun't compile the program in which this happens, so this won't fix the problem :(

Also, after having read the thread on SSE optimizations in the latest 7.1, I don't really feel like upgrading since I also work on AMD machines.

Has this problem ever been documented before or is there a way of getting around it that does not imply making the code ifc-specific?

Cheers and thanks
Pedro
0 Kudos
Steven_L_Intel1
Employee
923 Views
The SSE issue is fixed in the current 8.0 package.
Did you submit a report on the compile failure? What's the report number?
Seems to me you already have a solution for 7.1.
0 Kudos
Reply