next up previous
Next: GENERAL PROPERTIES OF NDF COMPONENTS
Up: NDF SHAPE AND SIZE INFORMATION
Previous: NDF Size

``Safe'' Dimension Sizes under Error Conditions   

A common pitfall which can affect software using the inherited status error-handling strategy employed by all the NDF_ routines (see §[*]) arises from the way in which the Fortran 77 ``adjustable array'' facility behaves.

Consider the following example, where a call to the NDF_SIZE routine is used to obtain the number of pixels in an NDF, and the returned result is then passed to another routine where it specifies the size of an adjustable array, A:

      CALL NDF_SIZE( INDF, NPIX, STATUS )
      CALL DOIT( NPIX, A, STATUS )

Normally, this will cause no problems. However, if there has been a previous error so that STATUS is no longer set to SAI__OK, then NDF_SIZE will not execute. If no further precautions were taken, the returned value of NPIX would be undefined and could easily have a value (zero, perhaps) which is invalid as an adjustable array dimension. In such cases, the application would probably terminate (i.e. crash) with a run-time error.

To prevent this happening, all NDF_ routines which return array size or dimensionality information will provide a ``safe'' value of 1 under error conditions. This applies both to the case where STATUS is set before the routine is called, as well as to the case where the NDF_ routine itself fails. This generally means that no extra precautions need to be taken to prevent run-time errors from this cause.



next up previous
Next: GENERAL PROPERTIES OF NDF COMPONENTS
Up: NDF SHAPE AND SIZE INFORMATION
Previous: NDF Size


Starlink User Note 33
R.F. Warren-Smith
11th January 2000
E-mail:rfws@star.rl.ac.uk

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