-
• #2252
The file is created with a bash file, that is clearly where I am wrong. I thought binary access was different again, at least that was the impression I got from the documentation I found. The documentation I've found about direct access has not been the best, it seems a lesser used feature.
That gist.github.com looks like a good idea. I'll try and pick out the bit I'm using.
I looked at this a bit more, formatted direct access isn't binary (unformatted is) - and in the case of formatted, RECL depends on size needed by your format length in characters..
If you're writing out integers with a format of I5, the record len is 5 bytes because the record is read as 5 characters, including padding.
So if I have an output file with the contents:
[code] 1 2 3 4 5 6 7 8 9 10[/code]and I want to read record 6, I need:
[code] INTEGER :: iOPEN(2, FILE='test.dat', ACCESS='DIRECT', RECL=5, FORM='FORMATTED') READ( 2, '(I5)', REC= 6 ) i[/code]
If you were dealing with unformatted direct access, the RECL would just be the size of the integer kind.
If you want to post up a snippet of your output file, I can try to read it.. Basically, you just need to make sure each integer you write with bash has a fixed width padded by leading spaces - so you need to know the max integer you'll be outputting - you can always just make it huge.. Then set the length in the RECL and FMT values.
-
• #2253
Hmmm, I like the look of the avids (the 6 especially), but all the reviews I've read have said they're a nightmare for squealing. But then again an equal number of people say the same thing about the Tektro Oryxs. The Tektro CR520/CR570s (with an upgrade to swiss stop pads) seem like they might be an alternative...
-
• #2254
what are the top 5 things to do in Berlin in 5 days?
There's a whole thread on Berlin. Great city, you'll want to do far more than 5 things! -
• #2255
ottbot Thanks a million that makes a lot more sense! I read sever al webpages on this and never found anything about the difference in RECL between formatted and unformatted. Do you have a link?
My shell script just dose
[code]
echo $i >> file.dat
[/code]
where "i" is between 0 and 9 so only ever one character long nd the file looks like this for example
[code]
1
5
2
2
9
3
4
[/code]so it looks like I should beable to do a formatted read with RECL=1 and then pick out the record I want.
-
• #2256
My mistake just looked it up .NET 3.0 was included with Vista not 3.5....
Anyway, it was for a server and after much wrangling I've fixed the bastard thing.
-
• #2257
ottbot Thanks a million that makes a lot more sense! I read sever al webpages on this and never found anything about the difference in RECL between formatted and unformatted. Do you have a link?
My shell script just dose
[code]
echo $i >> file.dat
[/code]
where "i" is between 0 and 9 so only ever one character long nd the file looks like this for example
[code]
1
5
2
2
9
3
4
[/code]so it looks like I should beable to do a formatted read with RECL=1 and then pick out the record I want.
Found that bit about formatted direct i/o here: http://docs.sun.com/source/819-3685/2_io.html
You have a small kink due the newlines in your file.. You just have to adjust your record size and format to account for it.. This program will read the first nine records:
[code] PROGRAM reader
INTEGER :: a, i CHARACTER*1 :: nl OPEN(2, FILE='file.dat', ACCESS='DIRECT', RECL=2, FORM='FORMATTED') DO i=1, 9 READ( 2, '(I1,A)', REC= i ) a, nl WRITE(*,*) 'record ', i, ' is ', a ENDDO END PROGRAM[/code]
Hope you get it sorted - fortran can be really esoteric, especially when dealing with code written in the 80's.. does my head in..
-
• #2258
I looked at this a bit more, formatted direct access isn't binary (unformatted is) - and in the case of formatted, RECL depends on size needed by your format length in characters..
If you're writing out integers with a format of I5, the record len is 5 bytes because the record is read as 5 characters, including padding.
So if I have an output file with the contents:
[code] 1 2 3 4 5 6 7 8 9 10[/code]and I want to read record 6, I need:
[code] INTEGER :: iOPEN(2, FILE='test.dat', ACCESS='DIRECT', RECL=5, FORM='FORMATTED') READ( 2, '(I5)', REC= 6 ) i[/code]
If you were dealing with unformatted direct access, the RECL would just be the size of the integer kind.
If you want to post up a snippet of your output file, I can try to read it.. Basically, you just need to make sure each integer you write with bash has a fixed width padded by leading spaces - so you need to know the max integer you'll be outputting - you can always just make it huge.. Then set the length in the RECL and FMT values.
Yep that works!!! So simple. Thanks a million make my life so much easier.
-
• #2259
Found that bit about formatted direct i/o here: http://docs.sun.com/source/819-3685/2_io.html
You have a small kink due the newlines in your file.. You just have to adjust your record size and format to account for it.. This program will read the first nine records:
Thanks, yep I read somewhere that new line counts for two bytes. So it's food to see what it counts for on a formatted situation thanks.
[code] PROGRAM reader
INTEGER :: a, i CHARACTER*1 :: nl OPEN(2, FILE='file.dat', ACCESS='DIRECT', RECL=2, FORM='FORMATTED') DO i=1, 9 READ( 2, '(I1,A)', REC= i ) a, nl WRITE(*,*) 'record ', i, ' is ', a ENDDO END PROGRAM[/code]
Hope you get it sorted - fortran can be really esoteric, especially when dealing with code written in the 80's.. does my head in..
Tell me about it. Trying to do simple things can be a right PITA!
-
• #2260
What happens to all the socks? They literally just disappear. To try and tackle the problem, 3 weeks ago I bought 10 pairs of identical socks.. I'm down to about 8 of these socks altogether now.. plus the assortment of non-matching socks I already had, naturally
just what the hell happens to these socks?
-
• #2261
I find a lot of socks get lost on the floor. I mean, I tendt to take socks off when I get in the house. I also have a weird thing where I cant have meal with socks on.
So they usually end up on the floor, under the table, under the sofa etc.
-
• #2262
fucking animals
-
• #2263
yeah, i usually just take them off when I take my shoes off. Actually, I usually take all my clothes off upon entering the flat, unless there's guests, then it's shorts and t-shirt
I just hate wearing trousers and socks in a hot flat, damn.
-
• #2264
holy shit, I just found 4 new socks tucked inside 2 pairs of trainers, under the sofa
top tip there DFP, thanks
-
• #2265
-
• #2266
what tight, as in you wont buy him a pint back...actually
would Jesus buy you a pint? -
• #2267
Tight, like this:
-
• #2268
ahhhhhhhhhhh! :)
-
• #2269
Since when has hamsandwich had tattoos?
And why is 'tattoo' mis-spelled?
-
• #2270
^^^
-
• #2271
-
• #2272
^Is that a question? No. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
• #2273
Would "weahaveanswers.com" not make more sense?
-
• #2274
molymods. is there an online version?
i want to draw two amino acids joined by a peptide bond, with colours. -
• #2275
not really the same thing, but ChemSketch?
what are the top 5 things to do in Berlin in 5 days?