* PACKAGE USUBS       !" 雑ルーチン
*
*"  [HIS] 90/08/31(numaguti)
*
*********************************************************************
      SUBROUTINE RESET     !" 配列を０リセット
     O         ( DATA  ,
     D           IDIM   )
*
*   [PARAM] 
      INTEGER    IDIM
*
*   [OUTPUT]       
      REAL       DATA ( IDIM )
*
*   [INTERNAL WORK] 
      INTEGER    I
*
      DO 1100 I = 1, IDIM
        DATA ( I ) = 0.  
 1100 CONTINUE
*
*
      RETURN
      END
***********************************************************************
      SUBROUTINE COPY     !" 配列を複写
     O         ( DATAO  ,
     I           DATAI  ,
     D           IDIM     )
*
*   [PARAM]
      INTEGER    IDIM
*
*   [OUTPUT]       
      REAL       DATAO ( IDIM )                !" 出力データ
*
*   [INPUT] 
      REAL       DATAI ( IDIM )                !" 入力データ
*
*   [INTERNAL WORK] 
      INTEGER    I
*
      DO 1100 I = 1, IDIM
        DATAO ( I ) = DATAI ( I )
 1100 CONTINUE
*
      RETURN
      END
***********************************************************************
      SUBROUTINE SETV   !" 配列にスカラー値をセット
     O         ( DATA  ,
     I           VALUE ,
     D           IDIM   )
*
*   [PARAM] 
      INTEGER    IDIM
*
*   [OUTPUT] 
      REAL       DATA ( IDIM )                 !" 配列
*
*   [INPUT] 
      REAL       VALUE                         !" 入力データ
*
*   [INTERNAL WORK] 
      INTEGER    I
*
      DO 1100 I = 1, IDIM
        DATA ( I ) = VALUE
 1100 CONTINUE
*
      RETURN
      END
***********************************************************************
      SUBROUTINE FILLV  !" 配列のある範囲を値で埋める >>
     M         ( DATA  ,
     I           VALUE ,
     D           IMIN  , IMAX  , IDIM  , JMIN  , JMAX  , JDIM  ,
     D           KMIN  , KMAX                                   )
*
*   [PARAM] 
      INTEGER    IDIM
      INTEGER    JDIM
      INTEGER    KMAX
*
*   [MODIFY] 
      REAL       DATA ( IDIM, JDIM, KMAX )   !" 配列データ
*
*   [INPUT] 
      REAL       VALUE                       !" 入力データ
      INTEGER    IMIN                        !" 第１次元始め
      INTEGER    IMAX                        !" 第１次元終り
      INTEGER    JMIN                        !" 第２次元始め
      INTEGER    JMAX                        !" 第２次元終り
      INTEGER    KMIN                        !" 第３次元始め
*
*   [INTERNAL WORK] 
      INTEGER    I, J, K
*
      DO 1100 K = KMIN, KMAX
        DO 1100 J = JMIN, JMAX
          DO 1100 I = IMIN, IMAX
            DATA ( I, J, K ) = VALUE
 1100 CONTINUE
*
*
      RETURN
      END
************************************************************************
      SUBROUTINE MAXMIN      !"  配列の最小値最大値を出力 
     I         ( DATA, IDIM, JDIM, KMAX, IMAX, JMAX, HITEM )
*
*   [PARAM] 
      INTEGER    IDIM
      INTEGER    JDIM
      INTEGER    KMAX
*
*   [INPUT] 
      REAL       DATA( IDIM, JDIM, KMAX )
      INTEGER    IMAX
      INTEGER    JMAX
      CHARACTER  HITEM*(*)                     !" 表題
*
*   [INTERNAL WORK] 
      INTEGER    IPMIN, JPMIN, KPMIN
      INTEGER    IPMAX, JPMAX, KPMAX
      REAL       DMIN, DMAX
*
      CALL RVMXMN
     O     ( DMAX  , DMIN  , 
     O       IPMAX , JPMAX , KPMAX , 
     O       IPMIN , JPMIN , KPMIN , 
     I       DATA  , IDIM  , JDIM  , KMAX , 
     I          1  , IMAX  ,    1  , JMAX ,  1 , KMAX  )
*
      WRITE (6,*) HITEM, ': min = ', DMIN,' at ', IPMIN,JPMIN,KPMIN
      WRITE (6,*) HITEM, ': max = ', DMAX,' at ', IPMAX,JPMAX,KPMAX
*
      RETURN
      END
*********************************************************************
      SUBROUTINE RVMXMN
     O            ( DMAX  , DMIN  , 
     O              IPMAX , JPMAX , KPMAX , 
     O              IPMIN , JPMIN , KPMIN , 
     I              DATA  , IDIM  , JDIM  , KDIM , 
     I              ISTR  , IEND  , JSTR  , JEND , KSTR , KEND  )
*
*   [INPUT
      REAL       DMAX , DMIN             !" 最大・最小値
      INTEGER    IPMAX, JPMAX, KPMAX       !" 最大値をとる要素
      INTEGER    IPMIN, JPMIN, KPMIN       !" 最小値をとる要素
      INTEGER    IDIM, JDIM, KDIM
      REAL       DATA( IDIM, JDIM, KDIM )  !" 調べる配列
      INTEGER    ISTR, IEND                !" 調べる範囲
      INTEGER    JSTR, JEND
      INTEGER    KSTR, KEND
*
*   [INTERNAL WORK] 
      INTEGER    I, J, K
*
      DMIN = DATA( ISTR, JSTR, KSTR )
      DMAX = DATA( ISTR, JSTR, KSTR )
*
      DO 1100 K=KSTR,KEND
        DO 1100 J=JSTR,JEND
          DO 1100 I=ISTR,IEND
*
            IF ( DATA( I,J,K ) .LT. DMIN ) THEN
              DMIN = DATA( I,J,K )
              IPMIN = I
              JPMIN = J
              KPMIN = K
            ENDIF
*
            IF ( DATA( I,J,K ) .GT. DMAX ) THEN
              DMAX = DATA( I,J,K )
              IPMAX = I
              JPMAX = J
              KPMAX = K
            ENDIF
*
 1100 CONTINUE
*
      RETURN
      END
*********************************************************************
      INTEGER FUNCTION IUNITM  !" 時間単位の変換
     I        ( KT    , HUNIT  , IDELT  )
*
*   [INPUT] 
      INTEGER     KT                          !" 時間(単位HUNIT)
      CHARACTER   HUNIT*(*)                   !" 時間単位
      INTEGER     IDELT                       !" Δｔ
*
*   [INTERNAL WORK] 
      INTEGER    IT
*
      IF      (    ( HUNIT       .EQ. 'STEP' )
     &         .OR.( HUNIT       .EQ. 'step' )  ) THEN
*
*"         < 1. step のとき Δｔを単位 >
*
        IT = KT * IDELT
*
*"         < 2. sec, min, hour, day >
*
      ELSE IF (    ( HUNIT (1:1) .EQ. 'S' )
     &         .OR.( HUNIT (1:1) .EQ. 's' )  ) THEN
        IT = KT
*
      ELSE IF (    ( HUNIT (1:1) .EQ. 'M' )
     &         .OR.( HUNIT (1:1) .EQ. 'm' )  ) THEN
        IT = KT*60
*
      ELSE IF (    ( HUNIT (1:1) .EQ. 'H' )
     &         .OR.( HUNIT (1:1) .EQ. 'h' )  ) THEN
        IT = KT*60*60
*
      ELSE IF (    ( HUNIT (1:1) .EQ. 'D' )
     &         .OR.( HUNIT (1:1) .EQ. 'd' )  ) THEN
        IT = KT*60*60*24
*
      ELSE
*
*"         < 3. それ以外 : 分 >
*
        IT = KT*60
        WRITE (6,*) 'UNIT = ',HUNIT , 'KT = ',KT
        WRITE (6,*) '単位が正しくありません。Ｍ（分）を仮定しました'
      ENDIF
*
      IUNITM = IT
*
      RETURN
      END
