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

Read, Write - Extra Blank Spaces Question

ssragunath
Beginner
349 Views
Hi,
I am reading a line from a file and writing it to another file. The sample code is given below.
CHARACTER*80 CURR_LINE
OPEN(3, FILE='input.inp',STATUS='OLD')
OPEN(4, FILE='output.out', STATUS = 'NEW')
READ(3,'(A80)') CURR_LINE
WRITE(4,'(A80)') CURR_LINE
CLOSE(3)
CLOSE(4)
The problem is that I am getting extra blank spaces at the end of the line in the output file. For example if the input file line is 5 characters long, the code fills the output line from 6th character to 80th character with blank spaces. This creates a lotof problems for me in another software. Can someone tell me how I can get rid of the empty characters at the end of the line. I am using CVF 66A.
Thanks.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
349 Views
WRITE(4,'(A)') TRIM(CURR_LINE)
0 Kudos
ssragunath
Beginner
349 Views
Thanks for the help. I will try this.
0 Kudos
Reply