compressed files

Dave Ciemiewicz ciemo at bananapc.wpd.sgi.com
Thu Jan 18 05:22:02 AEST 1990


In article <3339 at uceng.UC.EDU>, trohling at uceng.UC.EDU (tom rohling) writes:
> 
>      I have recently discovered the compress utility on UNIX machines and 
> it has turned out to be a wonderful way of keeping down the disk usage and
> the file transfer times on our 120GTX.  Now for the question:
> 
>      Can a compressed file be accessed through fortran (or C) much in the 
> same way that 'zcat' uncompresses the file to std out but leaves the file 
> in its compressed state?  i.e. can I read the contents of a compressed file
> from a program without having to uncompress it first?  Sort of like zcat 
> it into ram where my program can get at it without creating file out 
> of it and taking up all that space.
> 

No, FORTRAN and C do not support a zcat file type for reading or writing.
However, you should be able to use the system(3F) (FORTRAN version) or
system(3S) (C version) call to 'uncompress' the file before opening the
file:

	call system('uncompress file')

Of course, what you really want to do is create a string which has the
uncompress command and your filename in it.  My FORTRAN is too rusty
to try to illustrate the concatenation.

Just after you close the file, you may want to compress the file again:

	call system('compress file')

>      We have these rather large files (20 Meg uncompressed) we are using 
> in some CFD calculations and alot of the time there isn't enough room on 
> the disk to uncompress all the files and run the program for a while and 
> still leave enough disk space for other users.  Now I know we should just 
> forget all this and go buy another disk, but if this can be done it could 
> save alot of space for alot of people on other machines where you can't 
> 'just go buy another disk' (like a Cray where they charge you for the
> space you use).
> 

Of course, the proposal I have presented only works if you don't have all
data sets open at once; it assumes you are going to open and close them
in sequence or atleast only use a few at a time.

						--- Ciemo



More information about the Comp.sys.sgi mailing list