next up previous contents FITSIO Home
Next: 5. Basic CFITSIO Interface Up: 4. Programming Guidelines Previous: 4.12 When the Final

4.13 CFITSIO Size Limitations

CFITSIO places very 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 FITS files that may be simultaneously opened by CFITSIO is set by NMAXFILES as defined in fitsio2.h. It is currently set = 300 by default. CFITSIO will allocate about 80 * NMAXFILES bytes of memory for internal use. Note that the underlying C compiler or operating system, may have a smaller limit on the number of opened files. The C symbolic constant FOPEN_MAX is intended to define the maximum number of files that may open at once (including any other text or binary files that may be open, not just FITS files). On some systems it has been found that gcc supports a maximum of 255 opened files.

Note that opening and operating on many FITS files simultaneously in parallel may be less efficient than operating on smaller groups of files in series. CFITSIO only has NIOBUF number of internal buffers (set = 40 by default) that are used for temporary storage of the most recent data records that have been read or written in the FITS files. If the number of opened files is greater than NIOBUF, then CFITSIO may waste more time flushing and re-reading or re-writing the same records in the FITS files.

2. 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: 5. Basic CFITSIO Interface Up: 4. Programming Guidelines Previous: 4.12 When the Final