SUBROUTINE BDI1_MAPMQ( NARG, ARGS, OARG, STATUS )
*+
* Name:
* BDI1_MAPMQ
* Purpose:
* Service FileItemMap requests for the MaskedQuality field of BinDS
* Language:
* Starlink Fortran
* Invocation:
* CALL BDI1_MAPMQ( NARG, ARGS, OARG, STATUS )
* Description:
* Provides mapping for the 'MaskedQuality' class member of BinDS derived
* objects in HDS files.
* Arguments:
* NARG = INTEGER (given)
* Number of method arguments
* ARGS(*) = INTEGER (given)
* ADI identifier of method arguments
* OARG = INTEGER (returned)
* Output data
* STATUS = INTEGER (given and returned)
* The global status.
* Examples:
* {routine_example_text}
* {routine_example_description}
* Pitfalls:
* {pitfall_description}...
* Notes:
* {routine_notes}...
* Prior Requirements:
* {routine_prior_requirements}...
* Side Effects:
* {routine_side_effects}...
* Algorithm:
* {algorithm_description}...
* Accuracy:
* {routine_accuracy}
* Timing:
* {routine_timing}
* External Routines Used:
* {name_of_facility_or_package}:
* {routine_used}...
* Implementation Deficiencies:
* {routine_deficiencies}...
* References:
* BDI Subroutine Guide : http://www.sr.bham.ac.uk/asterix-docs/Programmer/Guides/bdi.html
* Keywords:
* package:bdi, usage:private
* Copyright:
* Copyright (C) University of Birmingham, 1995
* Authors:
* DJA: David J. Allan (Jet-X, University of Birmingham)
* {enter_new_authors_here}
* History:
* 15 Oct 1995 (DJA):
* Original version.
* {enter_changes_here}
* Bugs:
* {note_any_bugs_here}
*-
* Type Definitions:
IMPLICIT NONE ! No implicit typing
* Global Constants:
INCLUDE 'SAE_PAR' ! Standard SAE constants
INCLUDE 'ADI_PAR'
INCLUDE 'DAT_PAR'
INCLUDE 'QUAL_PAR'
* Arguments Given:
INTEGER NARG, ARGS(*)
* Arguments Returned:
INTEGER OARG
* Status:
INTEGER STATUS ! Global status
* Local Variables:
CHARACTER*(DAT__SZLOC) MLOC ! Quality mask
CHARACTER*(DAT__SZLOC) QLOC ! Quality array
CHARACTER*6 MODE
INTEGER NELM ! Number of data items
INTEGER PSID ! Items private store
INTEGER PTR ! Mapped data address
INTEGER QPTR ! Mapped quality array
BYTE MASK ! Quality mask
*.
* Check inherited global status.
IF ( STATUS .NE. SAI__OK ) RETURN
* Default return value
OARG = ADI__NULLID
* Extract the arguments
CALL ADI_GET0C( ARGS(5), MODE, STATUS )
* Ensure objects satisfy mapping requirement
IF ( MODE .EQ. 'READ' ) THEN
* Locate quality object
CALL BDI1_CFIND( ARGS(1), ARGS(2), 'Quality', .FALSE., QLOC,
: STATUS )
* And the mask
CALL BDI1_CFIND( ARGS(1), ARGS(2), 'QualityMask', .FALSE.,
: MLOC, STATUS )
* If no quality array, build a dynamic array to mark everything as good
IF ( QLOC .EQ. DAT__NOLOC ) THEN
* Get number of data elements
CALL BDI_GETNEL( ARGS(1), NELM, STATUS )
* Create dynamic array
CALL DYN_MAPL( 1, NELM, PTR, STATUS )
* Fill it with 'good' value
CALL ARR_INIT1L( .TRUE., NELM, %VAL(PTR), STATUS )
ELSE
* Default mask if not present
IF ( MLOC .EQ. DAT__NOLOC ) THEN
MASK = QUAL__MASK
ELSE
CALL DAT_GET( MLOC, '_UBYTE', 0, 0, MASK, STATUS )
END IF
* Map the quality array
CALL DAT_MAPV( QLOC, '_UBYTE', 'READ', QPTR, NELM, STATUS )
* Create dynamic array
CALL DYN_MAPB( 1, NELM, PTR, STATUS )
* Copy bytes into workspace
CALL ARR_COP1B( NELM, %VAL(QPTR), %VAL(PTR), STATUS )
* Logical AND with the mask
CALL BIT_AND1UB( NELM, %VAL(PTR), MASK, STATUS )
* Release the quality array
CALL DAT_UNMAP( QLOC, STATUS )
CALL DAT_ANNUL( QLOC, STATUS )
END IF
* Release locators
IF ( MLOC .NE. DAT__NOLOC ) THEN
CALL DAT_ANNUL( MLOC, STATUS )
END IF
* Locate the BDI private storage for the item, creating if required
CALL BDI0_LOCPST( ARGS(1), 'MaskedQuality', .TRUE., PSID,
: STATUS )
* If mapping went ok, store the pointer
CALL BDI1_STOMAP( PSID, .TRUE., DAT__NOLOC, 0, PTR, 'UBYTE',
: MODE, STATUS )
* Release private storage
CALL ADI_ERASE( PSID, STATUS )
* If mapping went ok, store the pointer in the return argument
CALL ADI_NEWV0I( PTR, OARG, STATUS )
ELSE
STATUS = SAI__ERROR
CALL MSG_SETC( 'M', MODE )
CALL ERR_REP( 'BDI1_MAPMQ_1', 'Mapping MaskedQuality for '/
: /'update/write access is forbidden', STATUS )
END IF
* Report any errors
IF ( STATUS .NE. SAI__OK ) CALL AST_REXIT( 'BDI1_MAPMQ', STATUS )
END