*" PACKAGE XMKINIT  !" 初期値作成
*
***********************************************************************
      PROGRAM MKINIT    !" 初期値メインルーチン
*
*   [PARAM]
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)                      !" 格子点数, 波数
      INCLUDE   (ZHDIM)                      !" 文字列文字数
      INCLUDE   (ZCCOM)                      !" 標準物理定数
#else
#include        "zcdim.F"                    !" 格子点数, 波数
#include        "zhdim.F"                    !" 文字列文字数
#include        "zccom.F"                    !" 標準物理定数
#endif
*
*   [VAR]
      REAL       GAU   ( IDIM, JDIM, KMAX )  !" 西風  ｕ
      REAL       GAV   ( IDIM, JDIM, KMAX )  !" 南風  ｖ
      REAL       GAT   ( IDIM, JDIM, KMAX )  !" 温度  Ｔ
      REAL       GAPS  ( IDIM, JDIM       )  !" 地表気圧
      REAL       GAQ   ( IDIM, JDIM, KMAX )  !" 比湿  ｑ
*"       : 格子点データ(t) <DYNMCS>  格子点データ(t+Δt)
*
      REAL       GBU   ( IDIM, JDIM, KMAX )  !" 西風  ｕ
      REAL       GBV   ( IDIM, JDIM, KMAX )  !" 南風  ｖ
      REAL       GBT   ( IDIM, JDIM, KMAX )  !" 温度  Ｔ
      REAL       GBPS  ( IDIM, JDIM       )  !" 地表気圧
      REAL       GBQ   ( IDIM, JDIM, KMAX )  !" 比湿  ｑ
*"       : 格子点データ(t-Δt) <DYNMCS>  格子点データ(t)
*
*
*   [INTERNAL PARM] 
      INTEGER    ISTEP                 !" 通しステップ数
      INTEGER    ITA                   !" 通し時間(t)
      INTEGER    ITB                   !" 通し時間(t-Δt)
      INTEGER    IDATEA( 6 )           !" 時刻：年月日時分秒
      INTEGER    IDATEB( 6 )           !" 時刻：年月日時分秒
*"       : 時刻等
*
      DATA       ITA, ITB     / 0 , 0 /
      DATA       IDATEA       / 1990, 1, 1, 0, 0, 0 /
      DATA       IDATEB       / 1990, 1, 1, 0, 0, 0 /
      DATA       ISTEP        / 0  /
*
      NAMELIST  /NMDATE/ ITA, ITB, IDATEA, IDATEB, ISTEP
*
      CHARACTER  HDSET *(NCC)
      CHARACTER  HFILE *(NFILN)
      CHARACTER  HDFMT *(NCC)
      DATA       HDFMT  / 'UR8' /
      INTEGER    JFLRST 
      DATA       JFLRST / 41 /
*
*   [INTERNAL WORK] 
      REAL       ALAT  ( JDIM )        !" 緯度
      REAL       DLAT  ( JDIM )        !" 緯度荷重
      REAL       ALON  ( IDIM )        !" 経度
      REAL       DLON  ( IDIM )        !" 経度荷重
      REAL       SIG   ( KMAX )        !" σレベル(整数)
      REAL       SIGM  (KMAX+1)        !" σレベル(半整数)
      REAL       DSIG  ( KMAX )        !" Δσ(整数)
      REAL       DSIGM (KMAX+1)        !" Δσ(半整数)
*
      CALL YPREP
      CALL PCONST
      CALL GTOPEN
*
      WRITE( 6,*     ) ' DATA NAME  ?'
      READ ( 5,'(A)' ) HDSET
      WRITE( 6,*     ) ' FILE NAME  ?'
      READ ( 5,'(A)' ) HFILE
      CALL GFWOPN ( JFLRST, HFILE )
      WRITE ( 6,NMDATE )
      WRITE ( 6,*      ) ' ENTER NAMELST NMDATE?'
      READ  ( 5,NMDATE, END=1910 )
 1910 CONTINUE
*
      CALL GTCSET( 'DDSET' , HDSET     )
*
      CALL SETCOR
     O         ( ALON  , DLON  ,
     O           ALAT  , DLAT  ,
     O           SIG   , DSIG  ,
     O           SIGM  , DSIGM  )
*
      CALL INISET               !" 初期値設定
     O         ( GAU   , GAV   , GAT   , GAPS  , GAQ   ,
     I           SIG                                      )
*
      CALL COPY ( GBU  , GAU  , IDIM*JDIM*KMAX )
      CALL COPY ( GBV  , GAV  , IDIM*JDIM*KMAX )
      CALL COPY ( GBT  , GAT  , IDIM*JDIM*KMAX )
      CALL COPY ( GBQ  , GAQ  , IDIM*JDIM*KMAX )
      CALL COPY ( GBPS , GAPS , IDIM*JDIM      )
*
      CALL WRRSTX           !" 基本リスタート・ファイルの書き込み
     I         ( GAU   , GAV   , GAT   , GAPS  , GAQ   ,
     I           GBU   , GBV   , GBT   , GBPS  , GBQ   ,
     I           ITA   , ITB   , IDATEA, IDATEB, ISTEP ,
     I           JFLRST, HDFMT                            )
*
      CALL YFINE
*
      STOP
      END
**********************************************************************
      SUBROUTINE INISET        !" 初期値設定
     O        ( GAU   , GAV   , GAT   , GAPS  , GAQ   ,
     I          SIG                                    )
*
*
*   [PARAM] 
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)                      !" 格子点数, 波数
#else
#include        "zcdim.F"                    !" 格子点数, 波数
#endif
*
*   [OUTPUT] 
      REAL       GAU   ( IDIM, JDIM, KMAX ),
     &           GAV   ( IDIM, JDIM, KMAX ),
     &           GAT   ( IDIM, JDIM, KMAX ),
     &           GAPS  ( IDIM, JDIM       )
      REAL       GAQ   ( IDIM, JDIM, KMAX )
      REAL       SIG   ( KMAX )
*
*   [INTERNAL PARM] 
      REAL       TPRTRB
      DATA       TPRTRB       / 0.1 /
*
*   [INTERNAL WORK] 
      REAL       RANDOM( IDIM, JDIM, KMAX )
      REAL       T
      INTEGER    I, J, K
*
*
      CALL RESET ( GAU   , IDIM*JDIM*KMAX )
      CALL RESET ( GAV   , IDIM*JDIM*KMAX )
      CALL RESET ( GAT   , IDIM*JDIM*KMAX )
      CALL RESET ( GAQ   , IDIM*JDIM*KMAX )
      CALL RESET ( GAPS  , IDIM*JDIM      )
*
*" << INIT : これが初期値だ >> 
*
c$$$      write (6,*) ' THE VALUE OF TEMPERATURE?'
c$$$      read  (5,*) T
*
      T = 280.0
*
      DO 1000 J = 1, JDIM
        DO 1000 I = 1, IDIM
          GAT  ( I,J,1 ) =  5.59681E+02
          GAT  ( I,J,2 ) =   5.58717E+02
          GAT  ( I,J,3 ) =   5.56753E+02
          GAT  ( I,J,4 ) =   5.53369E+02
          GAT  ( I,J,5 ) =   5.48377E+02
          GAT  ( I,J,6 ) =   5.41854E+02
          GAT  ( I,J,7 ) =   5.33831E+02
          GAT  ( I,J,8 ) =   5.24323E+02
          GAT  ( I,J,9 ) =   5.13934E+02
          GAT  ( I,J,10 ) =   5.03058E+02
          GAT  ( I,J,11 ) =   4.91655E+02
          GAT  ( I,J,12 ) =   4.79702E+02
          GAT  ( I,J,13 ) =   4.67222E+02
          GAT  ( I,J,14 ) =   4.52661E+02
          GAT  ( I,J,15 ) =   4.32033E+02
          GAT  ( I,J,16 ) =   4.07244E+02
          GAT  ( I,J,17 ) =   3.85432E+02
          GAT  ( I,J,18 ) =   3.65854E+02
          GAT  ( I,J,19 ) =   3.48171E+02
          GAT  ( I,J,20 ) =   3.32045E+02
          GAT  ( I,J,21 ) =   3.17357E+02
          GAT  ( I,J,22 ) =   3.03883E+02
          GAT  ( I,J,23 ) =   2.91484E+02
          GAT  ( I,J,24 ) =   2.80037E+02
          GAT  ( I,J,25 ) =   2.69404E+02
          GAT  ( I,J,26 ) =   2.59504E+02
          GAT  ( I,J,27 ) =   2.50317E+02
          GAT  ( I,J,28 ) =   2.41721E+02
          GAT  ( I,J,29 ) =   2.33632E+02
          GAT  ( I,J,30 ) =   2.29044E+02
          GAT  ( I,J,31 ) =   2.28551E+02
          GAT  ( I,J,32 ) =   2.28212E+02                          
*
          GAQ  ( I,J,1 ) =  9.91311E-01
          GAQ  ( I,J,2 ) =   9.90328E-01
          GAQ  ( I,J,3 ) =   9.88327E-01
          GAQ  ( I,J,4 ) =   9.84855E-01
          GAQ  ( I,J,5 ) =   9.79674E-01
          GAQ  ( I,J,6 ) =   9.72768E-01
          GAQ  ( I,J,7 ) =   9.64103E-01
          GAQ  ( I,J,8 ) =   9.53523E-01
          GAQ  ( I,J,9 ) =   9.41540E-01
          GAQ  ( I,J,10 ) =   9.28580E-01
          GAQ  ( I,J,11 ) =   9.14512E-01
          GAQ  ( I,J,12 ) =   8.99206E-01
          GAQ  ( I,J,13 ) =   8.82572E-01
          GAQ  ( I,J,14 ) =   8.62772E-01
          GAQ  ( I,J,15 ) =   8.33747E-01
          GAQ  ( I,J,16 ) =   7.91045E-01
          GAQ  ( I,J,17 ) =   7.50750E-01
          GAQ  ( I,J,18 ) =   7.11893E-01
          GAQ  ( I,J,19 ) =   6.74519E-01
          GAQ  ( I,J,20 ) =   6.38188E-01
          GAQ  ( I,J,21 ) =   6.03176E-01
          GAQ  ( I,J,22 ) =   5.69272E-01
          GAQ  ( I,J,23 ) =   5.36432E-01
          GAQ  ( I,J,24 ) =   5.04636E-01
          GAQ  ( I,J,25 ) =   4.73748E-01
          GAQ  ( I,J,26 ) =   4.43658E-01
          GAQ  ( I,J,27 ) =   4.14600E-01
          GAQ  ( I,J,28 ) =   3.86415E-01
          GAQ  ( I,J,29 ) =   3.58812E-01
          GAQ  ( I,J,30 ) =   3.32145E-01
          GAQ  ( I,J,31 ) =   3.32145E-01
          GAQ  ( I,J,32 ) =   3.32145E-01                          
*
          DO 1000 K = 1, KMAX
            GAU  ( I,J,K ) = 0.
            GAV  ( I,J,K ) = 0.
 1000 CONTINUE
*
      DO 2000 J = 1, JDIM
        DO 2000 I = 1, IDIM
            GAPS ( I,J   ) = 1000.
 2000 CONTINUE
*
*" << RANDOM : 乱数の付加 >> 
*
CCC   CALL \SGU1M( IDIM*JDIM*KMAX, 0, RANDOM, IER )
      DO 3000 K = 1, KMAX
         DO 3000 J = 1, JDIM
            DO 3000 I = 1, IDIM
               RANDOM( I,J,K )
     &         =  SIN(  REAL(I*J*(KMAX-K))
     &                / REAL(IMAX*JMAX*KMAX)*10. ) + k*0.15
 3000 CONTINUE
*
      DO 3100 K = 1, KMAX
         DO 3100 J = 1, JDIM
            DO 3100 I = 1, IDIM
               GAT ( I,J,K ) = GAT ( I,J,K )
     &                       + RANDOM( I,J,K ) * TPRTRB
 3100 CONTINUE
*
      RETURN
      END
