Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://www.astro.louisville.edu/software/sbig/archive/xmccd-4.1/xmccd-4.1e/libcfitsio/libcfitsio-3.310/fitsio.ps
Äàòà èçìåíåíèÿ: Wed Jul 18 21:53:58 2012
Äàòà èíäåêñèðîâàíèÿ: Thu Feb 27 22:50:38 2014
Êîäèðîâêà: IBM-866

Ïîèñêîâûå ñëîâà: meteor shower
FITSIO User's Guide
A Subroutine Interface to FITS Format Files
for Fortran Programmers
Version 3.0
HEASARC
Code 662
Goddard Space Flight Center
Greenbelt, MD 20771
USA
May 2011

ii

Contents
1 Introduction 1
2 Creating FITSIO/CFITSIO 3
2.1 Building the Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Testing the Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Linking Programs with FITSIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4 Getting Started with FITSIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5 Example Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6 Legal Stu# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 A FITS Primer 13
4 FITSIO Conventions and Guidelines 15
4.1 CFITSIO Size Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 Multiple Access to the Same FITS File . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.3 Current Header Data Unit (CHDU) . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.4 Subroutine Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.5 Subroutine Families and Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.6 Implicit Data Type Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.7 Data Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.8 Error Status Values and the Error Message Stack . . . . . . . . . . . . . . . . . . . . 18
4.9 VariableíLength Array Facility in Binary Tables . . . . . . . . . . . . . . . . . . . . . 19
4.10 Support for IEEE Special Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.11 When the Final Size of the FITS HDU is Unknown . . . . . . . . . . . . . . . . . . . 21
4.12 Local FITS Conventions supported by FITSIO . . . . . . . . . . . . . . . . . . . . . 21
iii

iv CONTENTS
4.12.1 Support for Long String Keyword Values. . . . . . . . . . . . . . . . . . . . . 21
4.12.2 Arrays of FixedíLength Strings in Binary Tables . . . . . . . . . . . . . . . . 22
4.12.3 Keyword Units Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.12.4 HIERARCH Convention for Extended Keyword Names . . . . . . . . . . . . 23
4.13 Optimizing Code for Maximum Processing Speed . . . . . . . . . . . . . . . . . . . . 24
4.13.1 Background Information: How CFITSIO Manages Data I/O . . . . . . . . . 25
4.13.2 Optimization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5 Basic Interface Routines 29
5.1 FITSIO Error Status Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.2 File I/O Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.3 Keyword I/O Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.4 Data I/O Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6 Advanced Interface Subroutines 35
6.1 FITS File Open and Close Subroutines: . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.2 HDUíLevel Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.3 Define or Redefine the structure of the CHDU . . . . . . . . . . . . . . . . . . . . . 41
6.4 FITS Header I/O Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.4.1 Header Space and Position Routines . . . . . . . . . . . . . . . . . . . . . . . 43
6.4.2 Read or Write Standard Header Routines . . . . . . . . . . . . . . . . . . . . 43
6.4.3 Write Keyword Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.4.4 Insert Keyword Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.4.5 Read Keyword Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.4.6 Modify Keyword Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.4.7 Update Keyword Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.4.8 Delete Keyword Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.5 Data Scaling and Undefined Pixel Parameters . . . . . . . . . . . . . . . . . . . . . 51
6.6 FITS Primary Array or IMAGE Extension I/O Subroutines . . . . . . . . . . . . . 52
6.7 FITS ASCII and Binary Table Data I/O Subroutines . . . . . . . . . . . . . . . . . . 55
6.7.1 Column Information Subroutines . . . . . . . . . . . . . . . . . . . . . . . . 55
6.7.2 LowíLevel Table Access Subroutines . . . . . . . . . . . . . . . . . . . . . . . 58
6.7.3 Edit Rows or Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
6.7.4 Read and Write Column Data Routines . . . . . . . . . . . . . . . . . . . . . 60

CONTENTS v
6.8 Row Selection and Calculator Routines . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.9 Celestial Coordinate System Subroutines . . . . . . . . . . . . . . . . . . . . . . . . 65
6.10 File Checksum Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.11 Date and Time Utility Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.12 General Utility Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7 The CFITSIO Iterator Function 75
8 Extended File Name Syntax 77
8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
8.2 Filetype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.2.1 Notes about HTTP proxy servers . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.2.2 Notes about the stream filetype driver . . . . . . . . . . . . . . . . . . . . . . 81
8.2.3 Notes about the gsiftp filetype . . . . . . . . . . . . . . . . . . . . . . . . . . 82
8.2.4 Notes about the root filetype . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
8.2.5 Notes about the shmem filetype: . . . . . . . . . . . . . . . . . . . . . . . . . 84
8.3 Base Filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8.4 Output File Name when Opening an Existing File . . . . . . . . . . . . . . . . . . . 86
8.5 Template File Name when Creating a New File . . . . . . . . . . . . . . . . . . . . . 88
8.6 Image TileíCompression Specification . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.7 HDU Location Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8.8 Image Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.9 Image Transform Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
8.10 Column and Keyword Filtering Specification . . . . . . . . . . . . . . . . . . . . . . 92
8.11 Row Filtering Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.11.1 General Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.11.2 Bit Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.11.3 Vector Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8.11.4 Good Time Interval Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.11.5 Spatial Region Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.11.6 Example Row Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.12 Binning or Histogramming Specification . . . . . . . . . . . . . . . . . . . . . . . . . 104
9 Template Files 107

vi CONTENTS
9.1 Detailed Template Line Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.2 Autoíindexing of Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.3 Template Parser Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
9.4 Formal Template Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
9.5 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.6 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
10 Summary of all FITSIO UseríInterface Subroutines 113
11 Parameter Definitions 121
12 FITSIO Error Status Codes 127

Chapter 1
Introduction
This document describes the Fortranícallable subroutine interface that is provided as part of the
CFITSIO library (which is written in ANSI C). This is a companion document to the CFITSIO
User's Guide which should be consulted for further information about the underlying CFITSIO
library. In the remainder of this document, the terms FITSIO and CFITSIO are interchangeable
and refer to the same library.
FITSIO/CFITSIO is a machineíindependent library of routines for reading and writing data files
in the FITS (Flexible Image Transport System) data format. It can also read IRAF format image
files and raw binary data arrays by converting them on the fly into a virtual FITS format file.
This library was written to provide a powerful yet simple interface for accessing FITS files which
will run on most commonly used computers and workstations. FITSIO supports all the features
described in the o#cial NOST definition of the FITS format and can read and write all the currently
defined types of extensions, including ASCII tables (TABLE), Binary tables (BINTABLE) and
IMAGE extensions. The FITSIO subroutines insulate the programmer from having to deal with
the complicated formatting details in the FITS file, however, it is assumed that users have a general
knowledge about the structure and usage of FITS files.
The CFITSIO package was initially developed by the HEASARC (High Energy Astrophysics Science
Archive Research Center) at the NASA Goddard Space Flight Center to convert various existing
and newly acquired astronomical data sets into FITS format and to further analyze data already in
FITS format. New features continue to be added to CFITSIO in large part due to contributions of
ideas or actual code from users of the package. The Integral Science Data Center in Switzerland,
and the XMM/ESTEC project in The Netherlands made especially significant contributions that
resulted in many of the new features that appeared in v2.0 of CFITSIO.
The latest version of the CFITSIO source code, documentation, and example programs are available
on the WorldíWide Web or via anonymous ftp from:
http://heasarc.gsfc.nasa.gov/fitsio
ftp://legacy.gsfc.nasa.gov/software/fitsio/c
1

2 CHAPTER 1. INTRODUCTION
Any questions, bug reports, or suggested enhancements related to the CFITSIO package should be
sent to the primary author:
Dr. William Pence Telephone: (301) 286í4599
HEASARC, Code 662 Eímail: William.D.Pence@nasa.gov
NASA/Goddard Space Flight Center
Greenbelt, MD 20771, USA
This User's Guide assumes that readers already have a general understanding of the definition
and structure of FITS format files. Further information about FITS formats is available from the
FITS Support O#ce at http://fits.gsfc.nasa.gov. In particular, the 'NOST FITS Standard'
gives the authoritative definition of the FITS data format, and the `FITS User's Guide' provides
additional historical background and practical advice on using FITS files.
CFITSIO users may also be interested in the FTOOLS package of programs that can be used to
manipulate and analyze FITS format files. Information about FTOOLS can be obtained on the
Web or via anonymous ftp at:
http://heasarc.gsfc.nasa.gov/ftools
ftp://legacy.gsfc.nasa.gov/software/ftools/release

Chapter 2
Creating FITSIO/CFITSIO
2.1 Building the Library
To use the FITSIO subroutines one must first build the CFITSIO library, which requires a C
compiler. gcc is ideal, or most other ANSIíC compilers will also work. The CFITSIO code is
contained in about 40 C source files (*.c) and header files (*.h). On VAX/VMS systems 2 assemblyí
code files (vmsieeed.mar and vmsieeer.mar) are also needed.
The Fortran interface subroutines to the C CFITSIO routines are located in the f77 wrap1.c,
through f77 wrap4.c files. These are relatively simple 'wrappers' that translate the arguments in the
Fortran subroutine into the appropriate format for the corresponding C routine. This translation is
performed transparently to the user by a set of C macros located in the cfortran.h file. Unfortunately
cfortran.h does not support every combination of C and Fortran compilers so the Fortran interface
is not supported on all platforms. (see further notes below).
A standard combination of C and Fortran compilers will be assumed by default, but one may also
specify a particular Fortran compiler by doing:
> setenv CFLAGS íDcompilerName=1
(where 'compilerName' is the name of the compiler) before running the configure command. The
currently recognized compiler names are:
g77Fortran
IBMR2Fortran
CLIPPERFortran
pgiFortran
NAGf90Fortran
f2cFortran
hpuxFortran
apolloFortran
sunFortran
CRAYFortran
3

4 CHAPTER 2. CREATING FITSIO/CFITSIO
mipsFortran
DECFortran
vmsFortran
CONVEXFortran
PowerStationFortran
AbsoftUNIXFortran
AbsoftProFortran
SXFortran
Alternatively, one may edit the CFLAGS line in the Makefile to add the 'íDcompilerName' flag
after running the './configure' command.
The CFITSIO library is built on Unix systems by typing:
> ./configure [ííprefix=/target/installation/path]
[ííenableísse2] [ííenableíssse3]
> make (or 'make shared')
> make install (this step is optional)
at the operating system prompt. The configure command customizes the Makefile for the particular
system, then the `make' command compiles the source files and builds the library. Type `./configure'
and not simply `configure' to ensure that the configure script in the current directory is run and
not some other systemíwide configure script. The optional 'prefix' argument to configure gives the
path to the directory where the CFITSIO library and include files should be installed via the later
'make install' command. For example,
> ./configure ííprefix=/usr1/local
will cause the 'make install' command to copy the CFITSIO libcfitsio file to /usr1/local/lib and the
necessary include files to /usr1/local/include (assuming of course that the process has permission
to write to these directories).
The optional --enableísse2 and --enableíssse3 flags will cause configure to attempt to build CFITSIO
using faster byteíswapping algorithms. See the ''Optimizing Programs'' section of this manual for
more information about these options.
By default, the Makefile will be configured to build the set of Fortranícallable wrapper routines
whose calling sequences are described later in this document.
The 'make shared' option builds a shared or dynamic version of the CFITSIO library. When using
the shared library the executable code is not copied into your program at link time and instead the
program locates the necessary library code at run time, normally through LD LIBRARY PATH or
some other method. The advantages of using a shared library are:
1. Less disk space if you build more than 1 program
2. Less memory if more than one copy of a program using the shared
library is running at the same time since the system is smart

2.1. BUILDING THE LIBRARY 5
enough to share copies of the shared library at run time.
3. Possibly easier maintenance since a new version of the shared
library can be installed without relinking all the software
that uses it (as long as the subroutine names and calling
sequences remain unchanged).
4. No runítime penalty.
The disadvantages are:
1. More hassle at runtime. You have to either build the programs
specially or have LD_LIBRARY_PATH set right.
2. There may be a slight start up penalty, depending on where you are
reading the shared library and the program from and if your CPU is
either really slow or really heavily loaded.
On HP/UX systems, the environment variable CFLAGS should be set to íAe before running coní
figure to enable ''extended ANSI'' features.
It may not be possible to statically link programs that use CFITSIO on some platforms (namely,
on Solaris 2.6) due to the network drivers (which provide FTP and HTTP access to FITS files). It
is possible to make both a dynamic and a static version of the CFITSIO library, but network file
access will not be possible using the static version.
On VAX/VMS and ALPHA/VMS systems the make gfloat.com command file may be executed to
build the cfitsio.olb object library using the default Gífloating point option for double variables.
The make dfloat.com and make ieee.com files may be used instead to build the library with the
other floating point options. Note that the getcwd function that is used in the group.c module may
require that programs using CFITSIO be linked with the ALPHA$LIBRARY:VAXCRTL.OLB
library. See the example link line in the next section of this document.
On Windows IBMíPC type platforms the situation is more complicated because of the wide variety
of Fortran compilers that are available and because of the inherent complexities of calling the
CFITSIO C routines from Fortran. Two di#erent versions of the CFITSIO dll library are available,
compiled with the Borland C++ compiler and the Microsoft Visual C++ compiler, respectively, in
the files cfitsiodll 2xxx borland.zip and cfitsiodll 3xxx vcc.zip, where '3xxx' represents the current
release number. Both these dll libraries contain a set of Fortran wrapper routines which may
be compatible with some, but probably not all, available Fortran compilers. To test if they are
compatible, compile the program testf77.f and try linking to these dll libraries. If these libraries do
not work with a particular Fortran compiler, then there are 2 possible solutions. The first solution
would be to modify the file cfortran.h for that particular combination of C and Fortran compilers,
and then rebuild the CFITSIO dll library. This will require, however, a some expertise in mixed
language programming. The other solution is to use the older v5.03 Fortraní77 implementation of
FITSIO that is still available from the FITSIO webísite. This version is no longer supported, but it
does provide the basic functions for reading and writing FITS files and should be compatible with
most Fortran compilers.
CFITSIO has currently been tested on the following platforms:
OPERATING SYSTEM COMPILER

6 CHAPTER 2. CREATING FITSIO/CFITSIO
Sun OS gcc and cc (3.0.1)
Sun Solaris gcc and cc
Silicon Graphics IRIX gcc and cc
Silicon Graphics IRIX64 MIPS
Dec Alpha OSF/1 gcc and cc
DECstation Ultrix gcc
Dec Alpha OpenVMS cc
DEC VAX/VMS gcc and cc
HPíUX gcc
IBM AIX gcc
Linux gcc
MkLinux DR3
Windows 95/98/NT Borland C++ V4.5
Windows 95/98/NT/ME/XP Microsoft/Compaq Visual C++ v5.0, v6.0
Windows 95/98/NT Cygwin gcc
OS/2 gcc + EMX
MacOS 7.1 or greater Metrowerks 10.+
CFITSIO will probably run on most other Unix platforms. Cray supercomputers are currently not
supported.
2.2 Testing the Library
The CFITSIO library should be tested by building and running the testprog.c program that is
included with the release. On Unix systems type:
% make testprog
% testprog > testprog.lis
% diff testprog.lis testprog.out
% cmp testprog.fit testprog.std
On VMS systems, (assuming cc is the name of the C compiler command), type:
$ cc testprog.c
$ link testprog, cfitsio/lib, alpha$library:vaxcrtl/lib
$ run testprog
The testprog program should produce a FITS file called `testprog.fit' that is identical to the `testí
prog.std' FITS file included with this release. The diagnostic messages (which were piped to the file
testprog.lis in the Unix example) should be identical to the listing contained in the file testprog.out.
The 'di#' and 'cmp' commands shown above should not report any di#erences in the files. (There
may be some minor formatting di#erences, such as the presence or absence of leading zeros, or 3
digit exponents in numbers, which can be ignored).
The Fortran wrappers in CFITSIO may be tested with the testf77 program. On Unix systems the
fortran compilation and link command may be called 'f77' or 'g77', depending on the system.

2.2. TESTING THE LIBRARY 7
% f77 ío testf77 testf77.f íL. ílcfitsio ílnsl ílsocket
or
% f77 íf ío testf77 testf77.f íL. ílcfitsio (under SUN O/S)
or
% f77 ío testf77 testf77.f íWl,íL. ílcfitsio ílm ílnsl ílsocket (HP/UX)
or
% g77 ío testf77 ís testf77.f ílcfitsio ílcc_dynamic ílncurses (Mac OSíX)
% testf77 > testf77.lis
% diff testf77.lis testf77.out
% cmp testf77.fit testf77.std
On machines running SUN O/S, Fortran programs must be compiled with the 'íf' option to force
double precision variables to be aligned on 8íbyte boundaries to make the fortranídeclared variables
compatible with C. A similar compiler option may be required on other platforms. Failing to use
this option may cause the program to crash on FITSIO routines that read or write double precision
variables.
On Windows platforms, linking Fortran programs with a C library often depends on the particular
compilers involved. Some users have found the following commands work when using the Intel
Fortran compiler:
ifort /libs.dll cfitsio.lib /MD testf77.f /Gm
or possibly,
ifort /libs:dll cfitsio.lib /MD /fpp /extfpp:cfortran.h,fitsio.h
/iface:cvf testf77.f
Also note that on some systems the output listing of the testf77 program may di#er slightly from
the testf77.std template if leading zeros are not printed by default before the decimal point when
using F format.
A few other utility programs are included with CFITSIO:
speed í measures the maximum throughput (in MB per second)
for writing and reading FITS files with CFITSIO
listhead í lists all the header keywords in any FITS file
fitscopy í copies any FITS file (especially useful in conjunction
with the CFITSIO's extended input filename syntax)
cookbook í a sample program that performs common read and
write operations on a FITS file.
iter_a, iter_b, iter_c í examples of the CFITSIO iterator routine

8 CHAPTER 2. CREATING FITSIO/CFITSIO
The first 4 of these utility programs can be compiled and linked by typing
% make program_name
2.3 Linking Programs with FITSIO
When linking applications software with the FITSIO library, several system libraries usually need
to be specified on the link comman Unix systems, the most reliable way to determine what libraries
are required is to type 'make testprog' and see what libraries the configure script has added. The
typical libraries that may need to be added are ílm (the math library) and ílnsl and ílsocket (needed
only for FTP and HTTP file access). These latter 2 libraries are not needed on VMS and Windows
platforms, because FTP file access is not currently supported on those platforms.
Note that when upgrading to a newer version of CFITSIO it is usually necessary to recompile, as
well as relink, the programs that use CFITSIO, because the definitions in fitsio.h often change.
2.4 Getting Started with FITSIO
In order to e#ectively use the FITSIO library as quickly as possible, it is recommended that new
users follow these steps:
1. Read the following `FITS Primer' chapter for a brief overview of the structure of FITS files.
This is especially important for users who have not previously dealt with the FITS table and image
extensions.
2. Write a simple program to read or write a FITS file using the Basic Interface routines.
3. Refer to the cookbook.f program that is included with this release for examples of routines that
perform various common FITS file operations.
4. Read Chapters 4 and 5 to become familiar with the conventions and advanced features of the
FITSIO interface.
5. Scan through the more extensive set of routines that are provided in the `Advanced Interface'.
These routines perform more specialized functions than are provided by the Basic Interface routines.
2.5 Example Program
The following listing shows an example of how to use the FITSIO routines in a Fortran program.
Refer to the cookbook.f program that is included with the FITSIO distribution for examples of
other FITS programs.
program writeimage
C Create a FITS primary array containing a 2íD image

2.5. EXAMPLE PROGRAM 9
integer status,unit,blocksize,bitpix,naxis,naxes(2)
integer i,j,group,fpixel,nelements,array(300,200)
character filename*80
logical simple,extend
status=0
C Name of the FITS file to be created:
filename='ATESTFILE.FITS'
C Get an unused Logical Unit Number to use to create the FITS file
call ftgiou(unit,status)
C create the new empty FITS file
blocksize=1
call ftinit(unit,filename,blocksize,status)
C initialize parameters about the FITS image (300 x 200 16íbit integers)
simple=.true.
bitpix=16
naxis=2
naxes(1)=300
naxes(2)=200
extend=.true.
C write the required header keywords
call ftphpr(unit,simple,bitpix,naxis,naxes,0,1,extend,status)
C initialize the values in the image with a linear ramp function
do j=1,naxes(2)
do i=1,naxes(1)
array(i,j)=i+j
end do
end do
C write the array to the FITS file
group=1
fpixel=1
nelements=naxes(1)*naxes(2)
call ftpprj(unit,group,fpixel,nelements,array,status)
C write another optional keyword to the header
call ftpkyj(unit,'EXPOSURE',1500,'Total Exposure Time',status)
C close the file and free the unit number
call ftclos(unit, status)
call ftfiou(unit, status)

10 CHAPTER 2. CREATING FITSIO/CFITSIO
end
2.6 Legal Stu#
Copyright (Unpublished--all rights reserved under the copyright laws of the United States), U.S.
Government as represented by the Administrator of the National Aeronautics and Space Adminisí
tration. No copyright is claimed in the United States under Title 17, U.S. Code.
Permission to freely use, copy, modify, and distribute this software and its documentation without
fee is hereby granted, provided that this copyright notice and disclaimer of warranty appears in all
copies.
DISCLAIMER:
THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EIí
THER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO,
ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURí
POSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE DOCí
UMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT THE
SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NASA BE LIABLE FOR ANY
DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR CONí
SEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN ANY WAY CONí
NECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, CONí
TRACT, TORT , OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERí
SONS OR PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED
FROM, OR AROSE OUT OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERí
VICES PROVIDED HEREUNDER.''
2.7 Acknowledgments
The development of many of the powerful features in CFITSIO was made possible through collabí
orations with many people or organizations from around the world. The following, in particular,
have made especially significant contributions:
Programmers from the Integral Science Data Center, Switzerland (namely, Jurek Borkowski, Bruce
O'Neel, and Don Jennings), designed the concept for the plugíin I/O drivers that was introduced
with CFITSIO 2.0. The use of `drivers' greatly simplified the lowílevel I/O, which in turn made
other new features in CFITSIO (e.g., support for compressed FITS files and support for IRAF
format image files) much easier to implement. Jurek Borkowski wrote the Shared Memory driver,
and Bruce O'Neel wrote the drivers for accessing FITS files over the network using the FTP, HTTP,
and ROOT protocols.
The ISDC also provided the template parsing routines (written by Jurek Borkowski) and the
hierarchical grouping routines (written by Don Jennings). The ISDC DAL (Data Access Layer)
routines are layered on top of CFITSIO and make extensive use of these features.

2.7. ACKNOWLEDGMENTS 11
Uwe Lammers (XMM/ESA/ESTEC, The Netherlands) designed the highíperformance lexical parsí
ing algorithm that is used to do onítheífly filtering of FITS tables. This algorithm essentially
preícompiles the userísupplied selection expression into a form that can be rapidly evaluated for
each row. Peter Wilson (RSTX, NASA/GSFC) then wrote the parsing routines used by CFITSIO
based on Lammers' design, combined with other techniques such as the CFITSIO iterator routine
to further enhance the data processing throughput. This e#ort also benefited from a much earlier
lexical parsing routine that was developed by Kent Blackburn (NASA/GSFC). More recently, Craig
Markwardt (NASA/GSFC) implemented additional functions (median, average, stddev) and other
enhancements to the lexical parser.
The CFITSIO iterator function is loosely based on similar ideas developed for the XMM Data
Access Layer.
Peter Wilson (RSTX, NASA/GSFC) wrote the complete set of Fortranícallable wrappers for all the
CFITSIO routines, which in turn rely on the CFORTRAN macro developed by Burkhard Burow.
The syntax used by CFITSIO for filtering or binning input FITS files is based on ideas developed
for the AXAF Science Center Data Model by Jonathan McDowell, Antonella Fruscione, Aneta
Siemiginowska and Bill Joye. See http://heasarc.gsfc.nasa.gov/docs/journal/axaf7.html for further
description of the AXAF Data Model.
The file decompression code were taken directly from the gzip (GNU zip) program developed by
Jeaníloup Gailly and others.
Doug Mink, SAO, provided the routines for converting IRAF format images into FITS format.
Martin Reinecke (Max Planck Institute, Garching)) provided the modifications to cfortran.h that
are necessary to support 64íbit integer values when calling C routines from fortran programs. The
cfortran.h macros were originally developed by Burkhard Burow (CERN).
Julian Taylor (ESO, Garching) provided the fast byteíswapping algorithms that use the SSE2 an