-----Original Message-----
From: Russell, Richard
Sent: Thursday, July 03, 2003 8:36 AM
Sent: Thursday, July 03, 2003 8:01 AM
To: [log in to unmask]
Subject: Re: Formatted read
In my second reply on this issue, I incorrectly stated that I made an error in the second format, used if a long string variable were to be used, rather than an array of 1-character elements. I had it right the first time:
READ(8,'(A70)') (STRVAR(I:I+MIN(69,LENGTH-I)),I=1,LENGTH,70)
Each I/O list item, in this case, becomes a substring of STRVAR, of length 70 for all but the last substring, and it needs the A70 to grab 70 characters and pull what it needs from that, discarding the blanks trailing the non-blank digits on the last record of the set.
I don't know what I was thinking when I said the format spec should have been 70A1. Posts admonishing me and suggesting that I be more careful to avoid confusing others with my posts will be accepted with my head hung sheepishly.
Having read Malcom Cohen's reply, and his suggested use of an numeric rather than character array, I imagine it's a matter of what you are doing with the number string you read and write. If you need to do math on the collected digits, then perhaps a numeric array is better, because it saves subsequent internal reading of the characters to get values. If you do read into numeric variables, and you need to do error checking of the input if there is any possibility of non-numeric input being there, then you will want to add IOSTAT=ier to the READ statement, to get control of error detection and reporting. Otherwise the program will just bomb with a less-than-useful message and perhaps a traceback.
Dick Russell
-----------------------------------------
*****************Internet Email Confidentiality Footer******************
Privileged/Confidential Information may be contained in this message.
If you are not the addressee indicated in this message (or responsible
for delivery of the message to such person), you may not copy or deliver
this message to anyone. In such case, you should destroy this message
and notify the sender by reply email. Please advise immediately if you
or your employer do not consent to Internet email for messages of this
kind. Opinions, conclusions and other information in this message that
do not relate to the official business of The Shaw Group Inc. or its
subsidiaries shall be understood as neither given nor endorsed by it.
________________________________________________________________________
The Shaw Group Inc.
http://www.shawgrp.com
|