C*****************************************************************************
C SELECTOR TASK:
C   fvelgallc
C
C FILE:
C   fvelgallc.f
C
C DESCRIPTION:
C
C AUTHOR/DATE:
C   pre-FTOOLS  Bill Priedhorsky (srcftn -> srcfit)
C   FTOOLS      Jesse Allen
C
C MODIFICATION HISTORY:
C   Version 0.9  24 Mar 1995  Initial FTOOL test version
C           1.0  15 Aug 1995  HISTORY keyword information added
C           1.1  12 Sep 1995  Altered to accept 20 sources instead of 16
C           1.2   2 Nov 1995  Gets coordinates from keywords instead of 
C                              address primary array
C           1.21 11 Nov 1995  Uses time boundaries from FVELMAP
C           1.22 18 Dec 1995  Includes minimum dynamic array size fix
C           1.23 30 Jan 1996  Removes final NULL line from light curves
C           1.24 31 Jan 1996  BACKV and BACKE are single elements instead 
C           1.25 11 Mar 1996  Corrected error in reading .par file
C                              of 3 element vectors
C
C PRIMARY LOCAL VARIABLES:
C   COMMON BLOCKS:
C      long_src, lat_src   Galactic coordinates of the sources
C      longcntr, latcntr   Galactic coordinates of the center of each map
C                           element
C      longmin, longmax, latmin, latmax, longavg, latavg
C                          Range or average of coordinates in the map
C      counts, background  Background subtracted counting rate and background
C      frate               The limit of the fraction of the map which can 
C                           be empty and still be used for data extraction
C      numpnts             The number of points in each map element prior
C                           to the application of FVELGALLC selection criteria
C      nsrc                The number of sources to be extracted
C      imax, jmax          The number of map elements in longitude and 
C                           latitude respectively
C
C CALLED ROUTINES:
C      gsrcpar             Gets the user selected parameters
C      julian              Function to convert between Universal Time and 
C                           Julian dates
C      getmap              Gets the maps generated by FVELMAP and extracts
C                           up to sixteen deconvolved sources from them
C
C*****************************************************************************

      subroutine fvelgc

      implicit none

C Common block declarations

      common /SOURCE/ long_src, lat_src, longcntr, latcntr, longmin, 
     +  longmax, latmin, latmax, longavg, latavg, counts, backgnd, 
     +  frate, numpnts, nsrc, imax, jmax
      common /NAME/ sourcename

      integer nsrc, imax, jmax, numpnts(20,20)
      real long_src(20), lat_src(20)
      real longcntr(20,20), latcntr(20,20)
      real counts(20,20), backgnd(20,20)
      real longmin, longmax, latmin, latmax, longavg, latavg, frate
      character*16 sourcename(20)

      common /TASK/ taskname
      character*40 taskname

C Local variables

      integer i, status

      real percent

      character*80 message


C Begin program 

      taskname = 'FVELGALLC v1.2c'
      call ftcmsg

C Get parameters from the par file

      call gsrcpar(status)
      if (status .ne. 0) goto 999

      percent = frate * 100.0
      write(message,'('' Extracting data when map is at least '', F5.2,
     +     ''% full'')') percent
      call fcecho(message)

      if (nsrc .lt. 10) then 
         write(message,'('' Extracting light curves for '', I1, 
     +        '' sources'')') nsrc
      else
         write(message,'('' Extracting light curves for '', I2, 
     +        '' sources'')') nsrc
      endif
      call fcecho(message)

      message = ' Source   Name              LII    BII '
      call fcecho(message)
      do 100 i = 1, nsrc
         write(message,'(3X, I2, 4X, A16, X, F6.2, X, F6.2)') 
     +        i, sourcename(i), long_src(i), lat_src(i)
         call fcecho(message)
 100  continue

      call getmap(1, status)
      call getmap(2, status)

 999  return

      end

C----------------------------------------------------------------------------
C Calls parameters for FVELGALLC task from the parameter file
C
C Author: Jesse S. Allen (Hughes STX; HEASARC/GSFC/NASA)
C History:
C  Version 0.9   22 Feb 1995
C          1.1   12 Sep 1995  Altered to allow 20 sources to be fit
C          1.11  11 Dec 1995  Removed begin and end times from the common
C          1.12  11 Mar 1996  Corrected error reading sources 18, 19, and 20
C                              values from parameters file


      subroutine gsrcpar(irafsts)

      implicit none

C Common block declarations

      common /SOURCE/ long_src, lat_src, longcntr, latcntr, longmin, 
     +  longmax, latmin, latmax, longavg, latavg, counts, backgnd, 
     +  frate, numpnts, nsrc, imax, jmax
      common /NAME/ sourcename

      integer nsrc, imax, jmax, numpnts(20,20)
      real long_src(20), lat_src(20)
      real longcntr(20,20), latcntr(20,20)
      real counts(20,20), backgnd(20,20)
      real longmin, longmax, latmin, latmax, longavg, latavg, frate
      character*16 sourcename(20)

C Local variable declarations

      integer irafsts

      real long_tmp, lat_tmp

      character*16 tempname
      character*80 message

C Initialize error checking flag

      irafsts = 0

C Get the longitude and latitude of up to 16 sources

 100  call uclgsi('numsrcs', nsrc, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get NUMSRCS parameter'
         call fcerr(message)
         go to 999
      else if ((nsrc .le. 0) .or. (nsrc .gt. 20)) then
         message = ' Illegal value! 1 <= Number of sources <= 20 '
         call fcecho(message)
         message = ' Please enter a valid number of sources now.'
         call fcecho(message)
         go to 100
      endif

      call uclgsr('long_src1', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC1 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(1) = long_tmp

 150  call uclgsr('lat_src1', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC1 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 150
      endif
      lat_src(1) = lat_tmp

       call uclgst('srcname1', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME1 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(1) = tempname

      if (nsrc .lt. 2) go to 2000
      call uclgsr('long_src2', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC2 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(2) = long_tmp

 250  call uclgsr('lat_src2', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC2 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 250
      endif
      lat_src(2) = lat_tmp

       call uclgst('srcname2', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME2 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(2) = tempname

      if (nsrc .lt. 3) go to 2000
      call uclgsr('long_src3', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC3 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(3) = long_tmp

 350  call uclgsr('lat_src3', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC3 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 350
      endif
      lat_src(3) = lat_tmp

       call uclgst('srcname3', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME3 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(3) = tempname

      if (nsrc .lt. 4) go to 2000
      call uclgsr('long_src4', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC4 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(4) = long_tmp

 450  call uclgsr('lat_src4', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC4 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 450
      endif
      lat_src(4) = lat_tmp

       call uclgst('srcname4', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME4 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(4) = tempname

      if (nsrc .lt. 5) go to 2000
      call uclgsr('long_src5', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC5 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(5) = long_tmp

 550  call uclgsr('lat_src5', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC5 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 550
      endif
      lat_src(5) = lat_tmp

       call uclgst('srcname5', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME5 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(5) = tempname

      if (nsrc .lt. 6) go to 2000
      call uclgsr('long_src6', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC6 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(6) = long_tmp

 650  call uclgsr('lat_src6', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC6 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 650
      endif
      lat_src(6) = lat_tmp

       call uclgst('srcname6', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME6 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(6) = tempname

      if (nsrc .lt. 7) go to 2000
      call uclgsr('long_src7', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC7 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(7) = long_tmp

 750  call uclgsr('lat_src7', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC7 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 750
      endif
      lat_src(7) = lat_tmp

       call uclgst('srcname7', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME7 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(7) = tempname

      if (nsrc .lt. 8) go to 2000
      call uclgsr('long_src8', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC8 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(8) = long_tmp

 850  call uclgsr('lat_src8', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC8 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 850
      endif
      lat_src(8) = lat_tmp

       call uclgst('srcname8', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME8 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(8) = tempname

      if (nsrc .lt. 9) go to 2000
      call uclgsr('long_src9', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC9 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(9) = long_tmp

 950  call uclgsr('lat_src9', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC9 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 950
      endif
      lat_src(9) = lat_tmp

       call uclgst('srcname9', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME9 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(9) = tempname

      if (nsrc .lt. 10) go to 2000
      call uclgsr('long_src10', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC10 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(10) = long_tmp

 1050 call uclgsr('lat_src10', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC10 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1050
      endif
      lat_src(10) = lat_tmp

       call uclgst('srcname10', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME10 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(10) = tempname

      if (nsrc .lt. 11) go to 2000
      call uclgsr('long_src11', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC11 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(11) = long_tmp

 1150 call uclgsr('lat_src11', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC11 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1150
      endif
      lat_src(11) = lat_tmp

       call uclgst('srcname11', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME11 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(11) = tempname

      if (nsrc .lt. 12) go to 2000
      call uclgsr('long_src12', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC12 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(12) = long_tmp

 1250 call uclgsr('lat_src12', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC12 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1250
      endif
      lat_src(12) = lat_tmp

       call uclgst('srcname12', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME12 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(12) = tempname

      if (nsrc .lt. 13) go to 2000
      call uclgsr('long_src13', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC13 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(13) = long_tmp

 1350 call uclgsr('lat_src13', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC13 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1350
      endif
      lat_src(13) = lat_tmp

       call uclgst('srcname13', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME13 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(13) = tempname

      if (nsrc .lt. 14) go to 2000
      call uclgsr('long_src14', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC14 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(14) = long_tmp

 1450 call uclgsr('lat_src14', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC14 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1450
      endif
      lat_src(14) = lat_tmp

       call uclgst('srcname14', tempname, irafsts)
       if (irafsts .ne. 0) then
          message = 'Unable to get SRCNAME14 parameter'
          call fcerr(message)
          go to 999
       endif
       sourcename(14) = tempname

      if (nsrc .lt. 15) go to 2000
      call uclgsr('long_src15', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC15 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(15) = long_tmp

 1550 call uclgsr('lat_src15', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC15 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1550
      endif
      lat_src(15) = lat_tmp

      call uclgst('srcname15', tempname, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get SRCNAME15 parameter'
         call fcerr(message)
         go to 999
      endif
      sourcename(15) = tempname

      if (nsrc .lt. 16) go to 2000
      call uclgsr('long_src16', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC16 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(16) = long_tmp

 1650 call uclgsr('lat_src16', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC16 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1650
      endif
      lat_src(16) = lat_tmp

      call uclgst('srcname16', tempname, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get SRCNAME16 parameter'
         call fcerr(message)
         go to 999
      endif
      sourcename(16) = tempname

      if (nsrc .lt. 17) go to 2000
      call uclgsr('long_src17', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC17 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(17) = long_tmp

 1750 call uclgsr('lat_src17', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC17 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1750
      endif
      lat_src(17) = lat_tmp

      call uclgst('srcname17', tempname, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get SRCNAME16 parameter'
         call fcerr(message)
         go to 999
      endif
      sourcename(17) = tempname

      if (nsrc .lt. 18) go to 2000
      call uclgsr('long_src18', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC18 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(18) = long_tmp

 1850 call uclgsr('lat_src18', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC18 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1850
      endif
      lat_src(18) = lat_tmp

      call uclgst('srcname18', tempname, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get SRCNAME16 parameter'
         call fcerr(message)
         go to 999
      endif
      sourcename(18) = tempname

      if (nsrc .lt. 19) go to 2000
      call uclgsr('long_src19', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC16 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(19) = long_tmp

 1950 call uclgsr('lat_src19', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC19 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1950
      endif
      lat_src(19) = lat_tmp

      call uclgst('srcname19', tempname, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get SRCNAME16 parameter'
         call fcerr(message)
         go to 999
      endif
      sourcename(19) = tempname

      if (nsrc .lt. 20) go to 2000
      call uclgsr('long_src20', long_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LONG_SRC20 parameter'
         call fcerr(message)
         go to 999
      else if ((long_tmp .gt. 360.0) .or. (long_tmp .lt. 0.0)) then
         long_tmp = MOD(long_tmp, 360.0)
      endif
      long_src(20) = long_tmp

 1975 call uclgsr('lat_src20', lat_tmp, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get LAT_SRC16 parameter'
         call fcerr(message)
         go to 999
      else if ((lat_tmp .lt. -90.0) .or. (lat_tmp .gt. 90.0)) then
         message = ' Illegal value! -90.0 <= lat <= 90.0 ' 
         call fcecho(message)
         message = ' Please enter a valid latitude now.'
         call fcecho(message)
         go to 1975
      endif
      lat_src(20) = lat_tmp

      call uclgst('srcname20', tempname, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get SRCNAME16 parameter'
         call fcerr(message)
         go to 999
      endif
      sourcename(20) = tempname

C Get other parameters

 2000 call uclgsr('frate', frate, irafsts)
      if (irafsts .ne. 0) then
         message = 'Unable to get FRATE parameter'
         call fcerr(message)
         go to 999
      else if ((frate .lt. 0.0) .or. (frate .gt. 1.0)) then
         message = ' Illegal value!  0.0 <= fraction <= 1.0 '
         call fcecho(message)
         message = ' Please enter a valid fraction now.'
         call fcecho(message)
         go to 2000
      endif

 999  return

      end


