      SUBROUTINE SIMPLE( STATUS )

*  Type Definitions:
      IMPLICIT NONE

*  Global Constants:
      INCLUDE '/star/include/sae_par'
      INCLUDE 'adi_par'

*  Status:
      INTEGER            STATUS

*  Local variables:
      INTEGER            IFID              ! Input file identifier
      INTEGER            IDPTR             ! Input data array pointer
      INTEGER            NDIM              ! Number of dimensions
      INTEGER            DIMS(ADI__MXDIM)  ! Size of dimensions

      LOGICAL            DATAOK            ! Does the data exist?

*  Initialise ASTERIX
      CALL AST_INIT()

*  Obtain name of data file, and get an identifier to it
      CALL USI_ASSOC( 'INP', 'BinDS', 'UPDATE', IFID, STATUS )

*  Check that the primary data section exists
      CALL BDI_CHK( IFID, 'Data', DATAOK, STATUS )
      IF ( .NOT. DATAOK ) STATUS = SAI__ERROR

*  Get shape of input data
      CALL BDI_GETSHP( IFID, ADI__MXDIM, DIMS, NDIM, STATUS )

*  Map the data
      CALL BDI_MAPR( IFID, 'Data', 'UPDATE', IDPTR, STATUS )

*  Manipulate the data
      CALL SIMPLE_TASK( %VAL(IDPTR), NDIM, DIMS, STATUS )

*  Tidy up
      CALL AST_CLOSE()
      CALL AST_ERR( STATUS )

      END


      SUBROUTINE SIMPLE_TASK( DATA, NDIM, DIMS, STATUS )

*  Global constants:
      INCLUDE '/star/include/sae_par'

*  Status:
      INTEGER            STATUS

*  Import:
      REAL               DATA(*)           ! Linear array of data values

      INTEGER            NDIM              ! Number of dimensions
      INTEGER            DIMS(*)           ! Size of dimensions

*  Local variables:
      INTEGER            NELM              ! Number of data elements
      INTEGER            I                 ! Loop variable
*.

*  Check inherited global status
      IF ( STATUS .NE. SAI__OK ) RETURN

*  Get size of the data array
      CALL ARR_SUMDIM( NDIM, DIMS, NELM )

* Perform the task as a vector operation on the data
      DO I = 1, NELM
        DATA(I) = SQRT( DATA(I) )
      END DO

      END
