- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey,
I'm trying to write the dates (yyyy-mm-dd) from 99 years into one singel row in a textfile.
By:
WRITE (15,155)(string_date_array(I), char(9), I=1,365000)
155 format ('%ID',' ',365000a10,a2))
But after a while the dates starts to write to line number 2 in the texfile. Is their any limits of the length of the row? How can I get around it?
All the dates has to be in the same row.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try using formatted stream output - OPEN(... FORM='FORMATTED', ACCESS='STREAM', ...)
Check the syntax of your FORMAT - are you missing an opening parenthesis and what is the a2 doing on the end?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please post your OPEN statement for the file in question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OPEN(15+(scen_loop*par_loop),file='..\..\..\testbank\'//trim(scen(scen_loop))// &
'\mapresultat_'//trim(scen(scen_loop))// &
'_'//trim(parameters(par_loop))//'.txt' &
,status='unknown',form='formatted')
WRITE (15+(scen_loop*par_loop),155)(string_date_array(I), char(9), I=1,365000)
155 format ('%ID',' ',365000(a10,a2)
The "a2" was a attempt to describe a tab. I started with 365000(a10,a).
If I remove char(9) in the WRITE statement and uses 365000(a12) it works now. But what if I like to write integers instead? In that case I can't add the two extra spaces after the string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
use 365000(i12) or
use 365000(i10,2x) to be sure to have two spaces after the number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Text files are subject to some limitations and expectations. One expectation is that they should be suitable for reading by a person. At 6 characters per inch your file, printed on paper, would require a sheet of paper so long as to extend beyond the right edge of my laptop, past my neighbor's backyard and into a neighborhood that I would hesitate to enter at night -- 11 miles (about 18 km) away. Do you really need that file to be a formatted file?
That said, are you aware of the nX format descriptor, which allows you to enter any number of blanks into an output line, but without needing to have any corresponding items in the I/O list? For integers, about which you asked, you could use a format of 365000*(2x,I10) or even 365000*I12. If the field width specified (e.g., 12 in "I12") is longer than needed for the number being formatted, the output is right-justified within the field and padded at the left with blanks.
Fortran 2008 allows you to use an 'unlimited' repeat count specifier, as in "*I12", see https://software.intel.com/en-us/node/510350 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can see the point of using formatted instead. I will look up if that's a opportunity.
It´s works fine using 365000I12 (But still 365000(2x,I10) does not works, in fact, even 365000(I12) won't work).
Thank you all!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page