*" PACKAGE XMKINIT  !" 初期値作成
*"       v00l32:1 次元平衡解初期値(Ts=350K)
*
***********************************************************************
      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.49864E+02
      GAT(1,1,2) = 3.49452E+02
      GAT(1,1,3) = 3.48612E+02
      GAT(1,1,4) = 3.47159E+02
      GAT(1,1,5) = 3.45003E+02
      GAT(1,1,6) = 3.42164E+02
      GAT(1,1,7) = 3.38636E+02
      GAT(1,1,8) = 3.34403E+02
      GAT(1,1,9) = 3.29709E+02
      GAT(1,1,10) = 3.24718E+02
      GAT(1,1,11) = 3.19397E+02
      GAT(1,1,12) = 3.13718E+02
      GAT(1,1,13) = 3.07672E+02
      GAT(1,1,14) = 3.00473E+02
      GAT(1,1,15) = 2.89984E+02
      GAT(1,1,16) = 2.76613E+02
      GAT(1,1,17) = 2.64185E+02
      GAT(1,1,18) = 2.52299E+02
      GAT(1,1,19) = 2.40683E+02
      GAT(1,1,20) = 2.33540E+02
      GAT(1,1,21) = 2.32881E+02
      GAT(1,1,22) = 2.32543E+02
      GAT(1,1,23) = 2.32370E+02
      GAT(1,1,24) = 2.32283E+02
      GAT(1,1,25) = 2.32238E+02
      GAT(1,1,26) = 2.32215E+02
      GAT(1,1,27) = 2.32203E+02
      GAT(1,1,28) = 2.32197E+02
      GAT(1,1,29) = 2.32194E+02
      GAT(1,1,30) = 2.32193E+02
      GAT(1,1,31) = 2.32192E+02
      GAT(1,1,32) = 2.32192E+02
*
      GAQ(1,1,1) = 2.99081E-01
      GAQ(1,1,2) = 2.98338E-01
      GAQ(1,1,3) = 2.96824E-01
      GAQ(1,1,4) = 2.94198E-01
      GAQ(1,1,5) = 2.90283E-01
      GAQ(1,1,6) = 2.85073E-01
      GAQ(1,1,7) = 2.78545E-01
      GAQ(1,1,8) = 2.70593E-01
      GAQ(1,1,9) = 2.61614E-01
      GAQ(1,1,10) = 2.51922E-01
      GAQ(1,1,11) = 2.41423E-01
      GAQ(1,1,12) = 2.30024E-01
      GAQ(1,1,13) = 2.17665E-01
      GAQ(1,1,14) = 2.02940E-01
      GAQ(1,1,15) = 1.81360E-01
      GAQ(1,1,16) = 1.50266E-01
      GAQ(1,1,17) = 1.21122E-01
      GAQ(1,1,18) = 9.33493E-02
      GAQ(1,1,19) = 6.71466E-02
      GAQ(1,1,20) = 4.25749E-02
      GAQ(1,1,21) = 4.25749E-02
      GAQ(1,1,22) = 4.25749E-02
      GAQ(1,1,23) = 4.25749E-02
      GAQ(1,1,24) = 4.25749E-02
      GAQ(1,1,25) = 4.25749E-02
      GAQ(1,1,26) = 4.25749E-02
      GAQ(1,1,27) = 4.25749E-02
      GAQ(1,1,28) = 4.25749E-02
      GAQ(1,1,29) = 4.25749E-02
      GAQ(1,1,30) = 4.25749E-02
      GAQ(1,1,31) = 4.25749E-02
      GAQ(1,1,32) = 4.25749E-02
*
      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
