*"表題 第１次元に関する平均 GTOOL3(GPXAVG)
*
*"履歴 90/08/17 沼口  敦
*"履歴 90/09/13 沼口  敦
*
*
*********************************************************************
*"         << 第１次元に関する平均 >>
*********************************************************************
      SUBROUTINE GPXAVG
     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  HITM          *(NCC)
      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
*
      CALL GHCGET ( HHEAD, 'AITM1', 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, 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( IYDIM*(IZ-1)+1 ), WW, IYDIM )
         DO 3110 IX = 1, IXDIM
            CALL GUVDIN( GDATAO( IYDIM*(IZ-1)+1 ), WW, IYDIM, IXDIM,
     &                   GDATA ( IX+IXDIM*IYDIM*(IZ-1) ),
     &                   AWGTX ( IX )                               )
 3110    CONTINUE
         CALL GUVOUT( GDATAO( IYDIM*(IZ-1)+1 ), WW, IYDIM )
 3100 CONTINUE
*
*"         < 4. ヘッダー変更 >
*
      CALL GHCOPY ( HHEAD, HHEADO )
      CALL GHCGET ( HHEAD , 'AITM2', HITM  )
      CALL GHCSET ( HHEADO, 'AITM1', HITM  )
      CALL GHCGET ( HHEAD , 'AITM3', HITM  )
      CALL GHCSET ( HHEADO, 'AITM2', HITM  )
      CALL GHPSET ( HHEADO, 'ASTR2', IZSTR )
      CALL GHPSET ( HHEADO, 'AEND2', IZEND )
      CALL GHPSET ( HHEADO, 'ASTR1', IYSTR )
      CALL GHPSET ( HHEADO, 'AEND1', IYEND )
      CALL GHCSET ( HHEADO, 'AITM3', ' '   )
      CALL GHPSET ( HHEADO, 'ASTR3', 1     )
      CALL GHPSET ( HHEADO, 'AEND3', 1     )
*
      IF ( IXSTR .EQ. IXEND )                  RETURN
*
      IF      ( HEDIT .EQ. ' ' ) THEN
         CALL GHCGET( HHEAD, 'AITM1', HAXIS )
         NH = LENC( HAXIS )
         HETTLD = HAXIS(1:NH)//'-mean'
         CALL GHEADD ( HHEADO, 'XM' , HETTLD )
*
      ELSE IF ( HEDIT .NE. 'NUL' ) THEN
         CALL GHEADD ( HHEADO, HEDIT, HETTL  )
      ENDIF
*
      RETURN
      END
*********************************************************************
*"         << 第１次元に関する平均 >>
*********************************************************************
      SUBROUTINE GMXAVG
     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       GPXAVG
     I         ( HHEAD , GDATA ,
     I           HEDIT , HETTL ,
     O           HHEADW, GDATAW  )
*
      CALL       GPFSET
     I         ( HHEADW, GDATAW,
     I           ' '   , ' '   ,
     O           HHEAD , GDATA   )
*
      RETURN
      END
