Silverfrost Forums

Welcome to our forums

Multi line format statement and missing width count error

10 Jan 2011 2:07 #7430

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

10 Jan 2011 2:42 #7432

Hi, I'm not sure what you want do display with that format, but try for instance this:

      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

10 Jan 2011 2:58 #7433

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

10 Jan 2011 4:38 #7439

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:

      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

11 Jan 2011 12:01 #7448

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.

11 Jan 2011 7:41 #7457

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

13 Jan 2011 2:45 #7481

Using free format code format removes most of these problems.

18 FORMAT(/'THIS IS MY LINE IN THE OLD CODE WHICH GOES ON FOR THE RIGHT SIDE OF TWO LINES.') 
Please login to reply.