* PACKAGE GTSEQ   !" 系列をまとめたデータの作成
*********************************************************************
      PROGRAM GTSEQ
*
#ifdef SYS_IBMS
      INCLUDE    (GTSINC)
      INCLUDE    (GZSIZE)
#else
#include         "gtsinc.F"
#include         "gzsize.F"
#endif
      COMMON     /GMWORK/ MWORK
      REAL       MWORK  ( IJKDIM )
*
      CHARACTER  HHEAD ( NDC )*(NCC)
      REAL       GDATA ( IJKDIM )
      CHARACTER  HHEADT( NDC )*(NCC)
      REAL       GDATAT( IJKDIM )
*
      CHARACTER  HFILE( 1 ) *(NFILN)
      DATA       HFILE / '$GTTMPDIR/gtool.out' /
      DATA       IFILE / 50 /
      DATA       JFILE / 60 /
*
      CHARACTER  OUT    *(NFILN)
      DATA       OUT    / '$GTTMPDIR/gtool.out' /
      LOGICAL    APND
      DATA       APND   / .FALSE. /
      CHARACTER  AXNAME *(NCC)
      CHARACTER  AXITEM *(NCC)
      CHARACTER  ITEM   *(NCC)
      CHARACTER  UNIT   *(NCC)
      CHARACTER  TITLE  *(NCC*2)
      CHARACTER  DSET   *(NCC)
      CHARACTER  EDIT   *(NCC)
      CHARACTER  ETTL   *(NCC)
      DATA       AXNAME, AXITEM / 2*' ' /
      DATA       ITEM, UNIT, TITLE, DSET, EDIT, ETTL /6*' '/
      LOGICAL    GRESET
      DATA       GRESET / .FALSE. /
      LOGICAL    HELP
      DATA       HELP   / .FALSE. /
*
      NAMELIST  /OPTION/ OUT, APND, AXNAME, AXITEM,
     &                   ITEM, UNIT, TITLE, DSET, EDIT, ETTL, GRESET,
     &                   HELP, HFILE
*
      CALL OPTARG ( 91, 'OPTION', 'HFILE', NOPT, NFILE )
      READ (91,OPTION,IOSTAT=IOS)
      CLOSE(91)
      IF ( IOS.NE.0 .OR. HELP ) THEN
         WRITE(6,OPTION)
         STOP
      ENDIF
*
      CALL GTOPEN
      CALL GTSIZE ( HHEAD , IJKDIM )
      CALL GTSIZE ( HHEADT, IJKDIM )
      CALL GMSIZE ( IJKDIM  )
*
      CALL GURNTF ( HFILE( 1 ), OUT  , '$GTTMPDIR/gtool.in' )
*
      CALL GFROPN ( IFILE, HFILE( 1 ) )
*
      CALL GUNENV( OUT,'.',.FALSE. )
      IL=LENC(OUT)
      WRITE (6,*) 'output='//OUT(1:IL)
*
      IF ( AXITEM .NE. ' ' ) THEN
         CALL GTCSET ( 'ITEMSEQ', AXITEM )
      ENDIF
      IF ( AXNAME .NE. ' ' ) THEN
         CALL GTCSET ( 'AXISSEQ', AXNAME )
      ENDIF
      CALL GPTSQR ( HHEADT )
*
      II = 0
 1100 CONTINUE
         CALL   GFREAD
     O        ( HHEAD , GDATA , IEOD  ,
     I          IFILE , 1               )
*
         IF ( IEOD.EQ.0 ) THEN
            II = II + 1
*
            CALL GPTSEQ
     I         ( HHEAD , GDATA ,
     I           ' '   , ' '   ,
     M           HHEADT, GDATAT )
*
      GOTO 1100
         ENDIF
*
      IF ( II .GT. 0 ) THEN
*
         IF ( ITEM .NE. ' ' ) THEN
            CALL GHCSET( HHEADT, 'ITEM', ITEM )
         ENDIF
         IF ( UNIT .NE. ' ' ) THEN
            CALL GHCSET( HHEADT, 'UNIT', UNIT )
         ENDIF
         IF ( TITLE .NE. ' ' ) THEN
            CALL GHCSTS( HHEADT, 'TITL', TITLE )
         ENDIF
         IF ( DSET .NE. ' ' ) THEN
            CALL GHCSET( HHEADT, 'DSET', DSET )
         ENDIF
*
         IF ( GRESET ) THEN
            CALL GHRSGP( HHEADT  )
         ENDIF
*
         CALL  GFOOPN ( JFILE,  OUT , APND )
*
         CALL  GFWRIT
     I               ( HHEADT, GDATAT,
     I                 JFILE , 1     , 0       )
*
         CALL  GUWIAX
     I               ( HHEADT )
      ENDIF
*
      STOP
      END
