Previous: Machine Specific Versions
Up: Making the FITSIO Library
Previous Page: Machine Specific Versions
Next Page: Basic FITSIO Conventions

The IRAF SPP Compatible Version of FITSIO

The original version of FITSIO was written in Fortran and uses Fortran read and write statements to access the FITS files. Later it became desirable to be able to use the FITSIO interface within the IRAF environment, therefore, an IRAF compatible version of FITSIO was developed in collaboration with Doug Tody at NOAO. This version of FITSIO uses the IRAF VOS (Virtual Operating System) file I/O calls to access the FITS files rather than using Fortran I/O,

The following source files are needed to build the IRAF compatible version of FITSIO:

fitsio.for  - The Fortran source code for the main body of FITSIO subroutines
fitsio.h    - The SPP include file, used by fitspp.x and fitssppb.x
fitsspp.com - The SPP common block used by fitsspp.x
fitsspp.x   - The low-level FITSIO subroutines, written in SPP
fitssppb.x  - The top-level SPP interface to FITSIO
mkpkg       - a sample make file which builds the FITSIO library
              (this mkpkg file requires the mkfort executable file
               which is supplied with IRAF)
The SPP version of FITSIO consists of 3 layers of code. At the bottom there is the fitsspp.x SPP source code which contains the IRAF-specific subroutines to read and write data to the FITS file. The middle layer of subroutines are contained in the fitsio.for file which is the same file used in every version of FITSIO. This layer is completely portable and contains no machine or environment dependencies. Finally, a thin interface layer of SPP subroutines are provided in the fitssppb.x file. This top layer of routines is provided for the convenience of SPP programmers and simply performs the conversion between SPP character variables and Fortran character strings.

A sample mkpkg file is provided which will build the FITSIO library in IRAF. This is intended as only an example. A more complete example of how to build the FITSIO library within the IRAF environment is provided in the FTOOLS package of FITS file utility software, which is also available from the HEASARC.

Once the FITSIO library has been built, IRAF programmers may then call either the SPP or the Fortran subroutine interface to FITSIO; both interfaces end up calling the same low-level SPP VOS interface routines to actually read or write the FITS files. IRAF programs written in Fortran (using either the IRAF IMFORT or the STScI F77 interface to access the IRAF VOS) can simply call the Fortran subroutine interface to FITSIO as specified in later sections of this document. From the programmer's point of view, this is no different than using a machine-specific implementation of FITSIO (e.g., when using the fitssun.for source file on a SUN workstation).

Programs written in SPP, on the otherhand, may call the SPP specific layer of FITSIO subroutines. These routines are identical to the Fortran subroutines except that the SPP subroutines have names beginning with 'fs' rather than 'ft' (e.g., 'call fsopen' rather than 'call ftopen'). The only purpose of this thin layer of SPP routines is to convert any SPP character variables into Fortran character strings before calling the corresponding FITSIO Fortran subroutine. Similarly, any character strings that are returned by the Fortran FITSIO subroutine are converted into SPP CHAR variables before being passed back to the calling SPP routine.

SPP programmers, therefore, should follow the definition of all the FITSIO interface subroutines given in this document, except that the SPP routines have names beginning with 'fs' rather than 'ft', and SPP CHAR variables should be substituted for any Fortran character string variables in the subroutine calling arguments. SPP programmers also need to be aware of the character string length definitions that are used throughout the SPP FITSIO interface as defined in the fitsio.h include file. The SPP versions of the interface routines behave identically to the Fortran versions and have exactly the same calling sequences, except for the following few exceptions:

*
FSPKNx: This family of subroutines only supports a single comment string, not an array of comment strings as in the Fortran routines.

*
FSPCLS, FSGCVS, and FSGCFS: These 3 routines all have an additional argument not present in the corresponding Fortran routines. This integer argument, DIM1, follows the character array argument and specifies the size of the 1st dimension of the 2-dimensional CHAR array, e.g.,

call fspcls(ounit, frow, felem, nelem, nulval, array, DIM1, anynul, status)

*
FSGIOU: This new subroutine has been added to the SPP interface and is not present in the Fortran FITSIO interface. It simply returns an unused file I/O unit number which may then be used as input to the fsopen or fsinit routines.

call fsgiou( iounit )



Previous: Machine Specific Versions
Up: Making the FITSIO Library
Previous Page: Machine Specific Versions
Next Page: Basic FITSIO Conventions

asterix@space.starlink
Wed Feb 16 08:18:45 GMT 1994