* PACKAGE GTEDY   !" eddy
**************************************************************************
      PROGRAM GTEDY
*
#ifdef SYS_IBMS
      INCLUDE    (GTSINC)
      INCLUDE    (GZSIZE)
#else
#include         "gtsinc.F"
#include         "gzsize.F"
#endif
      PARAMETER  ( RUNDEF=-999., IUNDEF=-999 )
      COMMON     /GMWORK/ MWORK
      REAL       MWORK  ( IJKDIM )
*
      CHARACTER  HHEAD( NDC )*(NCC)
      REAL       GDATA( IJKDIM )
*
      CHARACTER  HFILE( 1 ) *(NFILN)
      DATA       HFILE / '$GTTMPDIR/gtool.out' /
      DATA       IFILE / 50 /
      DATA       IFILP / 51 /
      DATA       JFILE / 60 /
*
      LOGICAL    X, Y, Z
      DATA       X, Y, Z / .TRUE.,.FALSE.,.FALSE. /
      CHARACTER  OUT    *(NFILN)
      DATA       OUT    / '$GTTMPDIR/gtool.out' /
      LOGICAL    APND
      DATA       APND   / .FALSE. /
      CHARACTER  ITEM   *(NCC)
      CHARACTER  UNIT   *(NCC)
      CHARACTER  TITLE  *(NCC*2)
      CHARACTER  DSET   *(NCC)
      CHARACTER  EDIT   *(NCC)
      CHARACTER  ETTL   *(NCC)
      DATA       ITEM, UNIT, TITLE, DSET, EDIT, ETTL /6*' '/
      LOGICAL    GRESET
      DATA       GRESET / .TRUE. /
      LOGICAL    HELP
      DATA       HELP   / .FALSE. /
*
      NAMELIST  /OPTION/ X, Y, Z, OUT, APND,
     &                   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 GMSIZE ( IJKDIM  )
*
      CALL GURNTF ( HFILE( 1 ), OUT  , '$GTTMPDIR/gtool.in' )
*
      CALL GFROPN ( IFILE, HFILE( 1 ) )
      CALL GFOOPN ( JFILE,  OUT , APND )
*
      CALL GUNENV( OUT,'.',.FALSE. )
      IL=LENC(OUT)
      WRITE (6,*) 'output='//OUT(1:IL)
*
      II = 0
 1100 CONTINUE
         CALL   GFREAD
     O        ( HHEAD , GDATA , IEOD  ,
     I          IFILE , 1               )
*
         IF ( IEOD.EQ.0 ) THEN
*
               II = II + 1
*
                  IF ( Z ) THEN
                     CALL GMZEDY
     M               ( HHEAD , GDATA ,
     I                 EDIT  , ETTL  )
                  ENDIF
                  IF ( Y ) THEN
                     CALL GMYEDY
     M               ( HHEAD , GDATA ,
     I                 EDIT  , ETTL  )
                  ENDIF
                  IF ( X  ) THEN
                     CALL GMXEDY
     I               ( HHEAD , GDATA ,
     I                 EDIT  , ETTL  )
                  ENDIF
*
                  IF ( ITEM .NE. ' ' ) THEN
                     CALL GHCSET( HHEAD , 'ITEM', ITEM )
                  ENDIF
                  IF ( UNIT .NE. ' ' ) THEN
                     CALL GHCSET( HHEAD , 'UNIT', UNIT )
                  ENDIF
                  IF ( TITLE .NE. ' ' ) THEN
                     CALL GHCSTS( HHEAD , 'TITL', TITLE )
                  ENDIF
                  IF ( DSET .NE. ' ' ) THEN
                     CALL GHCSET( HHEAD , 'DSET', DSET )
                  ENDIF
                  IF ( GRESET ) THEN
                     CALL GHRSGP( HHEAD  )
                  ENDIF
*
                  CALL  GFWRIT
     I                 ( HHEAD , GDATA ,
     I                   JFILE , 1     , 0       )
*
      GOTO 1100
         ENDIF
*
      STOP
      END
