next up previous
Next: Defining Output Formats
Up: SETTING UP FOR FORMAT CONVERSION
Previous: Accessing Sub-structures Within Foreign Data Files

Writing Format Conversion Utilities   

In the previous section, the utilities ``fitsin'' and ``fitsout'' were presumed to exist to perform the necessary conversions. For commonly encountered formats, this is likely to be the case, and the CONVERT package (SUN/55) and other likely sources of conversion utilities should be investigated before embarking on writing your own. Don't forget that you can often adapt existing utilities (including those provided by the operating system) by combining them into a suitable script.

If you do need to write your own format conversion utilities from scratch, then the rules that apply are very few. It should obviously be possible to execute your utility by invoking a suitable command which includes the names of the input and output datasets. Your utility will also need to be able to interpret the NDF name it receives. This means that if you are writing a program, it should probably use the NDF library to access the NDF data (rather than, say, HDS, which cannot necessarily interpret the compound data structure names that will occur).[*] For a template example of a conversion utility that reads data from unformatted Fortran files, see SUN/33.

As far as possible, the NDF library will attempt to ensure that the output dataset to be written by a conversion command does not already exist, by deleting it first if necessary (your conversion utility should then create it). However, it may not always be wise to depend on this. In particular, recovery from error conditions (such as failed conversions) is likely to be more robust if conversion commands are able to cope when their output datasets already exist.

Unless you are debugging, you should also arrange for conversion utilities not to write to the standard output channel, as such output will otherwise appear whenever a conversion occurs. This is not normally wanted.

Beyond this, you have complete freedom to define and implement the conversion you want to perform. This may have whatever side effects you choose, so long as it results in the production of the requested output dataset, leaves its input dataset intact and returns an appropriate status value to the NDF library (see §[*] for a discussion of error handling in conversion commands).



next up previous
Next: Defining Output Formats
Up: SETTING UP FOR FORMAT CONVERSION
Previous: Accessing Sub-structures Within Foreign Data Files


Starlink System Note 20
R.F.Warren-Smith & D.S.Berry
17th July 2000
E-mail:ussc@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils