      SUBROUTINE PUTGGB2(GGPAK,ILG1,NLAT,KHEM,NPGG,KOUNT,
     1             NF,NAME,LEV,GLL,WRKS)
C
C     * MAY 29/95 - M.LAZARE. INCLUDE OPTION "ISAVDTS" TO SAVE
C     *                       GCM OUTPUT IN "yyyymmddhh" FORMAT
C     *                       (FORMAT STATEMENT ALSO MODIFIED TO
C     *                       HANDLE POSSIBLE 10-CHARACTERS).
C     * MAY 29/95 - M.LAZARE. PREVIOUS VERSION PUTGGB.
C
C     * UNPACKS A GAUSSIAN GRID IN GGPAK ROW BY ROW FROM THE GCM. 
C     * THE UNPACKED GRID IS SAVED ON FILE NF.
C     * THE FIRST POINT IN EACH ROW IS COPIED INTO THE LAST POINT.
C 
C     * LEVEL 2,GGPAK,GLL 

      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)

      REAL GGPAK(1),GLL(ILG1*NLAT) 
      REAL WRKS(1)
      INTEGER IBUF(8)
      COMMON /KEEPTIM/ IYEAR,IYMDH,MYRSSTI,ISAVDTS
C---------------------------------------------------------------------

      IGRID=NC4TO8("GRID")

C     * DETERMINE PROPER IBUF(2) TO USE FOR SAVED FIELDS, BASED ON
C     * VALUE OF OPTION SWITCH "ISAVDTS".
C
      IF(ISAVDTS.NE.0)                   THEN
         IBUF2=IYMDH
      ELSE
         IBUF2=KOUNT
      ENDIF
C 
C     * STORE VALUES OF GGPAK INTO GLL, ADDING CYCLIC LONGITUDE.
C
      ILG=ILG1-1
      DO 210 J=1,NLAT 
        IJ=(J-1)*ILG1+1
        CALL UPGR(GLL(IJ),ILG,GGPAK,J,NPGG,WRKS) 
        GLL(IJ+ILG)=GLL(IJ)
  210 CONTINUE
C 
      KFLD=IGRID
      NPACK=0 
      CALL SETLAB(IBUF,KFLD,IBUF2,NAME,LEV,ILG1,NLAT,KHEM,NPACK)
      CALL FBUFOUT(NF,IBUF,-1,K)  
      WRITE(NF) GLL
      RETURN
C---------------------------------------------------------------------
      END 
