forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multi line format statement and missing width count error

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Abhishek



Joined: 22 Dec 2010
Posts: 28

PostPosted: Mon Jan 10, 2011 3:07 pm    Post subject: Multi line format statement and missing width count error Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Mon Jan 10, 2011 3:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Abhishek



Joined: 22 Dec 2010
Posts: 28

PostPosted: Mon Jan 10, 2011 3:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Mon Jan 10, 2011 5:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Tue Jan 11, 2011 1:01 am    Post subject: Reply with quote

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
View user's profile Send private message
Abhishek



Joined: 22 Dec 2010
Posts: 28

PostPosted: Tue Jan 11, 2011 8:41 am    Post subject: Reply with quote

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
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2625
Location: Sydney

PostPosted: Thu Jan 13, 2011 3:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group