next up previous contents FITSIO Home
Next: Multiple Access to the Up: FITSIO Conventions and Guidelines Previous: FITSIO Conventions and Guidelines   Contents

CFITSIO Size Limitations

CFITSIO places few restrictions on the size of FITS files that it reads or writes. There are a few limits, however, which may affect some extreme cases:

1. The maximum number of files that may be simultaneously opened is limited to the number of internal IO buffers allocated in CFITSIO (currently 25, as defined by NIOBUF in the file fitsio2.h), or by the limit of the underlying C compiler or machine operating system, which ever is smaller. The C symbolic constant FOPEN_MAX usually defines the total number of files that may open at once (this includes any other text or binary files which may be open, not just FITS files).

2. The maximum number of extensions (HDUs) that can be read or written in a single FITS file is currently set to 1000 as defined by MAXHDU in the fitsio.h file. This value may be increased if necessary, but the access times to the later extensions in such files may become excessively long.

3. By default, CFITSIO can handle FITS files up to 2.1 GB in size (2**31 bytes). This file size limit is often imposed by 32-bit operating systems. More recently, as 64-bit operating systems become more common, an industry-wide standard (at least on Unix systems) has been developed to support larger sized files (see http://ftp.sas.com/standards/large.file/). Starting with version 2.1 of CFITSIO, larger FITS files up to 6 terabytes in size may be read and written on certain supported platforms. In order to support these larger files, CFITSIO must be compiled with the `-D_FILE_OFFSET_BITS=64' compiler flag. All programs which link to the CFITSIO library must also be compiled with this flag or must include this preprocessor definition at the start of the source code file. This causes the compiler to allocate 8-bytes instead of 4-bytes for the `off_t' datatype which is used to store file offset positions.

If CFITSIO is compiled with the -D_FILE_OFFSET_BITS=64 flag on a platform that supports large files, then it can read and write FITS files that contain up to 2**31 2880-byte FITS records, or approximately 6 terabytes in size. It is still required that the value of the NAXISn and PCOUNT keywords in each extension be within the range of a signed 4-byte integer (max value = 2,147,483,648). Thus, each dimension of an image (given by the NAXISn keywords), the total width of a table (NAXIS1 keyword), the number of rows in a table (NAXIS2 keyword), and the total size of the variable-length array heap in binary tables (PCOUNT keyword) must be less than this limit.

Currently, support for large files within CFITSIO has only been tested on the Solaris 2.6 operating system using the Sun cc compiler or gcc 2.95.2.


next up previous contents FITSIO Home
Next: Multiple Access to the Up: FITSIO Conventions and Guidelines Previous: FITSIO Conventions and Guidelines   Contents