* Last processed by NICE on 12-Jun-2000 15:53:00
* Customized for :  IEEE, LINUX, UNIX, MOTIF, F77
c     $Header: /scisoft/gildas/sou/nic/main/nic_variable.for,v 1.70 2000/03/07 09:56:54 broguier Exp $
c     $Log: nic_variable.for,v $
c     Revision 1.70  2000/03/07 09:56:54  broguier
c     change name of variable FIELD_ROTATION
c
C Revision 1.69  2000/03/07  01:17:48  01:17:48  broguier (Dominique Broguiere)
C new variable FIELD_ROTATION for HHT
C
C Revision 1.68  2000/02/10  11:28:10  11:28:10  broguier (Dominique Broguiere)
C new variables atm_temp
C
C Revision 1.67  99/03/12  19:51:17  19:51:17  broguier ()
C SIC_CH replaced with SIC_KE
C
C Revision 1.66  99/02/12  11:19:01  11:19:01  broguier (Dominique Broguiere)
C add variable phase1 and phase2
C
C Revision 1.65  98/12/10  12:43:14  12:43:14  neri (Roberto Neri)
C *** empty log message ***
C
C Revision 1.64  98/09/07  18:40:41  18:40:41  broguier ()
C do not define array with dim equal to 0
C
C Revision 1.63  98/01/29  04:10:50  04:10:50  broguier (Dominique Broguiere)
C totopow replaced by calpow
C
C Revision 1.62  98/01/20  18:17:43  18:17:43  broguier ()
C bad definition for CALPOW_FLAG
C
C Revision 1.61  97/12/18  15:35:07  15:35:07  broguier (Dominique Broguiere)
C add CALPOW variables
C
C Revision 1.60  97/12/09  17:14:00  17:14:00  neri (Roberto Neri)
C fit parameter in variables
C
C Revision 1.52  96/12/04  18:10:02  18:10:02  neri (Roberto Neri)
C *** empty log message ***
C
C Revision 1.51  96/11/29  02:46:29  02:46:29  gildas (Gildas manager)
C *** empty log message ***
C
C Revision 1.47  96/11/19  23:26:47  23:26:47  broguier (Dominique Broguiere)
C new variable support_saa
C
C
C Revision 1.35  96/03/26  14:04:25  14:04:25  gildas (Gildas manager)
C big error: CALL SUB(.FALSE.) alors meme que SUBROUTINE SUB(TOTO) et
C TOTO = .TRUE. ds SUB!!!
C GD
C
C Revision 1.23  95/10/13  09:54:11  09:54:11  broguier (Dominique Broguiere)
C crcreate variable FORWARD_EFFICIENCY
C
C Revision 1.22  95/06/20  14:42:25  14:42:25  broguier (Dominique Broguiere)
C RECEIVER_GAIN is stored in shared memory
C
C Revision 1.20  95/05/30  18:37:20  18:37:20  broguier (Dominique Broguiere)
C use new variables ip_lst, ip_el, ip_signal, ip_scan_coord,...
C
C Revision 1.19  95/05/02  16:26:11  16:26:11  broguier (Dominique Broguiere)
C Define varibales only if file is correct
C
C Revision 1.14  95/01/23  17:41:55  17:41:55  broguier (Dominique Broguiere)
C DATA instructions after declarations
C
C Revision 1.12  95/01/21  05:00:30  05:00:30  neri (Roberto Neri)
C modify skydip section
C
C Revision 1.9  95/01/12  12:49:08  12:49:08  broguier (Dominique Broguiere)
C removal of variable subscan_shmid and modification of receiver_offsets
C
C
*
      SUBROUTINE NIC_VARIABLE(LINE,ERROR)
C ------------------------------------------------------------------------
C NIC command VARIABLE group ON|OFF
C ------------------------------------------------------------------------
* Global variables:
      INCLUDE 'parameter.inc'
* Dummy variables:
      CHARACTER*(*) LINE
      LOGICAL ERROR
* Local variables:
      INTEGER    MVOCAB, NKEY, LENC, NC, I
      PARAMETER (MVOCAB=10)
      CHARACTER ARGUM*12, ARGUM2*2,ARGUM3*2,VOCAB(MVOCAB)*12,KEYWOR*12
      LOGICAL   OFF,READONLY
      LOGICAL   SIC_PRESENT
      DATA VOCAB/
     $'HEADER',
     $'BOLOMETER',
     $'ANTENNA',
     $'CALIBRATION',
     $'FLAG',
     $'SKYDIP',
     $'FIT',
     $'DATA',
     $'CALPOW',
     $'*'/
*------------------------------------------------------------------------
* Code:
*
      CALL SIC_KE(LINE,0,1,ARGUM,NC,.TRUE.,ERROR)
      IF (ERROR) GOTO 999
      ERROR = .FALSE.
      CALL SIC_AMBIGS('NIC_VARIABLE',
     $ARGUM,KEYWOR,NKEY,VOCAB,MVOCAB,ERROR)
      IF (ERROR) RETURN
      ARGUM2 = 'ON'
      CALL SIC_KE(LINE,0,2,ARGUM2,NC,.FALSE.,ERROR)
      IF (ERROR) GOTO 999
      OFF = ARGUM2(1:2).EQ.'OF'
      IF (ARGUM2(1:2).NE.'ON' .AND.
     $ARGUM2(1:2).NE.'OF' .AND.
     $ARGUM2(1:2).NE.'RE' .AND.
     $ARGUM2(1:2).NE.'WR') THEN
         CALL MESSAGE (8,3,'VARIABLE',
     $   'Invalid status '//ARGUM2(1:LENC(ARGUM2)))
         ERROR = .TRUE.
         RETURN
      ENDIF
*
      ARGUM3(1:2)='RE'
      IF (SIC_PRESENT(0,3)) THEN
         CALL SIC_KE (LINE,0,3,ARGUM3,NC,.TRUE.,ERROR)
         IF (ERROR) GOTO 999
      ENDIF
*
      READONLY= .TRUE.
      IF ((ARGUM2(1:2).EQ.'WR') .OR. (ARGUM3(1:2).EQ.'WR'))
     $READONLY= .FALSE.
*
*
      IF (OFF) THEN
         IF (NKEY.EQ.10) THEN
            DO I=1,9
               SECTION(I) = 0            ! off   = 0
            ENDDO
         ELSE
            SECTION(NKEY) = 0            ! off   = 0
         ENDIF
      ELSE
         IF (READONLY) THEN
            IF (NKEY.EQ.10) THEN
               DO I=1,9
                  SECTION(I) = 2         ! read = 2
               ENDDO
            ELSE
               SECTION(NKEY) = 2         ! read = 2
            ENDIF
         ELSE
            IF (NKEY.EQ.10) THEN
               DO I=1,9
                  SECTION(I) = 1         ! write = 1
               ENDDO
            ELSE
               SECTION(NKEY) = 1         ! write = 1
            ENDIF
         ENDIF
      ENDIF
      GOTO  (1,2,3,4,5,6,7,8,9,10) NKEY
      CALL MESSAGE(6,3,'VARIABLE',KEYWOR//' not implemented')
999   ERROR = .TRUE.
      RETURN
*
1     CALL HEADER_VARIABLES(OFF,READONLY)
      RETURN
2     CALL BOLOMETER_VARIABLES(OFF,READONLY)
      RETURN
3     CALL ANTENNA_VARIABLES(OFF,READONLY)
      RETURN
4     CALL CALIBRATION_VARIABLES(OFF,READONLY)
      RETURN
5     CALL FLAG_VARIABLES(OFF,READONLY)
      RETURN
6     CALL SKYDIP_VARIABLES(OFF,READONLY)
      RETURN
7     CALL FIT_VARIABLES(OFF,READONLY)
      RETURN
8     CALL DATA_VARIABLES(OFF,READONLY)
      RETURN
9     CALL CALPOW_VARIABLES(OFF,READONLY)
      RETURN
10    CALL HEADER_VARIABLES(OFF,READONLY)
      CALL BOLOMETER_VARIABLES(OFF,READONLY)
      CALL ANTENNA_VARIABLES(OFF,READONLY)
      CALL CALIBRATION_VARIABLES(OFF,READONLY)
      CALL FLAG_VARIABLES(OFF,READONLY)
      CALL SKYDIP_VARIABLES(OFF,READONLY)
      CALL DATA_VARIABLES(OFF,READONLY)
      CALL FIT_VARIABLES(OFF,READONLY)
      CALL CALPOW_VARIABLES(OFF,READONLY)
      RETURN
      END
*<FF>
      SUBROUTINE STANDARD_VARIABLES(OFF,READONLY)
C ----------------------------------------------------------------------
C  	Initialisation routine
C	defines all HEADER variables
C ----------------------------------------------------------------------
      LOGICAL ERROR, OFF,READONLY
      INCLUDE 'nic.inc'
      INCLUDE 'parameter.inc'
      INCLUDE 'par.inc'
*
      INTEGER*4 IP_SKYLST, IP_SKYTAU, POINTER
      INTEGER*4 IP_AZ_POS, IP_EL_POS,  IP_AZ_NEG,IP_EL_NEG
      INTEGER*4 IP_WIDTH,  IP_AMP_POS, IP_AMP_NEG
      INTEGER*4 IP_WIDTH1, IP_WIDTH2,  IP_ANGLE
      INTEGER*4 IP_AZ_OFF, IP_EL_OFF
      INTEGER*4   DIM(4)
*
*------------------------------------------------------------------------
* General
*
      DIM(1) = NCHAN
      CALL SIC_DELVARIABLE('source',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('field_center',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('skew',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('lambda',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('beta',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('flux',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_rms',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan_type',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nsubscan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('onoff_mode',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nsubrec',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('wobbler_throw',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nchan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('ncalpow',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nrecord',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('ut',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('lst',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('az',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('el',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('signal',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('phase1',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('phase2',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('map',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan_coord',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('support_ekh',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('support_saa',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('support_mdb',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('support',.FALSE.,ERROR)
*
      IF (.NOT.OFF) THEN
         DIM(1) = NCHAN
         IF (DIM(1).NE.0)
     $   CALL SIC_DEF_REAL ('chan_rms',MEMORY(IP_RMS),
     $   1,DIM,.TRUE.,ERROR)
         DIM(1) = NRECORD
         DIM(2) = NCHAN
         IF (DIM(1).NE.0.AND.DIM(2).NE.0) THEN
            CALL SIC_DEF_REAL ('ut',MEMORY(IP_UT),1,DIM,
     $      .TRUE.,ERROR)
            CALL SIC_DEF_REAL ('lst',MEMORY(IP_LST),1,DIM,
     $      .TRUE.,ERROR)
            CALL SIC_DEF_REAL ('az',MEMORY(IP_AZ),1,DIM,
     $      .TRUE.,ERROR)
            CALL SIC_DEF_REAL ('el',MEMORY(IP_EL),1,DIM,
     $      .TRUE.,ERROR)
            CALL SIC_DEF_REAL ('signal',MEMORY(IP_SIGNAL),2,DIM,
     $      .TRUE.,ERROR)
            IF (IADDR_PHASES.NE.0) THEN
               CALL SIC_DEF_REAL ('phase1',MEMORY(IP_PHASE1),2,DIM,
     $         .TRUE.,ERROR)
               CALL SIC_DEF_REAL ('phase2',MEMORY(IP_PHASE2),2,DIM,
     $         .TRUE.,ERROR)
            ENDIF
         ENDIF
      ENDIF
      CALL SIC_DEF_CHAR ('source',SOURCE_NAME,.TRUE.,ERROR)
      CALL SIC_DEF_CHAR ('field_center',FIELD_CENTER,.TRUE.,ERROR)
      CALL SIC_DEF_REAL ('skew',SKEW,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_DBLE ('lambda',SOURCE_LAMBDA,0,DIM,.TRUE.,
     $ERROR)
      CALL SIC_DEF_DBLE ('beta',SOURCE_BETA,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_REAL ('flux',SOURCE_FLUX,0,DIM,.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('scan',SCAN_NUMBER,0,DIM,.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('scan_type',SCAN_TYPE,0,DIM,.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('nsubscan',SUBSCAN_NUMBER,0,DIM,
     $.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('onoff_mode',ONOFF_MODE,0,DIM,
     $.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('nsubrec',MEMORY(IPSUBREC),1,SUBSCAN_NUMBER,
     $.TRUE.,ERROR)
      IF (WOBBLER_THROW.NE.-999.AND.WOBBLER_THROW.NE.0) THEN
         CALL SIC_DEF_REAL ('wobbler_throw',WOBBLER_THROW,0,DIM,
     $   .FALSE.,ERROR)
      ELSEIF  (SCAN_TYPE.EQ.1) THEN      ! ON-OFF
         WOBBLER_THROW = NINT(DAZM*3600.*100.)/100.
         CALL SIC_DEF_REAL ('wobbler_throw',WOBBLER_THROW,0,DIM,
     $   .FALSE.,ERROR)
      ENDIF
      CALL SIC_DEF_INTE ('nchan',NCHAN,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('ncalpow',NCALPOW,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('nrecord',NRECORD,0,DIM,
     $.TRUE.,ERROR)
      RETURN
*
      ENTRY HEADER_VARIABLES(OFF,READONLY)
*
*     CALL SIC_DELVARIABLE('project_code',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('telescope',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_altitude',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_latitude',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_longitude',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('data_format',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('epoch',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('coord_syst',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('date_reduction',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('date_observ',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('name_of_reducer',.FALSE.,ERROR)
*
      CALL SIC_DELVARIABLE('data_shmid',.FALSE.,ERROR)
*
* For makplan
*
      CALL SIC_DELVARIABLE('is_lst',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('ndump',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('OLAM',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('VLAM',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('OBET',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('SAZM',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('OAZM',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('VAZM',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('OELV',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('VELV',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('SINT',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('DAZM',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('SRP2',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('NULA',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('NULE',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('COLSTAR',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('SOURCE',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('FIELD_CENTER',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('SKEW',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('LAMBDA',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('BETA',.FALSE.,ERROR)
      IF (OFF) THEN
         RETURN
      ENDIF
*
      CALL SIC_DEF_CHAR ('source',SOURCE_NAME,READONLY,ERROR)
      CALL SIC_DEF_CHAR ('field_center',FIELD_CENTER,READONLY,ERROR)
      CALL SIC_DEF_REAL ('skew',SKEW,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_DBLE ('lambda',SOURCE_LAMBDA,0,DIM,READONLY,
     $ERROR)
      CALL SIC_DEF_DBLE ('beta',SOURCE_BETA,0,DIM,READONLY,ERROR)
*     CALL SIC_DEF_CHAR ('project_code',PROJECT_CODE,READONLY,ERROR)
      CALL SIC_DEF_CHAR ('telescope',TELESCOPE,READONLY,ERROR)
      CALL SIC_DEF_REAL ('site_altitude',SITE_ALTITUDE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_DBLE ('site_latitude',SITE_LATITUDE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_DBLE ('site_longitude',SITE_LONGITUDE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_INTE ('data_format',DATA_FORMAT,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('epoch',EPOCH,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_INTE ('coord_syst',COORDINATE_SYSTEM,0,DIM,
     $READONLY,ERROR)
*     CALL SIC_DEF_INTE ('date_reduction',DATE_OF_REDUCTION,0,DIM,
*    $READONLY,ERROR)
      CALL SIC_DEF_INTE ('date_observ',DATE_OF_OBSERVATION,0,DIM,
     $READONLY,ERROR)
*
* Shared memory parameters
*
      CALL SIC_DEF_INTE ('data_shmid',DATA_SHMID,0,DIM,
     $.TRUE.,ERROR)
*
* Variables for makplan
*
      CALL SIC_DEF_LOGI('is_lst',IS_LST,READONLY,ERROR)
      CALL SIC_DEF_INTE('ndump',NBI,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('olam',OLAM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('vlam',VLAM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('obet',OBET,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('sazm',SAZM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('oazm',OAZM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('vazm',VAZM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('oelv',OELV,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('velv',VELV,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('sint',SINT,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('dazm',DAZM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_INTE('srp2',ISRP2,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('nula',PNULA,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('nule',PNULE,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL('colstar',COLSTAR,0,DIM,READONLY,ERROR)
*
* To define some variables for combine command without any scan read
      CALL SIC_DELVARIABLE('nrecord',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nsubscan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan_type',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nchan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('ncalpow',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('field_rotation',.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('nrecord',NRECORD,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('nsubscan',SUBSCAN_NUMBER,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('scan',SCAN_NUMBER,0,DIM,.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('scan_type',SCAN_TYPE,0,DIM,.FALSE.,ERROR)
      CALL SIC_DEF_INTE ('nchan',NCHAN,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('ncalpow',NCALPOW,0,DIM,.TRUE.,ERROR)
      CALL SIC_DEF_INTE ('field_rotation',FIELD_ROTATION,0,DIM,.FALSE.,E
     $RROR)
      RETURN
*
*<FF>
      ENTRY BOLOMETER_VARIABLES(OFF,READONLY)
      CALL SIC_DELVARIABLE('ref_chan',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('bolgain',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_number',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_az_off',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_el_off',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('frequency',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('bandwidth_equiv',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('field_rotation',.FALSE.,ERROR)
      IF (OFF) THEN
         RETURN
      ENDIF
      DIM(1) = NCHAN
      CALL SIC_DEF_INTE ('ref_chan',REFERENCE_RECEIVER,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('bolgain',REFERENCE_GAIN,0,DIM,
     $READONLY,ERROR)
      IF (DIM(1).NE.0) THEN
         CALL SIC_DEF_INTE ('chan_number',RECEIVER_NUMBER,1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('chan_az_off',
     $   MEMORY(IP_AZOFF),1,DIM,READONLY,ERROR)
         CALL SIC_DEF_REAL ('chan_el_off',
     $   MEMORY(IP_ELOFF),1,DIM,READONLY,ERROR)
      ENDIF
      CALL SIC_DEF_REAL ('frequency',FREQUENCY,0,DIM,.FALSE.,ERROR)
      CALL SIC_DEF_REAL ('bandwidth_equiv',BANDWIDTH_EQUIVALENT,
     $0,DIM,READONLY,ERROR)
      CALL SIC_DEF_INTE ('field_rotation',FIELD_ROTATION,0,DIM,.FALSE.,E
     $RROR)
      RETURN
*
      ENTRY ANTENNA_VARIABLES(OFF,READONLY)
*
      DIM(1) = 6
      CALL SIC_DELVARIABLE('telescope',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_altitude',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_latitude',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_longitude',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('antenna_eff',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('beam_eff',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('beam_az',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('beam_el',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('forward_eff',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nula',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nule',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('colstar',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('focus',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('wobbler_device',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('number_phases',.FALSE.,ERROR)
      IF (WOBBLER_THROW.NE.-999.AND.WOBBLER_THROW.NE.0) THEN
         CALL SIC_DELVARIABLE('wobbler_period',.FALSE.,ERROR)
         CALL SIC_DELVARIABLE('wobbler_throw',.FALSE.,ERROR)
         CALL SIC_DEF_REAL('wobbler_throw',WOBBLER_THROW,0,DIM,
     $   READONLY,ERROR)
         CALL SIC_DELVARIABLE('record_time',.FALSE.,ERROR)
      ENDIF
      IF (OFF) THEN
         RETURN
      ENDIF
      CALL SIC_DEF_CHAR ('telescope',TELESCOPE,READONLY,ERROR)
      CALL SIC_DEF_REAL ('site_altitude',SITE_ALTITUDE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_DBLE ('site_latitude',SITE_LATITUDE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_DBLE ('site_longitude',SITE_LONGITUDE,0,DIM,
     $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('antenna_eff',ANTENNA_EFFICIENCY,0,DIM,
*    $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('beam_eff',BEAM_EFFICIENCY,0,DIM,
*    $READONLY,ERROR)
      CALL SIC_DEF_REAL ('beam_az',BEAM_AZIMUTH,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('beam_el',BEAM_ELEVATION,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('forward_eff',FORWARD_EFFICIENCY,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('nula',PNULA,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL ('nule',PNULE,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL ('colstar',COLSTAR,0,DIM,
     $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('focus',FOCUS,1,DIM,READONLY,ERROR)
      CALL SIC_DEF_INTE ('wobbler_device',WOBBLER_DEVICE,0,DIM,
     $READONLY,ERROR)
*     CALL SIC_DEF_INTE ('number_phases',NUMBER_OF_PHASES,0,DIM,
*    $READONLY,ERROR)
      IF (WOBBLER_THROW.NE.-999.AND.WOBBLER_THROW.NE.0) THEN
         CALL SIC_DEF_REAL ('wobbler_period',WOBBLER_PERIOD,0,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('record_time',
     $   RECORD_INTEGRATION_TIME,0,DIM,READONLY,ERROR)
      ENDIF
      RETURN
*
*
      ENTRY CALIBRATION_VARIABLES(OFF,READONLY)
*
      CALL SIC_DELVARIABLE('amb_pres',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('amb_temp',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('amb_humi',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('refraction',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('site_altitude',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('water_vapour',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('counts_per_k',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('atm_temp',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('opacity',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_opacity',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chopper_temp',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('cold_load_temp',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('sky_counts',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('system_temp',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('frequency',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('bandwidth_equiv',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('jy_per_kelvin',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('chopper_counts',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('coldload_counts',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('chan_temp',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_gain',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('mean_gain_corr',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('chan_weight',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_rms',.FALSE.,ERROR)
      DIM(1) = NCHAN
      IF (OFF) THEN
         RETURN
      ENDIF
      IF (DIM(1).NE.0)
     $CALL SIC_DEF_REAL ('chan_rms',MEMORY(IP_RMS),1,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('amb_pres',AMBIENT_PRESSURE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('amb_temp',AMBIENT_TEMPERATURE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('refraction',REFRACTION,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('amb_humi',HUMIDITY,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL ('site_altitude',SITE_ALTITUDE,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('atm_temp',TATM,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_REAL ('water_vapour',WATER_VAPOUR,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('counts_per_k',COUNTS_TO_KELVIN,0,DIM,
     $READONLY,ERROR)
*      CALL SIC_DEF_REAL ('opacity',ATMOSPHERIC_OPACITY,0,DIM,
*     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('fit_opacity',FITTED_OPACITY,0,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('chopper_temp',CHOPPER_TEMPERATURE,0,DIM,
     $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('cold_load_temp',COLD_LOAD_TEMPERATURE,0,DIM,
*    $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('sky_counts',SKY_COUNTS,0,DIM,READONLY,ERROR)
*     CALL SIC_DEF_REAL ('system_temp',SYSTEM_TEMPERATURE,0,DIM,
*    $READONLY,ERROR)
      CALL SIC_DEF_REAL ('frequency',FREQUENCY,0,DIM,.FALSE.,ERROR)
*     CALL SIC_DEF_REAL ('bandwidth_equiv',BANDWIDTH_EQUIVALENT,
*    $0,DIM,READONLY,ERROR)
*     CALL SIC_DEF_REAL ('jy_per_kelvin',JY_TO_KELVIN,0,DIM,
*    $READONLY,ERROR)
*     CALL SIC_DEF_INTE ('chopper_counts',CHOPPER_COUNTS,1,DIM,
*    $READONLY,ERROR)
*     CALL SIC_DEF_INTE ('coldload_counts',COLD_LOAD_COUNTS,1,DIM,
*    $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('chan_temp',RECEIVER_TEMPERATURE,1,DIM,
*    $READONLY,ERROR)
      IF (DIM(1).NE.0)
     $CALL SIC_DEF_REAL ('chan_gain',MEMORY(IP_GAIN),1,DIM,
     $READONLY,ERROR)
      CALL SIC_DEF_REAL ('mean_gain_corr',MEAN_GAIN,0,DIM,
     $READONLY,ERROR)
*     CALL SIC_DEF_REAL ('chan_weight',RECEIVER_WEIGHT,1,DIM,
*     $READONLY,ERROR)
      RETURN
*
      ENTRY FLAG_VARIABLES(OFF,READONLY)
*
      CALL SIC_DELVARIABLE('amplifier_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('jansky_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('opacity_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('gainc_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('noise_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('gaine_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('chan_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('despike_flag',.FALSE.,ERROR)
      IF (OFF) THEN
         RETURN
      ENDIF
      DIM(1) = NCHAN
      CALL SIC_DEF_LOGI ('amplifier_flag',AMPLI_FLAG,
     $READONLY,ERROR)
      CALL SIC_DEF_LOGI ('jansky_flag',JANSKY_FLAG,
     $READONLY,ERROR)
      CALL SIC_DEF_LOGI ('opacity_flag',OPACITY_FLAG,
     $READONLY,ERROR)
      CALL SIC_DEF_LOGI ('gainc_flag',GAIN_RECEIVER_FLAG,
     $READONLY,ERROR)
      CALL SIC_DEF_LOGI ('noise_flag',NOISE_REMOVAL_FLAG,
     $READONLY,ERROR)
      CALL SIC_DEF_LOGI ('gaine_flag',GAIN_ELEV_FLAG,
     $READONLY,ERROR)
      IF (DIM(1).NE.0) THEN
         CALL SIC_DEF_INTE ('despike_flag',SPIKE_REMOVAL_FLAG,1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_LOGIN('chan_flag',MEMORY(IP_FLAG),
     $   1,DIM,READONLY,ERROR)
      ENDIF
      RETURN
*
      ENTRY SKYDIP_VARIABLES(OFF,READONLY)
*
      DIM(1) = NUMBER_OF_SKYDIPS
      CALL SIC_DELVARIABLE('frequency',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('bandwidth_equiv',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('nskydip',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan_opacity',.FALSE.,ERROR)
      IF (DIM(1).GT.0) THEN
         CALL SIC_DELVARIABLE('skydip_time',.FALSE.,ERROR)
         CALL SIC_DELVARIABLE('skydip_opacity',.FALSE.,ERROR)
      ENDIF
      IF (OFF) THEN
         RETURN
      ENDIF
      CALL SIC_DEF_REAL ('scan_opacity',SCAN_OPACITY,0,DIM,READONLY,
     $ERROR)
      CALL SIC_DEF_REAL ('frequency',FREQUENCY,0,DIM,READONLY,ERROR)
*     CALL SIC_DEF_REAL ('bandwidth_equiv',
*    $BANDWIDTH_EQUIVALENT,0,DIM,READONLY,ERROR)
      CALL SIC_DEF_INTE ('nskydip',NUMBER_OF_SKYDIPS
     $,0,DIM,READONLY,ERROR)
      IF (DIM(1).GT.0) THEN
         IP_SKYLST    = POINTER(SKYDIP_MEM,MEMORY)
         IP_SKYTAU    = IP_SKYLST + 2*DIM(1)
         CALL SIC_DEF_DBLE ('skydip_time',MEMORY(IP_SKYLST),1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('skydip_opacity',MEMORY(IP_SKYTAU),1,DIM,
     $   READONLY,ERROR)
      ENDIF
      RETURN
*
*
      ENTRY FIT_VARIABLES(OFF,READONLY)
*
      DIM(1) = NCHAN_FIT
      CALL SIC_DELVARIABLE('fit_az_pos',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_az_neg',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_el_pos',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_el_neg',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_amp_pos',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_amp_neg',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_fwhm',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_az_off',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_el_off',.FALSE.,ERROR)
*
      CALL SIC_DELVARIABLE('fit_az',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_el',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_ra',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_dec',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_amp',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_major',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_minor',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_angle',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_pointing',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('fit_focus',.FALSE.,ERROR)
      IF (OFF) THEN
         RETURN
      ENDIF
      IF (IADDR_FIT.NE.0.AND.DIM(1).NE.0) THEN
         IP_AZ_POS  = POINTER (IADDR_FIT,MEMORY)
         IF (DOUBLEBEAM_FIT) THEN
            IP_EL_POS  = IP_AZ_POS  + NCHAN_FIT
            IP_AZ_NEG  = IP_EL_POS  + NCHAN_FIT
            IP_EL_NEG  = IP_AZ_NEG  + NCHAN_FIT
            IP_WIDTH   = IP_EL_NEG  + NCHAN_FIT
            IP_AMP_POS = IP_WIDTH   + NCHAN_FIT
            IP_AMP_NEG = IP_AMP_POS + NCHAN_FIT
            IP_AZ_OFF  = IP_AMP_NEG + NCHAN_FIT
            IP_EL_OFF  = IP_AZ_OFF  + NCHAN_FIT
            CALL SIC_DEF_REAL ('fit_az_pos',MEMORY(IP_AZ_POS),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_az_neg',MEMORY(IP_AZ_NEG),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_el_pos',MEMORY(IP_EL_POS),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_el_neg',MEMORY(IP_EL_NEG),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_amp_pos',MEMORY(IP_AMP_POS),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_amp_neg',MEMORY(IP_AMP_NEG),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_fwhm',  MEMORY(IP_WIDTH),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_az_off',MEMORY(IP_AZ_OFF),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_el_off',MEMORY(IP_EL_OFF),1,DIM,
     $      .FALSE.,ERROR)
         ELSE
            IP_EL_POS  = IP_AZ_POS  + NCHAN_FIT
            IP_AMP_POS = IP_EL_POS  + NCHAN_FIT
            IP_WIDTH1  = IP_AMP_POS + NCHAN_FIT
            IP_WIDTH2  = IP_WIDTH1  + NCHAN_FIT
            IP_ANGLE   = IP_WIDTH2  + NCHAN_FIT
            IP_AZ_OFF  = IP_ANGLE   + NCHAN_FIT
            IP_EL_OFF  = IP_AZ_OFF  + NCHAN_FIT
            IF (CNV_MAP) THEN
               CALL SIC_DEF_REAL ('fit_ra',MEMORY(IP_AZ_POS),1,DIM,
     $         .FALSE.,ERROR)
               CALL SIC_DEF_REAL ('fit_dec',MEMORY(IP_EL_POS),1,DIM,
     $         .FALSE.,ERROR)
            ELSE
               CALL SIC_DEF_REAL ('fit_az',MEMORY(IP_AZ_POS),1,DIM,
     $         .FALSE.,ERROR)
               CALL SIC_DEF_REAL ('fit_el',MEMORY(IP_EL_POS),1,DIM,
     $         .FALSE.,ERROR)
            ENDIF
            CALL SIC_DEF_REAL ('fit_amp',MEMORY(IP_AMP_POS),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_major', MEMORY(IP_WIDTH1),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_minor', MEMORY(IP_WIDTH2),1,DIM,
     $      .FALSE.,ERROR)
            CALL SIC_DEF_REAL ('fit_angle', MEMORY(IP_ANGLE),1,DIM,
     $      .FALSE.,ERROR)
            IF (COMPUTE_OFF_FIT) THEN
               CALL SIC_DEF_REAL ('fit_az_off',MEMORY(IP_AZ_OFF),1,DIM,
     $         .FALSE.,ERROR)
               CALL SIC_DEF_REAL ('fit_el_off',MEMORY(IP_EL_OFF),1,DIM,
     $         .FALSE.,ERROR)
            ENDIF
         ENDIF
      ENDIF
      DIM(1) = 12
      CALL SIC_DEF_REAL ('fit_pointing',MEMORY(IP_POINTING),1,DIM,
     $.FALSE.,ERROR)
      CALL SIC_DEF_REAL ('fit_focus',MEMORY(IP_FOCUS),0,DIM,
     $.FALSE.,ERROR)
      RETURN
*
      ENTRY DATA_VARIABLES(OFF,READONLY)
*
*         CALL SIC_DELVARIABLE('record_number',.FALSE.,ERROR)
*         CALL SIC_DELVARIABLE('record_quality',.FALSE.,ERROR)
*         CALL SIC_DELVARIABLE('record_update',.FALSE.,ERROR)
*         CALL SIC_DELVARIABLE('record_code',.FALSE.,ERROR)
*
*
      CALL SIC_DELVARIABLE('ut',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('lst',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('az',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('el',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('signal',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('phase1',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('phase2',.FALSE.,ERROR)
*     CALL SIC_DELVARIABLE('map',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('scan_coord',.FALSE.,ERROR)
      IF (OFF) THEN
         RETURN
      ENDIF
      IF (IADDRRECORD.EQ.0) THEN
*         CALL MESSAGE (6,2,'VARIABLE','No input file opened ')
         RETURN
      ENDIF
      DIM(1) = NRECORD
      DIM(2) = NCHAN
      IF (DIM(1).GT.0.AND.DIM(2).GT.0) THEN
         CALL SIC_DEF_REAL ('ut',MEMORY(IP_UT),1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('lst',MEMORY(IP_LST),1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('az',MEMORY(IP_AZ),1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('el',MEMORY(IP_EL),1,DIM,
     $   READONLY,ERROR)
         CALL SIC_DEF_REAL ('signal',MEMORY(IP_SIGNAL),2,DIM,
     $   READONLY,ERROR)
         IF (IADDR_PHASES.NE.0) THEN
            CALL SIC_DEF_REAL ('phase1',MEMORY(IP_PHASE1),2,DIM,
     $      READONLY,ERROR)
            CALL SIC_DEF_REAL ('phase2',MEMORY(IP_PHASE2),2,DIM,
     $      READONLY,ERROR)
         ENDIF
*
*      CALL SIC_DEF_INTE ('record_number',record_number,0,DIM,
*     $     READONLY,ERROR)
*      CALL SIC_DEF_INTE ('record_quality',record_quality,0,DIM,
*     $     READONLY,ERROR)
*      CALL SIC_DEF_INTE ('record_update',record_update,0,DIM,
*     $     READONLY,ERROR)
*      CALL SIC_DEF_INTE ('record_code',record_code,0,DIM,
*     $     READONLY,ERROR)
*
*
         IF (SCAN_TYPE.EQ.4.OR.SCAN_TYPE.EQ.2.OR.SCAN_COORD_FOUND) THEN
            DIM(2)=2
            CALL SIC_DEF_REAL ('scan_coord',MEMORY(IP_SCAN_COORD),2,DIM,
     $      READONLY,ERROR)
         ELSEIF (SCAN_TYPE.EQ.5) THEN    ! if FOCUS
            CALL SIC_DEF_REAL ('scan_coord',MEMORY(IP_SCAN_COORD),1,DIM,
     $      READONLY,ERROR)
         ENDIF
      ENDIF
      RETURN
*
      ENTRY CALPOW_VARIABLES(OFF,READONLY)
*
      CALL SIC_DELVARIABLE('calpow',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('calpow_number',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('calpow_flag',.FALSE.,ERROR)
      CALL SIC_DELVARIABLE('calpow_gain',.FALSE.,ERROR)
      IF (OFF) THEN
         RETURN
      ENDIF
      IF (NCALPOW.NE.0) THEN
         DIM(1) = NRECORD
         DIM(2) = NCALPOW
         IF (DIM(1).GT.0.AND.DIM(2).GT.0) THEN
            CALL SIC_DEF_REAL ('calpow',MEMORY(IP_CALPOW),2,DIM,
     $      READONLY,ERROR)
            DIM(1) = NCALPOW
            CALL SIC_DEF_LOGIN('calpow_flag',CALPOW_FLAG,
     $      1,DIM,.FALSE.,ERROR)
            CALL SIC_DEF_INTE ('calpow_number',CALPOW_NUMBER,1,DIM,
     $      READONLY,ERROR)
            CALL SIC_DEF_REAL ('calpow_gain',CALPOW_GAIN,1,DIM,
     $      READONLY,ERROR)
         ENDIF
      ENDIF
      RETURN
      END
