Sun compiler not liking X in format statements 
Author Message
 Sun compiler not liking X in format statements

It took me longer that I'd like to admit to find this.

I need to write to strings to create my formats, so I can se the
depth of my recursive output.

The lines

write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4),2(F8.3))"
print formstr,mydepth,k,trialnextk,mt

work.

However, if I want to add a space by my integers, and use

write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4,X),2(F8.3))"

I get a runtime error:

 ******  fortran RUN-TIME SYSTEM  ******
 Error 1000:  format error
 Location:  the PRINT statement at line 424 of "dphs1.f90"
Abort

I'm pretty sure that I've been using constructs like 3(I4,X) for a good
twenty years.

Even more oddly,

print "(3(i4,x),2(F8.3))",mydepth,k,trialnextk,mt

works, but if I instead write that expresion into formstr, and then use
formstr in the print statement, it breaks again.

Am I wrong, or is there something fishy here?

hawk
--
Richard E. Hawkins, Asst. Prof. of Economics    /"\   ASCII ribbon campaign

These opinions will not be those of              X    and postings.
Penn State until it pays my retainer.           / \  



Wed, 01 Nov 2006 06:06:59 GMT  
 Sun compiler not liking X in format statements

(snip)

Quote:
> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4,X),2(F8.3))"

> I get a runtime error:

>  ******  FORTRAN RUN-TIME SYSTEM  ******
>  Error 1000:  format error
>  Location:  the PRINT statement at line 424 of "dphs1.f90"
> Abort

> I'm pretty sure that I've been using constructs like 3(I4,X) for a good
> twenty years.

As far as I know, the X format item always needs a number
before the X, such as 1X or 10X.   There must be some history
here that I don't understand, as a length should come after
the X, and so it doesn't seem to be a length.

If it refuses 1X, post again.

-- glen



Wed, 01 Nov 2006 06:22:49 GMT  
 Sun compiler not liking X in format statements


Quote:
> It took me longer that I'd like to admit to find this.

> I need to write to strings to create my formats, so I can se the
> depth of my recursive output.

> The lines

> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4),2(F8.3))"
> print formstr,mydepth,k,trialnextk,mt

> work.

> However, if I want to add a space by my integers, and use

> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4,X),2(F8.3))"

> I get a runtime error:

>  ******  FORTRAN RUN-TIME SYSTEM  ******
>  Error 1000:  format error
>  Location:  the PRINT statement at line 424 of "dphs1.f90"
> Abort

> I'm pretty sure that I've been using constructs like 3(I4,X) for a good
> twenty years.

> Even more oddly,

> print "(3(i4,x),2(F8.3))",mydepth,k,trialnextk,mt

> works, but if I instead write that expresion into formstr, and then use
> formstr in the print statement, it breaks again.

> Am I wrong, or is there something fishy here?

The standard requires a digit before the X in a format,
so you'll need 1X.  Many processors allowed a bare X as
an extension (or maybe just didn't check for it, a
common source of "extensions").

Dick Hendrickson

- Show quoted text -

Quote:

> hawk



Wed, 01 Nov 2006 06:24:34 GMT  
 Sun compiler not liking X in format statements


Quote:

>> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4,X),2(F8.3))"
>As far as I know, the X format item always needs a number
>before the X, such as 1X or 10X.   There must be some history
>here that I don't understand, as a length should come after
>the X, and so it doesn't seem to be a length.

Wow.  And after all these years :)

What I find particularly odd is that it makes a difference (on that
compiler) whether I use a string literal or write the string into a
variable used immediately thereafter.  I'd think that it would be easier
to reuse the same parsing . . .

thanks

hawk
--
Richard E. Hawkins, Asst. Prof. of Economics    /"\   ASCII ribbon campaign

These opinions will not be those of              X    and postings.
Penn State until it pays my retainer.           / \  



Wed, 01 Nov 2006 07:32:49 GMT  
 Sun compiler not liking X in format statements

(I wrote)

Quote:
>>As far as I know, the X format item always needs a number
>>before the X, such as 1X or 10X.  
> Wow.  And after all these years :)
> What I find particularly odd is that it makes a difference (on that
> compiler) whether I use a string literal or write the string into a
> variable used immediately thereafter.  I'd think that it would be easier
> to reuse the same parsing . . .

Most compilers I know of compile format strings to an
internal representation, and use that.   Still, it would
make some sense to reuse as much of the code as possible.

-- glen



Wed, 01 Nov 2006 07:53:09 GMT  
 Sun compiler not liking X in format statements



Quote:
> It took me longer that I'd like to admit to find this.

> I need to write to strings to create my formats, so I can se the
> depth of my recursive output.

> The lines

> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4),2(F8.3))"
> print formstr,mydepth,k,trialnextk,mt

> work.

> However, if I want to add a space by my integers, and use

> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4,X),2(F8.3))"

> I get a runtime error:

>  ******  FORTRAN RUN-TIME SYSTEM  ******
>  Error 1000:  format error
>  Location:  the PRINT statement at line 424 of "dphs1.f90"
> Abort

> I'm pretty sure that I've been using constructs like 3(I4,X) for a good
> twenty years.

> Even more oddly,

> print "(3(i4,x),2(F8.3))",mydepth,k,trialnextk,mt

> works, but if I instead write that expresion into formstr, and then use
> formstr in the print statement, it breaks again.

> Am I wrong, or is there something fishy here?

> hawk
> --
> Richard E. Hawkins, Asst. Prof. of Economics    /"\   ASCII ribbon
campaign

> These opinions will not be those of              X    and postings.
> Penn State until it pays my retainer.           / \

Apart from breaking the Fortran standard,
is the character variable "formstr" of sufficient length?

Hans-Georg Gustavsson



Wed, 01 Nov 2006 23:29:31 GMT  
 Sun compiler not liking X in format statements

Quote:



>> write(formstr,*)"( ",3*mydepth,"x,' kt,rt: ',","3(i4),2(F8.3))"
>> print formstr,mydepth,k,trialnextk,mt
>Apart from breaking the Fortran standard,

I assume that you mean by using X rather than 1X?

Quote:
>is the character variable "formstr" of sufficient length?

Yep.  it was size 80.

hawk

--
Richard E. Hawkins, Asst. Prof. of Economics    /"\   ASCII ribbon campaign

These opinions will not be those of              X    and postings.
Penn State until it pays my retainer.           / \  



Thu, 02 Nov 2006 05:12:44 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Total n00b gets compiler error with FORMAT statement...

2. Intel Fortran compiler FORMAT statement tabbing to column

3. Sun Fortran 90 compiler error or not?

4. read statement works on dos compiler, not unix

5. Windows passes filename in 8.3 format and not in long format to tcl script

6. compiler for Sun 4's (compiler.com)

7. write statement output buffer flush off on Sun

8. Statement functions - Sun f90 V1.2 ?

9. #line statement in Sun f77 ?

10. statement function in Sun Fortran

11. SUN Fortran vs. Statement Functions

12. Interpreting a format() statement

 

 
Powered by phpBB® Forum Software