- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
The output of my program is a text file. The write statement is as follow:
open(unit=3 , file='GI.txt') do i=1,n write(3,*) GI(i,20),GI(i,21),GI(i,22),GI(i,23),GI(i,24),GI(i,25),GI(i,3) end do close(unit=3)
The output text file is:
8.3631918E-02 3.8731284E-03 0.9124947 1.6570982E-02 1.2863785E-03 0.9817734 5.000000 8.3645843E-02 3.6123185E-03 0.9127416 1.6570950E-02 1.1989133E-03 0.9818419 5.000000 8.3371475E-02 3.6123185E-03 0.9130162 1.6491989E-02 1.1989133E-03 0.9819432 5.000000 8.3385289E-02 3.3518937E-03 0.9132624 1.6491955E-02 1.1117029E-03 0.9820116 5.000000 8.3376385E-02 3.0915497E-03 0.9135318 1.6491907E-02 1.0245456E-03 0.9821022 5.000000 8.3367527E-02 2.8312337E-03 0.9138010 1.6491858E-02 9.3740685E-04 0.9821926 5.000000 8.3357789E-02 2.5716582E-03 0.9140702 1.6491810E-02 8.5075555E-04 0.9822835 5.000000 8.3347775E-02 2.3130313E-03 0.9143388 1.6491760E-02 7.6472707E-04 0.9823740 5.000000 8.3338819E-02 2.0545253E-03 0.9146064 1.6491711E-02 6.7877769E-04 0.9824634 5.000000 8.3329812E-02 1.7961761E-03 0.9148740 1.6491663E-02 5.9293135E-04 0.9825526 5.000000 8.3320513E-02 1.5382101E-03 0.9151412 1.6491614E-02 5.0733547E-04 0.9826420 5.000000
and what happens is that, for example, [GI(1,20),GI(1,21),GI(1,22),GI(1,23),GI(1,24)] are in one line and [GI(1,25),GI(1,3)] are in the next line. I want to make all the seven values in a single row.
Also is there any way to make the format looks like that:
Sw Krw Kro ----------------------- 1.0 1.0 0.0
0.9 0.9 0.1
0.8 0.8 0.2
?
Thanks in advance
Andrew.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add a RECL=<nnn> clause to your OPEN statement, or use a formatted WRITE instead of list-directed WRITE.
I don't understand your second question. What do you want to print, and what have your attempts yielded so far?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The default record length (80?) that is applied to the text file is too short. try adding RECL=132 to the open statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks all but the output is like that:
0.1000904 0.8985094 1.3999972E-03 1.8356534E-02 0.9676864 2.4477080E-03 5.000000 0.1000826 0.8971182 2.7987848E-03 1.8356487E-02 0.9652581 4.8911870E-03 5.000000 0.1000750 0.8957291 4.1955458E-03 1.8356441E-02 0.9628368 7.3275873E-03 5.000000
I want the results to be in the form of a table, for example to be like that:
0.1000904 0.8985094 1.3999972E-03 1.8356534E-02 0.9676864 2.4477080E-03 5.000000 0.1000826 0.8971182 2.7987848E-03 1.8356487E-02 0.9652581 4.8911870E-03 5.000000
And the second part of my inquiry is how to add a label to each column
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The output does not make sense, what does your new code look like?
You need to read up on the FORMAT statement to control how each element is output i.e. field width and decimal places etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The new code is:
open(unit=3 , file='GI.txt', RECL=7) do i=1,n write(3,*) GI(i,20),GI(i,21),GI(i,22),GI(i,23),GI(i,24),GI(i,25),GI(i,3) end do close(unit=3)
Do you suggest me a specific source ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The default RECL is 80 (that is what you declared to be insufficient in your original post. Why then, instead of something big enough, such as 132 (standard line-printer line size), did you use 7? Try RECL=132 in the OPEN statement.
RECL=7 specifies that each line be no more than seven characters long. Perhaps you thought, incorrectly, that it meant "enough space for seven real numbers"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got it. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's also the (new in 14.0) option /wrap-margin- which prevents list-directed output from wrapping records.
![](/skins/images/1FC86CD46823E418D1E2B7B4DC10231C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page