*"表題 第３次元に関する平均 GTOOL3(GPZAVG)
*
*"履歴 90/08/17 沼口  敦
*
*
*********************************************************************
*"         << 第３次元に関する平均 >>
*********************************************************************
      SUBROUTINE GPZAVG
     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
*
      CALL GHCGET ( HHEAD, 'AITM3', HAXIS )
      IF ( HAXIS .EQ. ' ' ) THEN
         CALL       GPFSET
     I         ( HHEAD , GDATA ,
     I           ' '   , ' '   ,
     O           HHEADO, GDATAO   )
         RETURN
      ENDIF
*
*"         < 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 )
 3100 CONTINUE
*
*"         < 4. ヘッダー変更 >
*
      CALL GHCOPY ( HHEAD, HHEADO )
      CALL GHCSET ( HHEADO, 'AITM3', ' '   )
      CALL GHPSET ( HHEADO, 'ASTR3', 1     )
      CALL GHPSET ( HHEADO, 'AEND3', 1     )
*
      IF ( IZSTR .EQ. IZEND )                  RETURN
*
      IF      ( HEDIT .EQ. ' ' ) THEN
         CALL GHCGET( HHEAD, 'AITM3', HAXIS )
         NH = LENC( HAXIS )
         HETTLD = HAXIS(1:NH)//'-mean'
         CALL GHEADD ( HHEADO, 'ZM' , HETTLD )
*
      ELSE IF ( HEDIT .NE. 'NUL' ) THEN
         CALL GHEADD ( HHEADO, HEDIT, HETTL  )
      ENDIF
*
      RETURN
      END
*********************************************************************
*"         << 第３次元に関する平均 >>
*********************************************************************
      SUBROUTINE GMZAVG
     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       GPZAVG
     I         ( HHEAD , GDATA ,
     I           HEDIT , HETTL ,
     O           HHEADW, GDATAW  )
*
      CALL       GPFSET
     I         ( HHEADW, GDATAW,
     I           ' '   , ' '   ,
     O           HHEAD , GDATA   )
*
      RETURN
      END
