public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* A question about g77's OPEN & WRITE
@ 2002-11-03  5:41 Zhong Wang
  2002-11-03 10:45 ` Toon Moene
  0 siblings, 1 reply; 2+ messages in thread
From: Zhong Wang @ 2002-11-03  5:41 UTC (permalink / raw)
  To: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312, Size: 1227 bytes --]

Hello, everybody

  I am using g77 for programing now. But I found that
g77 is somewhat 
different to Visual Fortran in I/O.

  In visual fortran, the following code is legal:
>>>>>
  REAL a(10)
  OPEN(10,file='aaa.dat',form='binary')
  WRITE(10)a
  CLOSE(10)
<<<<<
  You can see that in file aaa.dat there's not
anything between the integer 
and real numbers.
  But in g77, if I use:
>>>>>
  REAL a(10)
  OPEN(10,file='aaa.dat',form='unformatted')
  WRITE(10)a
  CLOSE(10)
<<<<<
  With "hexedit aaa.dat", you can find there's a
length value before and after 
each record. You know, sometimes we have to make more
efforts to deal with 
those length values when we use other softwares to
open these data files. For 
example, when I use matlab to open the file, I have to
read off those length 
values. It's very convinient.

  Can you recommend me a possible method with g77 to
generate data file which 
contains no extra bytes in it? Or can the developers
add some new features 
like form='direct' to g77?

  Thank you very much,
  Yours,
  mili


_________________________________________________________
Do You Yahoo!? 
"ÊÇIT¾«Ó¢Âð£¿Ð¡ÊÔÅ£µ¶»ñʱÉд󽱣¡"
http://cn.promo.yahoo.com/cgi-bin/udb/u

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: A question about g77's OPEN & WRITE
  2002-11-03  5:41 A question about g77's OPEN & WRITE Zhong Wang
@ 2002-11-03 10:45 ` Toon Moene
  0 siblings, 0 replies; 2+ messages in thread
From: Toon Moene @ 2002-11-03 10:45 UTC (permalink / raw)
  To: Zhong Wang; +Cc: gcc-help

Zhong Wang wrote:

>   I am using g77 for programing now. But I found that
> g77 is somewhat 
> different to Visual Fortran in I/O.
> 
>   In visual fortran, the following code is legal:
> 
>   REAL a(10)
>   OPEN(10,file='aaa.dat',form='binary')
>   WRITE(10)a
>   CLOSE(10)
> <<<<<
>   You can see that in file aaa.dat there's not
> anything between the integer 
> and real numbers.
>   But in g77, if I use:
> 
>   REAL a(10)
>   OPEN(10,file='aaa.dat',form='unformatted')
>   WRITE(10)a
>   CLOSE(10)
> <<<<<
>   With "hexedit aaa.dat", you can find there's a
> length value before and after 
> each record. You know, sometimes we have to make more
> efforts to deal with 
> those length values when we use other softwares to
> open these data files. For 
> example, when I use matlab to open the file, I have to
> read off those length 
> values. It's very convinient.
> 
>   Can you recommend me a possible method with g77 to
> generate data file which 
> contains no extra bytes in it? Or can the developers
> add some new features 
> like form='direct' to g77?

No, there's no method to get rid of the record lenghts in an unformatted
file when using g77.  However, if all the records in your file are the
same length, you could write a "direct access" file, by doing the writes
thusly:

      REAL A(10)
      OPEN(...,ACCESS='DIRECT',RECL=....)
      DO I = 1, N
         ... fill A
         WRITE(...,REC=I) A
      ENDDO
      CLOSE(...)

This will give you a file with N records of length 10 (32-bit words)
without any other data in it.

Hope this helps,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-03 18:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-03  5:41 A question about g77's OPEN & WRITE Zhong Wang
2002-11-03 10:45 ` Toon Moene

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).