Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extra bytes in OSX vs classic binaries



Richard, et al

I too tried the access='direct',recl=1 approach with g77-3.5, but without
success. For my application, each g77 output file to the post-processor is
written with a character string identifier and the format (e. g. ieeei4r8),
before writing output that is a mix of characters, integers and reals. That
among other things, confuses the issue. It looks like I'll stay with ASCII,
at least it works. One alternative is to write a C routine for that
relatively short portion of the code that writes the output to the
post-processor.

What is apparently needed is an access='C' option on the Fortran open file
statement, but since g77 is already a dinosaur, although a lively one, I
really doubt that will happen.

Thanks to all.

Joe Koski

on 6/26/04 12:15 AM, SeaSoft Systems at email@hidden wrote:

> Joe:
>
> I tried the direct access method and it works fine (naturally, the
> byte-by-byte method suggested immediately below is comparatively slow
> for large files, if that is an issue). I found the "direct access"
> solution (also offered by Drew and Eric; a pox on Digest Mode! :) by
> Googling after getting a heads up on the basic problem from Jeff
> Jonas and Roy Mendelssohn. Here is Clive Page's take on the issue,
> found at
>
> http://www.dbforums.com/archive/index.php/t-951804.html:
>
> ====================================
> In article <bn0rpr$dcr$email@hidden>,
> Rob McDonald <email@hidden> wrote:
>> Is there any way to get g77 to read/write files opened with the "
>> form='binary' " flag? If not, and if there are any g77 developers
>> listening, is there any chance that this capability will be added?
>
> What you may be able to do (sorry if anyone else has already
> suggested this) is to open
> the file ACCESS='DIRECT', FORM='FORMATTED', RECL=1
>
> This means each character in the file turns into one record. You can
> then do a formatted
> direct access read into a character array and get individual bytes,
> something like this:
>
> CHARACTER MYARRAY(somesize)
> READ(UNIT=myunit, FMT='(A)', REC=nrec) (MYARRAY(I),I=1,something)
>
> The rules for formatted direct access say that you read from
> sucessive records when you
> run out of items in the current record, so you don't need one READ
> statement per byte.
>
> --
> Clive Page
> ====================================
>
>
> Many thanks to all who contributed to this thread,
>
> Richard Hartman
>
>
>> From: Joe Koski <email@hidden>
>>
>> on 6/25/04 3:55 PM, Drew McCormack at email@hidden wrote:
>>
>>>
>>> On Jun 25, 2004, at 5:47 PM, Joe Koski wrote:
>>>
>>>> Please excuse me for piggy-backing, but I have a similar issue for
>>>> which
>>>> list members may know the answer.
>>>>
>>>> I have a Fortran 77 code that I compile with g77-3.5. The program can
>>>> write
>>>> binary output files for reading by a post-processor (GMV). The
>>>> post-processor is C code, probably compiled with gcc. Apparently the
>>>> g77
>>>> binary file format differs from the gcc binary file format as
>>>> described in
>>>> this thread. As a result the C language post-processor can't read the
>>>> g77
>>>> binary output, and I'm forced to use ASCII instead. As far as I know,
>>>> the
>>>> post-processor won't read .hdf files, either.
>>>>
>>>> My question: are there compiler switches for g77 that will allow the
>>>> g77
>>>> binary output files to be compatible with gcc, similar to the -N3
>>>> Absoft
>>>> option described below? Any tricks? How about running the particular
>>>> g77
>>>> output routine through f2c and then compiling it with gcc?
>>>>
>>> One option is to write the data to a fortran direct access file, with a
>>> record length of 1. This is basically the same as writing in C. No
>>> extra record information will appear in the file, only the data you
>>> write.
>>>
>>> Drew
>>>
>> Nice trick! If it works, I owe you the network equivalent of a beer. I'll
>> give it a try and report back to the list.
>>
>> Joe Koski
_______________________________________________
fortran-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/fortran-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Extra bytes in OSX vs classic binaries (From: SeaSoft Systems <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.