read compress file in Unix env. 
Author Message
 read compress file in Unix env.

Hi netters :

   How to read a compress file in fortran without using system command

   It must be portable . Dose it mean that I must get the uncompress

   fortran source code ? Is there exist such source ?

    Thanx  :)

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                       __
                      |_   ==  _ _   _2               H.C.Chen
                      |__     | | | |_
   -           __

---   _________]_[__/_>________    ______------

    =\_/ __ \_\_______|_/ __ \__D        ------
________(__)_____________(__)____              \-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                    Dep. Phys.    National Central Unv. Taiwan
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Wed, 03 Apr 1996 09:03:03 GMT  
 read compress file in Unix env.

      How to read a compress file in fortran without using system command
      It must be portable . Dose it mean that I must get the uncompress
      fortran source code ? Is there exist such source ?

I'm not aware of a Fortran implementation of the uncompression
algorithm of any of the popular compression formats (compress, gzip,
zip, pkzip, whatever), but perhaps someone else is and will post an
ftp location or something.

If you need FORTRAN-77-standard-conforming code that can (portably) read
a compressed file and uncompress it either "on the fly" or into another
file, you might well have to write it yourself.  First, however, you
should determine whether you can write just the code that can read
the compressed file and ensure that, no matter what the byte values in
the file, your code can reconstruct them exactly as they appear in the
original file.  I generally pay little attention to runtime I/O issues
in Fortran (since, for now, my compiler uses the existing f2c libraries
for its runtime support), but as I recall, FORTRAN 77 doesn't provide
the same kind of file-reading capability as C, that is, a way of saying
"just get me the next N bytes of the file without regard to formatting,
record sizes, or whatever".

If you _can_ write a portable program that reads a compressed file and
gets every single byte in it "right", in order, and prove that it works
on a wide range of systems (big- and little-endian, UNIX and non-UNIX OSes,
basically any fairly popular system that has the kind of uncompressed
file you want to read), _then_ you have a good starting-point.  (You might
have to write a test program in C that compares some kind of portable
output of your Fortran program representing the byte-by-byte content
it read from the compressed file with the actual compressed file to do
the testing on various systems.)

However, if you don't do the above for any of the following reasons:

    -  FORTRAN 77 does not provide a portable way to read every byte
       from a compressed (raw binary-byte) file

    -  Fortran implementations on the systems you care about don't
       provide a uniform way to read every byte from a compressed file

    -  You don't have the time

    -  You don't have the energy

    -  You don't have the knowledge

    -  You don't have the money to hire me (or someone else, conceivably :-)

Then I suggest you shouldn't undertake the far harder task of writing
a "portable" uncompress.  After all, if the code can't be 100% portable,
and you have to resort to calling a C function to do some critical
aspect of the job (say, reading the file byte-by-byte, or allocating
heap memory, or whatever), you might as well just have that C function
do the uncompression job itself.
--





Tue, 02 Apr 1996 18:06:33 GMT  
 read compress file in Unix env.

Quote:

>hen) writes:

>      How to read a compress file in fortran without using system command
>      It must be portable . Dose it mean that I must get the uncompress
>      fortran source code ? Is there exist such source ?

>I'm not aware of a Fortran implementation of the uncompression
>algorithm of any of the popular compression formats (compress, gzip,
>zip, pkzip, whatever), but perhaps someone else is and will post an
>ftp location or something.

>   ... lots of actually very useful stuff deleted to save space...




An alternative which I use is to live the unix philosophy and just
let zcat (or gcat or gzcat or whatever) do the uncompression outside
your program and pipe the results into your fortran program:

        zcat file.Z | myfortranprogram

If the input file is ascii, no problem... just read from unit 5
("standard input").  If the input is binary, for Suns at least,
it is not difficult to write (in C) a _very_ tiny piece of code
which you can call as a function from within your fortran code
which will let you read arbitrary binary data from standard-input
within your fortran program.  Or write arbitrary binary data to
standard output for that matter...  leaving you with a fortran
code that has the look and feel of any other program in a unix
pipeline.  They'll never know the difference...   If you're
interested, I can provide the code.  It's only been tested on
Suns so far however so the (relevant!) issues of portability
described in the original reply remain.

 +----------------------------------------------------+

 |     Naval Research Laboratory, Code 7323           |
 |     Stennis Space Center, MS 39529-5004            |
 |     Telephone: (601)688-5588  FAX: (601)688-4759   |
 +----------------------------------------------------+
--
 +----------------------------------------------------+

 |     Naval Research Laboratory, Code 7323           |
 |     Stennis Space Center, MS 39529-5004            |
 |     Telephone: (601)688-5588  FAX: (601)688-4759   |
 +----------------------------------------------------+



Wed, 03 Apr 1996 06:24:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. UNIX Compressed Files From A PC

2. can't read env(DISPLAY) from regexp with $env(DISPLAY)

3. Prg to read compressed files

4. Reading compressed files

5. Reading compressed files

6. subroutine to read *.Z (compressed) files directly?

7. squeak, source files, change files, merging, compressing

8. ZipFolders and Zip compressed filesystems (WAS: Re: Unix and ease of use )

9. Can REALBASIC read and write UNIX/DOS data files

10. MF COBOL (unix) problem ( reading in file )

11. Reading Windows Binary File in MIPSPro Fortran90 on Unix

12. reading unix files from NT using SSH2

 

 
Powered by phpBB® Forum Software