*"表題 第３次元の平均を引く GTOOL3(GPZSEL)
*
*"履歴 90/09/06 沼口  敦
*
*
*********************************************************************
*"         << 第３次元の平均を引く >>
*********************************************************************
      SUBROUTINE GPZEDY
     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  HHEADZ ( NDC )*(NCC)
      REAL       AWGTZ  ( 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 )
*
*"         < 2. Δｚの取得 >
*
      CALL GTPGET ( 'SUBCHK', OSUBCK )
      CALL GTSIZE ( HHEADZ  ,  NW     )
      CALL GUQAXV
     I            ( HHEAD , 3     , 'WGT'  ,
     O              HHEADZ, AWGTZ , IEOD     )
      CALL GTPSET ( 'SUBCHK', OSUBCK )
*
*"         < 3. データ平均( 重みつき ) >
*
      CALL GUSZCZ ( NW    , IXDIM  )
*
      DO 3100 IY = 1, IYDIM
*
         CALL GUVINT( GDATAO( IXDIM*(IY-1)+1 ), WW, IXDIM )
         DO 3110 IZ = 1, IZDIM
            CALL GUVDIN( GDATAO( IXDIM*(IY-1)+1 ), WW, IXDIM, 1 ,
     &                   GDATA ( IXDIM*IYDIM*(IZ-1) + IXDIM*(IY-1)+1 ),
     &                   AWGTZ ( IZ )                                  )
 3110    CONTINUE
         CALL GUVOUT( GDATAO( IXDIM*(IY-1)+1 ), WW, IXDIM )
*
         CALL VRSET0( GDATAO( IXDIM*(IY-1)+1 ), WW, IXDIM, 1, 1 )
         DO 3120 IZ = 1, IZDIM
            CALL VRSUB ( GDATA ( IXDIM*IYDIM*(IZ-1) + IXDIM*(IY-1)+1 ),
     &                   WW,
     &                   GDATAO( IXDIM*IYDIM*(IZ-1) + IXDIM*(IY-1)+1 ),
     &                   IXDIM, 1, 1, 1                                )
 3120    CONTINUE
*
 3100 CONTINUE
*
*"         < 4. ヘッダー変更 >
*
      CALL GHCOPY ( HHEAD, HHEADO )
*
      IF ( IZSTR .EQ. IZEND )                  RETURN
*
      IF      ( HEDIT .EQ. ' ' ) THEN
         CALL GHCGET( HHEAD, 'AITM3', HAXIS )
         NH = LENC( HAXIS )
         HETTLD = HAXIS(1:NH)//'-eddy'
         CALL GHEADD ( HHEADO, 'ZE' , HETTLD )
*
      ELSE IF ( HEDIT .NE. 'NUL' ) THEN
         CALL GHEADD ( HHEADO, HEDIT, HETTL  )
      ENDIF
*
      RETURN
      END
*********************************************************************
*"         << 第３次元の平均を引く >>
*********************************************************************
      SUBROUTINE GMZEDY
     I         ( 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       GPZEDY
     I         ( HHEAD , GDATA ,
     I           HEDIT , HETTL ,
     O           HHEADW, GDATAW  )
*
      CALL       GPFSET
     I         ( HHEADW, GDATAW,
     I           ' '   , ' '   ,
     O           HHEAD , GDATA   )
*
      RETURN
      END
