* PACKAGE IHSUB     !" ヒストリーパッケージ
*
*"   [HIS] 90/11/02(numaguti) Original
************************************************************************
      SUBROUTINE HSTADD    !" 時間平均ヒストリーの足し込み
     M         ( GOUT  ,
     I           GDATA , IMULT ,
     I           HCORD , HTYPE  )
*
*   [PARAM] 
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)                      !" 格子点数，波数
#else
#include        "zcdim.F"                    !" 格子点数，波数
#endif
*   [MODIFY] 
      REAL       GOUT   ( * )
*
*   [INPUT] 
      REAL       GDATA  ( IDIM, JDIM, *  )
      INTEGER    IMULT
      CHARACTER  HCORD *(*)
      CHARACTER  HTYPE *(*)
*
*   [INTERNAL WORK] 
      REAL       GDATAW ( IDIM, JDIM, KMAX+1 )
      INTEGER    IMAXD, JMAXD, KMAXD
      INTEGER    II, I, J, K
*
      IF      ( HTYPE .EQ. 'X' ) THEN
         CALL XAVR
     I      ( GDATA , HCORD ,
     O        GDATAW, IMAXD , JMAXD , KMAXD  )
*
      ELSE IF ( HTYPE .EQ. 'Z' ) THEN
         CALL ZAVR
     I      ( GDATA , HCORD ,
     O        GDATAW, IMAXD , JMAXD , KMAXD  )
*
      ELSE IF ( HTYPE .EQ. 'XZ' ) THEN
         CALL XZAVR
     I      ( GDATA , HCORD ,
     O        GDATAW, IMAXD , JMAXD , KMAXD  )
*
      ELSE IF ( HTYPE .EQ. 'XY' ) THEN
         CALL XYAVR
     I      ( GDATA , HCORD ,
     O        GDATAW, IMAXD , JMAXD , KMAXD  )
*
      ELSE IF ( HTYPE .EQ. 'XYZ' ) THEN
         CALL XYZAVR
     I      ( GDATA , HCORD ,
     O        GDATAW, IMAXD , JMAXD , KMAXD  )
*
      ELSE
         CALL NOAVR
     I      ( GDATA , HCORD ,
     O        GDATAW, IMAXD , JMAXD , KMAXD  )
      ENDIF
*
      II = 0
      DO 1100 K = 1, KMAXD
         DO 1110 J = 1, JMAXD
            DO 1120 I = 1, IMAXD
               II = II + 1
               GOUT ( II ) = GOUT ( II ) + GDATAW( I,J,K )*IMULT
 1120       CONTINUE
 1110    CONTINUE
 1100 CONTINUE
*
      RETURN
      END
************************************************************************
      SUBROUTINE HHEDIT       !" 時間平均編集記述
     M         ( HHEAD ,
     I           ITSUM , IMEAN , HUTIMO  )
*
*   [MODIFY] 
      CHARACTER  HHEAD ( * )*(*)             !" ヘッダー
*
*   [INPUT] 
      INTEGER    ITSUM                       !" 積算時間
      INTEGER    IMEAN                       !" 平均/積算
      CHARACTER  HUTIMO     *(*)             !" 出力時刻単位
*
*   [INTERNAL WORK] 
#ifdef SYS_IBMS
      INCLUDE   (ZHDIM)                      !" 文字数
#else
#include        "zhdim.F"                    !" 文字数
#endif
      CHARACTER  HEDIT      *(NCC)           !" 時刻単位
      CHARACTER  HETTL      *(NCC)           !" 時刻単位
      CHARACTER  HNUM       *(NCC)           !" 時刻単位
      INTEGER    NNUM, NE
      REAL       RT
*
*   [EXTERNAL FUNC] 
      INTEGER    LENC
*
      CALL ACTIMR
     I         ( ITSUM , '#'   , HUTIMO,
     O           RT                        )
*
      CALL GZDBCR ( 'D', RT, HNUM, NNUM   )
      HETTL = HNUM(1:NNUM)//HUTIMO
      NE = LENC( HETTL )
*
      IF ( IMEAN .GT. 0 ) THEN
         HEDIT = 'TMEAN'
         HETTL(NE+1:NE+5) = ' Mean'
      ELSE
         HEDIT = 'TINTG'
         HETTL(NE+1:NE+5) = ' Intg'
      ENDIF
*
      CALL GHEADD( HHEAD , HEDIT  , HETTL )
*
      RETURN
      END
