Re: Fortran to read 16 or 32 bit binary files
- From: "robin" <robin_v@xxxxxxxxxxx>
- Date: Tue, 17 Nov 2009 08:52:39 GMT
<pradeep.bhattad@xxxxxxxxx> wrote in message news:b89c4858-29b4-4f1c-89a0-8629b14f0120@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| Hi Everyone
| I use XLF95 compiler on UNIX operating system. I am able to read and
| write binary files successfully using following piece of code.
|
| PROGRAM TEST
| IMPLICIT NONE
| CHARACTER(1)::B
| INTEGER::MAT(100),I
|
| ! To Read 8 bit Binary Files
| OPEN(UNIT=1,FILE='file_read.bin',FORM='UNFORMATTED',ACCESS='STREAM')
| DO I=1,100
| READ(1) B
| MAT(I)=ICHAR(B)
| ENDDO
| CLOSE(1)
|
| ! To Write 8 bit Binary Files
| OPEN
| (UNIT=1,FILE='file_write.bin',FORM='UNFORMATTED',ACCESS='STREAM')
| DO I=1,50
| WRITE(1) CHAR(MAT(I))
| ENDDO
| CLOSE
| (1)
|
| STOP
| END PROGRAM TEST
|
|
| However i can read and write integer values between 0-255 (8 bit or
| 2^8). I there a way to read / write 16 or 32 bit integer values?
I guess that it depends on whether you want to process arbitrary
binary files, or whether you just want to read and write
32-bit integers (and other things such as REALs, etc.
So, which is it?
.
- References:
- Fortran to read 16 or 32 bit binary files
- From: pradeep.bhattad@xxxxxxxxx
- Fortran to read 16 or 32 bit binary files
- Prev by Date: Re: Tutorial, Compiler and Graphic/Diagram Library
- Next by Date: Re: Random number generators
- Previous by thread: Re: Fortran to read 16 or 32 bit binary files
- Next by thread: ﻬஐ ﻬஐ 2009 Cheap price *** Nike shox with high quality at website: www.fjrjtrade.com <***>
- Index(es):