New extensions are created by calling the routine NDF_XNEW and specifying the extension name together with its HDS type and shape. For instance:
CHARACTER * ( DAT__SZLOC ) LOC ... CALL NDF_XNEW( INDF, 'IRAS', 'IRAS_EXTENSION', 0, 0, LOC, STATUS )
would create a new scalar `IRAS' extension with an HDS type of `IRAS_EXTENSION' and return a locator for it via the LOC argument. In practice, extensions will almost always be scalar HDS structures, but this routine allows for other possibilities if required. An error will result if the named extension already exists.
Once an extension structure has been created, components may be created within it and values assigned to them using HDS routines, as before. For instance, to create and assign a value of 30.5 to a real component called ANGLE in a newly-created `IRAS' extension, the following calls might be used:
CHARACTER * ( DAT__SZLOC ) LOC REAL ANGLE ... CALL NDF_XNEW( INDF, 'IRAS', 'IRAS_EXTENSION', 0, 0, LOC, STATUS ) CALL CMP_MOD( LOC, 'ANGLE', '_REAL', 0, 0, STATUS ) CALL CMP_PUT0R( LOC, 'ANGLE', 30.5, STATUS ) CALL DAT_ANNUL( LOC, STATUS )
Here, the call to CMP_MOD ensures that the required ANGLE component exists, creating it if necessary. CMP_PUT0R then assigns a value to it. The extension locator LOC must be annulled when it is no longer required, since the NDF_ system will not perform this task.
Again, this process of creating a scalar component within an NDF extension and writing a value to it is sufficiently common that a set of routines is provided to do it directly. In this case, the routines have names of the form NDF_XPT0x, where the (lower-case) ``x'' should be replaced by I, R, D, L or C, according to the type of value being written. The above operation of writing a real value into a component of an `IRAS' extension can therefore be performed with a single call to NDF_XPT0R, as follows:
CALL NDF_XPT0R( ANGLE, INDF, 'IRAS', 'ANGLE', STATUS )
As with the NDF_XGT0x routines (see
§), the NDF_XPT0x routines will
also accept a compound HDS component name, possibly including array
subscripts, as a third argument. This allows the creation of
components which are nested more deeply inside the extension, but
remember that all HDS structures lying above the new component must
already exist. When writing to an array element, the array itself
must also previously have been created.