- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am trying to write unformatted file. However, the binary file size is always 1kb. Hence, I feel it is not writing the file correctly.
What is the error in this piece of code ?
inquire(file="../coords_bin", exist=exist)
if (exist) then
open(99,file="../coords_bin",status='old',
* action='write', form='unformatted', access='seqential'
* ,position='append')
else
open(99,file="../coords_bin",status='new',action='write',
* form='unformatted',access='seqential',position='append')
end if
C! EDIT2: adding position='append' could increase the .dat file.
write(6,*), JLTYP,NOEL,NPT,COORDS(iLoadDIR) !ascii file
WRITE(99) JLTYP,NOEL,NPT,COORDS(iLoadDIR) !binary file
close(99)
open (unit=99,file='../coords_bin',access='stream',
* form="unformatted",status="OLD")
read(99), IJLTYP, IEID, INT_PT, Y0
write(6,*), 'search for:', JLTYP,NOEL,NPT ! = search for: 42 46439 1
write(6,*), 'read out:', IJLTYP, IEID, INT_PT,Y0 ! = read out: 180388626452 4295014401 -4584610301207151303 4.243991582918676E-313
When I read out, I am seeing different values. Is there a bug in my code ?
Thanks !
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
COORDS(iLoadDIR) is writing 1 element of the array. COORDS(1:iLoadDIR) would write that range or COORDS would write the whole array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrew,
Sorry for not being clear. Please see the revised. Thanks ! I intended to use only coords(iLoadDir).
In my previous version, I was not using position='append' hence, it was probably additing to the file and hence always my binary file was 1kb.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page