      SUBROUTINE PK_EQUATOR(KFILDO,IPACK,ND5,IS3,NS3,IPKOPT,L3264B,
     1                      LOCN,IPOS,IER,*)
C
C        MARCH   2000   LAWRENCE   GSC/TDL   ORIGINAL CODING
C        JANUARY 2001   GLAHN      COMMENTS; IER = 303 CHANGED TO 304;
C                                  ADDED CHECK FOR SIZE OF IS3( )
C        JANUARY 2001   GLAHN/LAWRENCE CHANGED IS3(45) TO ISC(47)
C                                  IN CALL TO PKBG
C
C        PURPOSE
C            PACKS TEMPLATE 3.110, AN EQUATORIAL AZIMUTHAL
C            EQUIDISTANT PROJECTION TEMPLATE, IN SECTION 3 OF A GRIB2.
C            IT IS THE RESPONSIBILITY OF THE CALLING ROUTINE TO PACK
C            THE FIRST 13 OCTETS IN SECTION 3.
C
C        DATA SET USE
C           KFILDO - UNIT NUMBER FOR OUTPUT (PRINT) FILE. (OUTPUT)
C
C        VARIABLES
C              KFILDO = UNIT NUMBER FOR OUTPUT (PRINT) FILE. (INPUT)
C            IPACK(J) = THE ARRAY THAT HOLDS THE ACTUAL PACKED MESSAGE
C                       (J=1,ND5). (INPUT/OUTPUT)
C                 ND5 = THE SIZE OF THE ARRAY IPACK( ). (INPUT)
C              IS3(J) = CONTAINS THE EQUATORIAL AZIMUTHAL EQUIDISTANT 
C                       INFORMATION (IN ELEMENTS 15 THROUGH 57)
C                       THAT WILL BE PACKED INTO IPACK( ) (J=1,NS3).
C                       (INPUT/OUTPUT)
C                 NS3 = SIZE OF IS3( ). (INPUT) 
C              IPKOPT = PACKING INDICATOR:
C                       0 = ERROR, DON'T PACK
C                       1 = PACK IA( ), SIMPLE
C                       2 = PACK IA( ) AND IB( ), SIMPLE
C                       3 = PACK COMPLEX OR SPATIAL DIFFERENCING
C                       4 = PACK COMPLEX.
C                       (INPUT)
C              L3264B = THE INTEGER WORD LENGTH IN BITS OF THE MACHINE
C                       BEING USED. VALUES OF 32 AND 64 ARE
C                       ACCOMMODATED. (INPUT)
C                LOCN = THE WORD POSITION TO PLACE THE NEXT VALUE.
C                       (INPUT/OUTPUT)
C                IPOS = THE BIT POSITION IN LOCN TO START PLACING
C                       THE NEXT VALUE. (INPUT/OUTPUT)
C                 IER = RETURN STATUS CODE. (OUTPUT)
C                         0 = GOOD RETURN.
C                       1-4 = ERROR CODES GENERATED BY PKBG. SEE THE 
C                             DOCUMENTATION IN THE PKBG ROUTINE.
C                       302 = IS3( ) HAS NOT BEEN DIMENSIONED LARGE
C                             ENOUGH TO CONTAIN THE ENTIRE TEMPLATE. 
C                       304 = IS3(13) DOES NOT INDICATE POLAR
C                             STEREOGRAPHIC MAP PROJECTION; 
C                             INCORRECTLY CALLED SUBROUTINE. 
C                       310 = UNRECOGNIZED OR UNSUPPORTED SHAPE OF
C                             EARTH CODE IN IS3(15) RETURNED BY
C                             SUBROUTINE EARTH.
C                   * = ALTERNATE RETURN WHEN IER .NE. 0.
C
C             LOCAL VARIABLES
C               ISIGN = A FLAG INDICATING WHETHER A VALUE TO BE
C                       PACKED IS POSITIVE OR NEGATIVE. 
C                   N = L3264B = THE INTEGER WORD LENGTH IN BITS OF 
C                       THE MACHINE BEING USED. VALUES OF 32 AND
C                       64 ARE ACCOMMODATED. 
C             MINSIZE = THE SMALLEST ALLOWABLE DIMENSION FOR IS3( ).
C
C        NON SYSTEM SUBROUTINES CALLED
C           EARTH, PKBG
C
      PARAMETER(MINSIZE=57)
C
      DIMENSION IPACK(ND5),IS3(NS3) 
C
      N=L3264B
      IER=0
C
C        CHECK TO MAKE SURE THAT THE USER WANTS TO PROCESS
C        A EQUATORIAL AZIMUTHAL EQUIDISTANT PROJECTION.  CHECK FOR
C        NS3 GE 13 ASSURES A VALUE FOR IS3(13).
C
      IF(NS3.GE.13)THEN
C
         IF (IS3(13).NE.110)THEN
D           WRITE(KFILDO,10)IS3(13)
D10         FORMAT(/' MAP PROJECTION CODE ',I4,' INDICATED BY IS3(13)'/
D    1              ' IS NOT EQUATORIAL AZIMUTHAL. PLEASE REFER'/
D    2              ' TO THE GRIB2 DOCUMENTATION TO DETERMINE THE'/
D    3              ' CORRECT MAP PROJECTION PACKER TO CALL.'/) 
            IER=304
            GOTO 900
         ENDIF
C
      ELSE
         IER=302
         GO TO 900
      ENDIF
C
C        CHECK THE DIMENSIONS OF IS3( ).
C
      IF(NS3.LT.MINSIZE)THEN
         IER=302
         GO TO 900
      ENDIF
C
C        PACK THE SHAPE OF THE EARTH.
      CALL EARTH(KFILDO,IPACK,ND5,IS3,NS3,N,LOCN,IPOS,IER)
      IF(IER.NE.0)GO TO 900
C
C        PACK THE NUMBER OF POINTS ALONG THE X AND Y AXES
C        (Nx, Ny)
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(31),32,N,IER,*900)
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(35),32,N,IER,*900)
C
C        PACK THE LATITUDE & LONGITUDE OF THE TANGENCY POINT
      ISIGN=0
      IF(IS3(39).LT.0)ISIGN=1
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,ISIGN,1,N,IER,*900)
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,ABS(IS3(39)),
     1          31,N,IER,*900)
      ISIGN=0
      IF(IS3(43).LT.0)ISIGN=1
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,ISIGN,1,N,IER,*900)
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,ABS(IS3(43)),
     1          31,N,IER,*900)
C
C        PACK THE RESOLUTION AND COMPONENT FLAG.
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(47),8,N,IER,*900)
C
C        PACK Dx - X-DIRECTION GRID LENGTH IN UNITS OF 10-5 M
C        AS MEASURED AT THE POINT OF THE AXIS.
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(48),32,N,IER,*900)
C
C        PACK Dy - Y-DIRECTION GRID LENGTH IN UNITS OF 10-5 M
C        AS MEASURED AT THE POINT OF THE AXIS.
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(52),32,N,IER,*900)
C
C        PACK THE PROJECTION CENTER FLAG.
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(56),8,N,IER,*900)
C
C        PACK THE SCANNING MODE. CHECK TO SEE IF THE DATA POINTS 
C        HAVE BEEN ORDERED BOUSTROPHEDONICALLY. IF SO, SET BIT 4
C        TO 1 IN THE SCANNING MODE OCTET.
C
      IF((IPKOPT.EQ.3).OR.(IPKOPT.EQ.4))THEN
         IS3(57)=IOR(IS3(57),16)
      ELSE
         IS3(57)=IAND(IS3(57),239)
      ENDIF
C
      CALL PKBG(KFILDO,IPACK,ND5,LOCN,IPOS,IS3(57),8,N,IER,*900)
C
C       ERROR RETURN SECTION
 900  IF(IER.NE.0)RETURN 1
C
      RETURN
      END
