* PACKAGE IMONI  !"ヒストリー モニター
*
*"  [HIS]  90/11/02(numaguti)
*******************************************************************
      SUBROUTINE  HMONIT          !" モニター出力
     I          ( HHEAD , GDATA ,
     I            IT    , IDATE , ISTEP , ITDUR  )
*
#ifdef SYS_IBMS
      INCLUDE (ZCDIM)                        !" 格子点数, 波数
      INCLUDE (ZHDIM)                        !" 文字数
#else
#include      "zcdim.F"                      !" 格子点数, 波数
#include      "zhdim.F"                      !" 文字数
#endif
*
*   [INPUT]       
      CHARACTER  HHEAD ( * ) *(*)
      REAL       GDATA ( * )
      INTEGER    IT
      INTEGER    IDATE ( 6 )
      INTEGER    ISTEP
      INTEGER    ITDUR
*
*   [INTERNAL SAVE]
      INTEGER    ITOLD
      DATA       ITOLD / -1 /
*
*   [INTERNAL PARM] 
      INTEGER    IWDFL
      DATA       IWDFL / 21 /
      INTEGER    KMAXP1
      PARAMETER  ( KMAXP1=KMAX+1 )
      INTEGER    ISTR , IEND, IINT
      INTEGER    JSTR , JEND, JINT
      INTEGER    KSTR , KEND, KINT
      DATA       ISTR , IEND, IINT / 1, IMAX, 10 /
      DATA       JSTR , JEND, JINT / 1, JMAX, 10 /
      DATA       KSTR , KEND, KINT / 1, KMAXP1,1 /
      CHARACTER  FILE  *(NFILN)
      DATA       FILE  / 'CON' /
      INTEGER    NCOLS
      DATA       NCOLS / 133 /
*
      NAMELIST  /NMMONI/
     &           ISTR , IEND, IINT,
     &           JSTR , JEND, JINT,
     &           KSTR , KEND, KINT,
     &           FILE , NCOLS
*
      LOGICAL    OFIRST
      DATA       OFIRST / .TRUE. /
      SAVE
*
*   [INTERNAL WORK] 
      CHARACTER  HITEM *(NCC)
      CHARACTER  HAVRG *(NCC)
      CHARACTER  HDFMT *(NCC)
      CHARACTER  HNUM  *30
      INTEGER    IFPAR, JFPAR, JFM, IERR
      INTEGER    IXEND, IYEND, K
*
*   [ONCE] 
      IF ( OFIRST ) THEN
         OFIRST = .FALSE.
         CALL   REWNML ( IFPAR , JFPAR )
         READ   ( IFPAR, NMMONI, END=190 )
  190    WRITE  ( JFPAR, NMMONI )
*
         CALL IFLOPN
     O         ( JFM   , IERR  ,
     I           FILE  , IWDFL , 'WRITE', 'FORMATTED'  )
      ENDIF
*
*"         < 1. 時刻を印刷 >
*
      IF ( IT .NE. ITOLD ) THEN
         WRITE ( JFM, * ) '******************[ TIME = ', IT,
     &                    ']******************'
         ITOLD = IT
      ENDIF
*
*"         < 2. データを印刷 >
*
      CALL GHCGET ( HHEAD, 'ITEM' , HITEM )
      CALL GHCGET ( HHEAD, 'EDIT1', HAVRG )
      CALL GHPGET ( HHEAD, 'AEND1', IXEND )
      CALL GHPGET ( HHEAD, 'AEND2', IYEND )
      CALL GHCGET ( HHEAD, 'DFMT' , HDFMT )
*
      IF      ( HAVRG .EQ. 'X-AVG' ) THEN
*
         WRITE ( JFM, * ) '============< ', HITEM, HAVRG,
     &                    '>============='
         DO 1100 K = MIN(KSTR,IYEND), MIN(KEND,IYEND), KINT
            CALL PRINTD
     I         ( JFM  , HDFMT , GDATA  ,
     I           JSTR , MIN(JEND,IXEND), JINT  , K    ,
     I           IXEND, IYEND , NCOLS                  )
 1100    CONTINUE
*
      ELSE IF ( HAVRG .EQ. 'XZ-AVG' ) THEN
*
        WRITE ( JFM, * ) '============< ', HITEM, HAVRG,
     &                    '>============='
         CALL PRINTD
     I         ( JFM  , HDFMT , GDATA ,
     I           JSTR , MIN(JEND,IXEND), JINT  , 1    ,
     I           IXEND, IYEND , NCOLS                   )
*
      ELSE IF ( HAVRG .EQ. 'XYZ-AVG' ) THEN
*
         WRITE ( HNUM , HDFMT ) GDATA(1)
         WRITE ( JFM  , '(1X,A16,4X,A)' ) HITEM, HNUM
*
      ENDIF
*
      RETURN
      END
