* Last processed by NICE on 12-Jun-2000 15:53:00
* Customized for :  IEEE, LINUX, UNIX, MOTIF, F77
c     $Header: /gagax1/u/gildas/nic_run.for,v 1.18 1996/02/19 17:02:49 neri Exp
c     $Log: nic_run.for,v $
c     Revision 1.35  2000/05/02 15:03:39  broguier
c     New version after correction in nic_support
c
C Revision 1.34  2000/02/10  11:26:22  11:26:22  broguier (Dominique Broguiere)
C new version of NIC
C
C Revision 1.33  99/03/11  15:35:08  15:35:08  broguier ()
C Version 1.4-06 10-Mar-1999
C
C Revision 1.32  99/02/12  12:19:36  12:19:36  broguier (Dominique Broguiere)
C Version 1.4-05
C
C Revision 1.30  98/07/17  16:03:12  16:03:12  broguier ()
C check replaced by nic_check
C
C Revision 1.29  98/02/03  12:10:01  12:10:01  neri (Roberto Neri)
C *** empty log message ***
C
C Revision 1.28  98/01/29  04:08:30  04:08:30  broguier (Dominique Broguiere)
C new commands VERSION and POWER
C
C Revision 1.27  97/12/18  15:33:43  15:33:43  broguier ()
C add CALPOW variables
C
C Revision 1.18  1996/02/19  17:02:49  neri
C *** empty log message ***
C
C Revision 1.13  96/01/16  12:21:37  12:21:37  neri (Roberto Neri)
C *** empty log message ***
C
C Revision 1.11  95/10/09  19:11:31  19:11:31  broguier (Dominique Broguiere)
C Add command FIT
C
C Revision 1.10  95/05/30  18:36:15  18:36:15  broguier (Dominique Broguiere)
C use new variables ip_lst, ip_el, ip_signal, ip_scan_coord,...
C
C Revision 1.9  95/05/29  14:52:54  14:52:54  neri (Roberto Neri)
C GET command implemented
C
C Revision 1.7  95/03/30  11:32:08  11:32:08  broguier (Dominique Broguiere)
C *** empty log message ***
C
C Revision 1.4  94/11/23  15:23:46  15:23:46  gildas (Gildas manager)
C disable nic_analyze
C
C Revision 1.3  94/11/22  16:16:29  16:16:29  broguier (Dominique Broguiere)
C *** empty log message ***
C
C Revision 1.2  94/11/18  15:01:11  15:01:11  broguier (Dominique Broguiere)
C *** empty log message ***
C
*
      SUBROUTINE RUN_NIC(LINE,COMM,ERROR)
*
      CHARACTER*(*) LINE,COMM
      LOGICAL ERROR
      INTEGER        LENC, N_ARRAY
      INTEGER*4  IP, IP1, IP2
      INTEGER*4  SELECTED_CHANNEL, POINTER, DECL_HOUR
      INTEGER*4  IER, SIC_GETVM
      PARAMETER (N_ARRAY = 181*181*2)
*
      INCLUDE 'nic.inc'
      INCLUDE 'parameter.inc'
      INCLUDE 'par.inc'
*
      CALL MESSAGE(0,1,'NIC',LINE(1:LENC(LINE)))
*
      IF (COMM.EQ.'BASELINE') THEN
         CALL BASELINE (LINE,ERROR)
      ELSEIF (COMM.EQ.'CHECK') THEN
         CALL NIC_CHECK (LINE,ERROR)
      ELSEIF (COMM.EQ.'DESPIKE') THEN
         IER = SIC_GETVM (NCHAN,SELECTED_CHANNEL)
         IP = POINTER(SELECTED_CHANNEL,MEMORY)
         CALL DESPIKE (LINE,MEMORY(IP),ERROR)
         CALL FREE_VM(NCHAN,SELECTED_CHANNEL)
      ELSEIF (COMM.EQ.'FLAG') THEN
         IER = SIC_GETVM (NCHAN,SELECTED_CHANNEL)
         IP = POINTER(SELECTED_CHANNEL,MEMORY)
         CALL FLAG (LINE,MEMORY(IP),ERROR)
         CALL FREE_VM(NCHAN,SELECTED_CHANNEL)
      ELSEIF (COMM.EQ.'FIELD') THEN
         IER = SIC_GETVM (N_ARRAY,DECL_HOUR)
         IP1 = POINTER(DECL_HOUR,MEMORY)
         IP2 = IP1+N_ARRAY/2
         CALL FIELD (LINE,MEMORY(IP1),MEMORY(IP2),ERROR)
         CALL FREE_VM(N_ARRAY,DECL_HOUR)
      ELSEIF (COMM.EQ.'FILE') THEN
         CALL FILE (LINE,ERROR)
      ELSEIF (COMM.EQ.'FIND') THEN
         CALL FIND_SCAN (LINE,ERROR)
      ELSEIF (COMM.EQ.'FIT') THEN
         CALL NIC_FIT (LINE,ERROR)
      ELSEIF (COMM.EQ.'GET') THEN
         CALL GET_SCAN (LINE,ERROR)
      ELSEIF (COMM.EQ.'HEADER') THEN
         CALL HEADER (LINE,ERROR)
      ELSEIF (COMM.EQ.'POWER') THEN
         CALL POWER (LINE,ERROR)
      ELSEIF (COMM.EQ.'LIST') THEN
         CALL NIC_LIST (LINE,ERROR)
      ELSEIF (COMM.EQ.'SET') THEN
         CALL SET (LINE,ERROR)
      ELSEIF (COMM.EQ.'SHOW') THEN
         CALL NIC_SHOW (LINE,ERROR)
      ELSEIF (COMM.EQ.'SIMULATE') THEN
         CALL NIC_SIMUL (LINE,ERROR)
      ELSEIF (COMM.EQ.'SOLVE') THEN
         IF (SCAN_TYPE.EQ.0) THEN
            CALL MESSAGE (2,1,'SOLVE','No input file opened')
         ELSE
            IF (SCAN_TYPE.EQ.3) CALL SOLVE_SKYDIP (LINE,ERROR)
            IF (SCAN_TYPE.EQ.4) CALL SOLVE_POINTING (LINE,ERROR)
            IF (SCAN_TYPE.EQ.5) CALL SOLVE_FOCUS (LINE,ERROR)
            IF (SCAN_TYPE.EQ.9) CALL SOLVE_RASTERDIP (LINE,ERROR)
            IF (SCAN_TYPE.LE.2.OR.(SCAN_TYPE.GE.6.AND.SCAN_TYPE.NE.9))
     $      CALL MESSAGE (2,1,'SOLVE','Bad scan type')
         ENDIF
      ELSEIF (COMM.EQ.'SUPPORT') THEN
         CALL SUPPORT (LINE,ERROR)
      ELSEIF (COMM.EQ.'VARIABLES') THEN
         CALL NIC_VARIABLE (LINE,ERROR)
      ELSEIF (COMM.EQ.'VERSION') THEN
         WRITE (6,'(A)') 'Version 1.4-08 02-May-2000 (nic@iram.fr)'
      ELSE
         CALL GAGOUT ('E-NIC,  Unsupported command ')
         ERROR = .TRUE.
      ENDIF
99    END
