*" PACKAGE XMKINIT  !" 初期値作成
*"       v00l32:1 次元平衡解初期値(Ts=330K)
*
***********************************************************************
      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 )
c$$$      CALL RESET ( GAT   , IDIM*JDIM*KMAX )
c$$$      CALL RESET ( GAQ   , IDIM*JDIM*KMAX )
      CALL RESET ( GAPS  , IDIM*JDIM      )
*
*
*" << INIT : これが初期値だ >> 
*
c$$$      write (6,*) ' THE VALUE OF TEMPERATURE?'
c$$$      read  (5,*) T
*
      DO 1000 K = 1, KMAX
        DO 1000 J = 1, JDIM
          DO 1000 I = 1, IDIM
            GAU  ( I,J,K ) = 0.
            GAV  ( I,J,K ) = 0.
c$$$           GAT  ( 1,1,1 ) = 280.0
c$$$           GAQ  ( I,1,1 ) = 0.001
 1000 CONTINUE
*
      GAT(1,1,1)  = 3.29864E+02
      GAT(1,1,2)  = 3.29452E+02
      GAT(1,1,3)  = 3.28613E+02
      GAT(1,1,4)  = 3.27158E+02
      GAT(1,1,5)  = 3.24996E+02
      GAT(1,1,6)  = 3.22138E+02
      GAT(1,1,7)  = 3.18573E+02
      GAT(1,1,8)  = 3.14267E+02
      GAT(1,1,9)  = 3.09453E+02
      GAT(1,1,10) = 3.04284E+02
      GAT(1,1,11) = 2.98706E+02
      GAT(1,1,12) = 2.92658E+02
      GAT(1,1,13) = 2.86083E+02
      GAT(1,1,14) = 2.78048E+02
      GAT(1,1,15) = 2.65727E+02
      GAT(1,1,16) = 2.46922E+02
      GAT(1,1,17) = 2.32432E+02
      GAT(1,1,18) = 2.32118E+02
      GAT(1,1,19) = 2.31958E+02
      GAT(1,1,20) = 2.31876E+02
      GAT(1,1,21) = 2.31834E+02
      GAT(1,1,22) = 2.31813E+02
      GAT(1,1,23) = 2.31802E+02
      GAT(1,1,24) = 2.31797E+02
      GAT(1,1,25) = 2.31794E+02
      GAT(1,1,26) = 2.31793E+02
      GAT(1,1,27) = 2.31792E+02
      GAT(1,1,28) = 2.31792E+02
      GAT(1,1,29) = 2.31791E+02
      GAT(1,1,30) = 2.31791E+02
      GAT(1,1,31) = 2.31791E+02
      GAT(1,1,32) = 2.31791E+02
*
      GAQ(1,1,1)  = 1.46595E-01
      GAQ(1,1,2)  = 1.45911E-01
      GAQ(1,1,3)  = 1.44516E-01
      GAQ(1,1,4)  = 1.42098E-01
      GAQ(1,1,5)  = 1.38497E-01
      GAQ(1,1,6)  = 1.33714E-01
      GAQ(1,1,7)  = 1.27736E-01
      GAQ(1,1,8)  = 1.20479E-01
      GAQ(1,1,9)  = 1.12319E-01
      GAQ(1,1,10) = 1.03558E-01
      GAQ(1,1,11) = 9.41318E-02
      GAQ(1,1,12) = 8.39855E-02
      GAQ(1,1,13) = 7.31105E-02
      GAQ(1,1,14) = 6.03649E-02
      GAQ(1,1,15) = 4.22839E-02
      GAQ(1,1,16) = 1.86678E-02
      GAQ(1,1,17) = 3.23171E-03
      GAQ(1,1,18) = 3.23171E-03
      GAQ(1,1,19) = 3.23171E-03
      GAQ(1,1,20) = 3.23171E-03
      GAQ(1,1,21) = 3.23171E-03
      GAQ(1,1,22) = 3.23171E-03
      GAQ(1,1,23) = 3.23171E-03
      GAQ(1,1,24) = 3.23171E-03
      GAQ(1,1,25) = 3.23171E-03
      GAQ(1,1,26) = 3.23171E-03
      GAQ(1,1,27) = 3.23171E-03
      GAQ(1,1,28) = 3.23171E-03
      GAQ(1,1,29) = 3.23171E-03
      GAQ(1,1,30) = 3.23171E-03
      GAQ(1,1,31) = 3.23171E-03
      GAQ(1,1,32) = 3.23171E-03
*
      DO 2000 J = 1, JDIM
        DO 2000 I = 1, IDIM
            GAPS ( I,J   ) = 1000.
 2000 CONTINUE
*
*" << RANDOM : 乱数の付加 >> 
*
c$$$CCC   CALL \SGU1M( IDIM*JDIM*KMAX, 0, RANDOM, IER )
c$$$      DO 3000 K = 1, KMAX
c$$$         DO 3000 J = 1, JDIM
c$$$            DO 3000 I = 1, IDIM
c$$$               RANDOM( I,J,K )
c$$$     &         =  SIN(  REAL(I*J*(KMAX-K))
c$$$     &                / REAL(IMAX*JMAX*KMAX)*10. ) + k*0.15
c$$$ 3000 CONTINUE
c$$$*
c$$$      DO 3100 K = 1, KMAX
c$$$         DO 3100 J = 1, JDIM
c$$$            DO 3100 I = 1, IDIM
c$$$               GAT ( I,J,K ) = GAT ( I,J,K )
c$$$     &                       + RANDOM( I,J,K ) * TPRTRB
c$$$ 3100 CONTINUE
*
      RETURN
      END
