3

I want to write the following output to a txt file using f77:

14  76900.56273 0.000077    -100000     1000000000   -0.769006

I use:

write(6,*) KINC, BM, R2, AF, BK, BM/AF

without any format (which works well in terms of decimal digits). However in my txt file the output is written as:

14  76900.56273 0.000077    -100000 
1000000000    -0.769006

Because I think there is a fixed column width limit by default. I don't know if it is possible to change this so that I can just copy and paste it to excel.

I've looked at FORTRAN 77 Language Reference but I haven't found a way to do it. Any ideas? Thanks

5
  • 1
    Have you considered specifying a "too large to ever be an issue" width to override the default? Commented Feb 25, 2014 at 13:42
  • I have but I don't know how to do that.... :) Commented Feb 25, 2014 at 13:44
  • Isn't fixed column width limit set in your txt file editor/viewer? Commented Feb 25, 2014 at 13:50
  • I don't think so because the txt file to which I'm writing has other text written which don't have this problem.... Commented Feb 25, 2014 at 14:40
  • Related: stackoverflow.com/q/21171556/2068635 Commented Feb 25, 2014 at 16:56

2 Answers 2

2
  1. use format
  2. or check your compiler's option

if your compiler is one of dec/compaq/intel, read this link.

http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-win/hh_goto.htm#GUID-C6A40AAC-81D8-4DD8-A792-62792B3AC213.htm#GUID-C6A40AAC-81D8-4DD8-A792-62792B3AC213

list directed output (fmt=*) :: 80 column limit default.

"There is a property of list-directed sequential WRITE statements called the right margin. If you do not specify RECL as an OPEN statement specifier or in environmental variable FORT_FMT_RECL, the right margin value defaults to 80. When RECL is specified, the right margin is set to the value of RECL. If the length of a list-directed sequential WRITE exceeds the value of the right margin value, the remaining characters will wrap to the next line. Therefore, writing 100 characters will produce two lines of output, and writing 180 characters will produce three lines of output."

In intel's manual, blue color indicates extensions to the Fortran Standards. These extensions (non-standard features) may or may not be implemented by other compilers that conform to the language standard.


oracle(sun) F77

http://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbu/index.html#z400074369ac

"Output lines longer than 80 characters are avoided where possible"

Sign up to request clarification or add additional context in comments.

1 Comment

+ gfortran has no problem like this. It's default recl value is 1073741824 bytes (1 GB).
1

With the asterisk as the format, you are using listed-directed IO. This is intended as a convenience. It gives the programmer minimal control, with few restrictions on the compiler and incomplete portability. The compiler is free to determine aspects such as line length. If you want control over line length, switch to using an actual format.

P.S. Why use FORTRAN 77? Fortran 90/95/2003 is easier to use and more powerful. gfortran is an open-source compiler.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.