| View previous topic :: View next topic |
| Author |
Message |
Abhishek
Joined: 22 Dec 2010 Posts: 28
|
Posted: Mon Jan 10, 2011 3:07 pm Post subject: Multi line format statement and missing width count error |
|
|
Hi
I am using multi line format statements. The file format is fixed because this is a legacy code. Example statement is given below
18 FORMAT(/78HTHIS IS MY LINE IN THE OLD CODE WHICH GOES ON FOR THE
1RIGHT SIDE OF TWO LINES.)
Such a statement is causing errors as follows:
Unknown edit descriptor 'R', or missing comma
This is happening in all multiline FORMAT statements. The code is compiling fine in other FORTRAN compilers.
Can someone throw some light on this ?
Thanks
Abhishek |
|
| Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Mon Jan 10, 2011 3:42 pm Post subject: |
|
|
Hi, I'm not sure what you want do display with that format, but try for instance this:
| Code: |
write(6,18)
18 FORMAT('/78H,THIS IS MY LINE IN THE OLD CODE WHICH GOES ON FOR THE
*RIGHT SIDE OF TWO LINES.') |
Use an asterisk as continuation mark in column 6 and put the format statements in ' ', then it works.
Regards - Wilfried |
|
| Back to top |
|
 |
Abhishek
Joined: 22 Dec 2010 Posts: 28
|
Posted: Mon Jan 10, 2011 3:58 pm Post subject: |
|
|
Thanks. Will try this.
Actually I am trying to write to an internal file (a character(2000) variable) using these kind of FORMAT statements ad trying to build up output text.
Some more related questions:
Is there a limit to the no. of characters that can be written to an internal file using formatted WRITE statements ?
If answer to the above question is yes, then how to get around this limit ?
If a '/' or a '//' is included in the FORMAT statement, will it be correctly written to the internal file as char(10) + char(13) characters ?
Thanks
Abhishek |
|
| Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Mon Jan 10, 2011 5:38 pm Post subject: |
|
|
I don't know the maximum no. of characters, sorry. To place char(10) and char(13) into the string, you may do the following:
| Code: |
program test
integer*4 l
character*2 crlf
character*10000 string
crlf(1:1) = char(10)
crlf(2:2) = char(13)
string = ' '
write(string,'(A,A,A,A,A)')
* 'this is a test to',crlf,
* 'see what will happen',crlf,
* 'if you write this into a string'
l = leng(string)
print*,string(1:l)
end |
Regards - Wilfried |
|
| Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Tue Jan 11, 2011 1:01 am Post subject: |
|
|
You can't use / to put return characters in character arrays (internal files).
At least you never could do this in Fortran 77.
You can use the method suggested by Wilfried, that should work. |
|
| Back to top |
|
 |
Abhishek
Joined: 22 Dec 2010 Posts: 28
|
Posted: Tue Jan 11, 2011 8:41 am Post subject: |
|
|
Thanks for the valuable inputs.
Looks like FTN95 compiler does not like string constant being split. If I use
18 FORMAT(/37HTHIS IS MY LINE IN THE OLD CODE WHICH,1X,
140HGOES ON FOR THE RIGHT SIDE OF TWO LINES.)
instead of the earlier one, it is working fine.
The crlf example is also working fine. I guess I can do with it.
Looks like I have my own issue when I say there is a limit on no. of characters in internal write. Let me do more research and post again!
Thanks
Abhishek |
|
| Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2623 Location: Sydney
|
Posted: Thu Jan 13, 2011 3:45 am Post subject: |
|
|
Using free format code format removes most of these problems.
| Code: |
18 FORMAT(/'THIS IS MY LINE IN THE OLD CODE WHICH GOES ON FOR THE RIGHT SIDE OF TWO LINES.')
|
|
|
| Back to top |
|
 |
|