      SUBROUTINE TGLOC04(NTARGS,TARGNAME,NPARMS,PARMS,
     *      KSYSNAT,KCENNAT,TARGUNIT,LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE TOSS TARGET LOCATION PACKAGE, TGLOC.  IT
C COMPUTES UNIT VECTORS IN LOCAL ORBITAL COORDINATES FOR TARGETS
C DEFINED BY AZIMUTH AND ELEVATION IN THOSE COORDINATES.
C
C VAR     DIM    TYPE I/O DESCRIPTION
C ---     ---    ---- --- -----------
C
C NTARGS   1      I*4  I  NUMBER OF TARGETS TO BE PROCESSED.
C                         IF ZERO OR NEGATIVE, NONE ARE PROCESSED.
C
C TARGNAME NTARGS CH*16 I TARGET NAMES;  USED FOR ERROR MESSAGES,
C                         OTHERWISE THE NAME HAS NO SIGNIFICANCE.
C
C NPARMS   1      I*4  I  THE NUMBER OF PARAMETERS SUPPLIED IN THE PARMS
C                         ARRAY.  MUST BE 2 OR GREATER.
C
C PARMS           R*8  I  SAME AS TGLOC'S DESCRIPTION OF PARMS FOR
C    NPARMS,NTARGS        TARGET TYPE 4.
C
C KSYSNAT  1      I*4  O  IDENTIFIES THE NATURAL COORDINATE SYSTEM'S
C                         ORIENTATION.  IS SET TO 12 TO INDICATE THE
C                         ORIENTATION IS LOCAL ORBITAL.
C
C KCENNAT  1      I*4  O  IDENTIFIES THE NATURAL COORDINATE SYSTEM'S
C                         ORIGIN.  IS SET TO 9999 TO INDICATE THE ORIGIN
C                         IS IRRELEVANT.
C
C TARGUNIT 3,NTARGS R*8 O TARGUNIT(-,I) IS THE UNIT VECTOR OF THE I'TH
C                         TARGET.  IN LOCAL ORBITAL COORDINATES.
C
C LUERR    1      I*4   I FORTRAN UNIT NUMBER FOR ERROR MESSAGES.
C                          = 0/NEGATIVE, NO MESSAGES POSSIBLE.
C
C IERR     1      I*4   O ERROR RETURN FLAG.
C                          = 0, NO ERROR.
C                          = OTHERWISE, ERROR.
C
C***********************************************************************
C
C BY C PETRUZZO, GSFC/742, 8/85.
C        MODIFIED....
C
C***********************************************************************
C
      REAL*8 PARMS(NPARMS,1),TARGUNIT(3,1)
      CHARACTER*16 TARGNAME(1)
C
      IERR = 0
      KSYSNAT = 12     ! SYSTEM ORIENTATION IS LOCAL ORBITAL
      KCENNAT = 9999   ! INDEPENDENT OF ORIGIN
      IF(NTARGS.LE.0) GO TO 9999
C
C GET TARGET DIRECTION VECTOR IN 'NATURAL' SYSTEM.
C
      DO ITARG=1,NTARGS
        CALL TGLOC04A(NPARMS,PARMS(1,ITARG),TARGNAME(ITARG),
     *           LUERR,IERR1)
        IF(IERR1.EQ.0) THEN
          AZ = PARMS(1,ITARG)
          EL = PARMS(2,ITARG)
          CALL XYZSPH(1,AZ,EL,1.D0,TARGUNIT(1,ITARG),1.D0)
        ELSE
          IERR = 1
          TARGUNIT(1,ITARG) = 'ERROR'
          TARGUNIT(2,ITARG) = 'ERROR'
          TARGUNIT(3,ITARG) = 'ERROR'
          END IF
        END DO
C
 9999 CONTINUE
      RETURN
      END
