*"表題 第１次元の平均を引く GTOOL3(GPXEDY)
*
*"履歴 90/09/06 沼口  敦
*"     92/08/28 竹広真一
*"     96/10/14 石渡正樹
*
*********************************************************************
*"         << 第１次元の平均を引く >>
*********************************************************************
      SUBROUTINE GPXEDY
     I         ( HHEAD , GDATA ,
     I           HEDIT , HETTL ,
     O           HHEADO, GDATAO )
*
      CHARACTER  HHEAD  ( * )*(*)        !" ヘッダー(入力)
      REAL       GDATA  ( * )            !" データ(入力)
      CHARACTER  HEDIT       *(*)        !" 編集略記号
      CHARACTER  HETTL       *(*)        !" 編集タイトル
      CHARACTER  HHEADO ( * )*(*)        !" ヘッダー(出力)
      REAL       GDATAO ( * )            !" データ(出力)
*
#ifdef SYS_IBMS
      INCLUDE    (GZSIZE)                !" NCC, NDC
#else
#include         "gzsize.F"              !" NCC, NDC
#endif
      CHARACTER  HAXIS         *(NCC)
      CHARACTER  HETTLD        *(NCC)
*
#ifdef SYS_IBMS
      INCLUDE   (GZIWRK)                     !" NW: 軸ワークの大きさ
#else
#include        "gziwrk.F"                   !" NW: 軸ワークの大きさ
#endif
      CHARACTER  HHEADX ( NDC )*(NCC)
      REAL       AWGTX  ( NW )
      REAL       WW     ( NW )
      LOGICAL    OSUBCK
*
*"         < 1. 大きさの取得 >
*
      CALL GUSMIS ( HHEAD )
*
      CALL GUQSIZ
     I         ( HHEAD ,
     O           IXSTR , IXEND , IXDIM ,
     O           IYSTR , IYEND , IYDIM ,
     O           IZSTR , IZEND , IZDIM  )
*
      CALL GUSZCK ( HHEADO, IXDIM*IYDIM*IZDIM )
*
*"         < 2. Δｘの取得 >
*
      CALL GTPGET ( 'SUBCHK', OSUBCK )
      CALL GTSIZE ( HHEADX  ,  NW     )
      CALL GUQAXV
     I            ( HHEAD , 1     , 'WGT'  ,
     O              HHEADX, AWGTX , IEOD     )
      CALL GTPSET ( 'SUBCHK', OSUBCK )
*
*"         < 3. データ平均( 重みつき ) >
*
      CALL GUSZCZ ( NW    , IYDIM  )
*
      DO 3100 IZ = 1, IZDIM
*
         CALL GUVINT( GDATAO( IXDIM*IYDIM*(IZ-1)+1 ), WW, IYDIM )
         DO 3110 IX = 1, IXDIM
            CALL GUVDIN( GDATAO( IXDIM*IYDIM*(IZ-1)+1 ), WW, 
     &                   IYDIM, IXDIM,
     &                   GDATA ( IX+IXDIM*IYDIM*(IZ-1) ),
     &                   AWGTX ( IX )                               )
 3110    CONTINUE
         CALL GUVOUT( GDATAO( IXDIM*IYDIM*(IZ-1)+1 ), WW, IYDIM )
*
         CALL VRSET0( GDATAO( IXDIM*IYDIM*(IZ-1)+1 ), WW, IYDIM, 1, 1 )
         DO 3120 IX = 1, IXDIM
            CALL VRSUB ( GDATA ( IX+IXDIM*IYDIM*(IZ-1) ),
     &                   WW,
     &                   GDATAO( IX+IXDIM*IYDIM*(IZ-1) ),
     &                   IYDIM, IXDIM, 1, IXDIM          )
 3120    CONTINUE
*
 3100 CONTINUE
*
*"         < 4. ヘッダー変更 >
*
      CALL GHCOPY ( HHEAD, HHEADO )
*
      IF      ( HEDIT .EQ. ' ' ) THEN
         CALL GHCGET( HHEAD, 'AITM1', HAXIS )
         NH = LENC( HAXIS )
         HETTLD = HAXIS(1:NH)//'-eddy'
         CALL GHEADD ( HHEADO, 'XE' , HETTLD )
*
      ELSE IF ( HEDIT .NE. 'NUL' ) THEN
         CALL GHEADD ( HHEADO, HEDIT, HETTL  )
      ENDIF
*
      RETURN
      END
*********************************************************************
*"         << 第１次元の平均を引く >>
*********************************************************************
      SUBROUTINE GMXEDY
     M         ( HHEAD , GDATA ,
     I           HEDIT , HETTL  )
*
      CHARACTER  HHEAD  ( * )*(*)        !" ヘッダー(入力)
      REAL       GDATA  ( * )            !" データ(入力)
      CHARACTER  HEDIT       *(*)        !" 編集略記号
      CHARACTER  HETTL       *(*)        !" 編集タイトル
*
      COMMON     /GMWORK/ GDATAW
      REAL       GDATAW ( 1 )            !" データ(ワーク)
#ifdef SYS_IBMS
      INCLUDE    (GZSIZE)                !" NCC, NDC
#else
#include         "gzsize.F"              !" NCC, NDC
#endif
      CHARACTER  HHEADW ( NDC )*(NCC)    !" ヘッダー(ワーク)
*
      CALL       GMCSIZ ( HHEADW )
      CALL       GPXEDY
     I         ( HHEAD , GDATA ,
     I           HEDIT , HETTL ,
     O           HHEADW, GDATAW )
*
      CALL       GPFSET
     I         ( HHEADW, GDATAW,
     I           ' '   , ' '   ,
     O           HHEAD , GDATA   )
*
      RETURN
      END
