开发者

Porting sun studio compatible fortran 77 to gcc: format specifier in READ, FORMAT

I have some old fortran 77 I'm trying to port to gcc on Windows.

I'm using gfortran 4.4.

The statement uses READ(FOO, '(F)' , ERR=BAR) BAZ and gcc is complaining about F. From what I've seen it looks like F needs a size associated with it. There are also FORMAT statements which use a similar construct.

What is the proper way to port this? I开发者_运维问答t seems like using F alone on sun studio compilers just fits to the proper size. But gfortran complains about it not being a non-negative or positive width.

Any ideas how to port this?


This is a formatted read. It should be READ(FOO, '(FN.M)' , ERR=BAR) BAZ, N and M specific numbers, where N is the field width in characters and M is the number of digits after the decimal point. On input M doesn't matter if the data has a decimal point, because the decimal point will override the format specification. If you aren't sure that the input data will always fit within this strict specification, it is probably better to switch to format-free input: READ(FOO, * , ERR=BAR) BAZ. This is also called list-directed i/o. This is very flexible and guessing, probably better matches what the extension "F" was doing. (format-free / list-directed is different from unformatted, which is for binary files without any conversion of the bits.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜