*%表題   南北風の格子点データの作成
*%
*%履歴   91/05/14 佐藤正樹       C:\FORT\OORT\GRDVVV.FOR
*%       91/05/16 佐藤正樹       C:\FORT\OORT\GRDVVV.FOR
*%
*%
*-----------------------------------------------------------------------
      PROGRAM  GRDVVV

      INTEGER  NLAT           ! 緯度配列の次元
      PARAMETER ( NLAT = 15 )
      INTEGER  NPRS           ! 圧力配列の次元
      PARAMETER ( NPRS = 8 )

      REAL  VVV(-NLAT:NLAT, 1:NPRS) ! 南北風

      INTEGER  NLAT2           ! 緯度配列の次元
      PARAMETER ( NLAT2 = 18 )
      INTEGER  NPRS2           ! 圧力配列の次元
      PARAMETER ( NPRS2 = 20 )

      REAL  VVV2(-NLAT2:NLAT2, 1:NPRS)  ! 南北風
      REAL  VVV3(-NLAT2:NLAT2, 0:NPRS2) ! 南北風

      INTEGER  ILAT           ! 緯度配列の次元, DOループ
      INTEGER  IPRS           ! 圧力配列の次元, DOループ

      INTEGER  ILAT2          ! 緯度配列の次元, DOループ

*     < 入出力パラメーター >

      INTEGER   IR   / 20 /          ! 入力ユニット番号
      CHARACTER HIFL*16              ! 入力ファイル名

      INTEGER   OR   / 30 /          ! 出力ユニット番号
      CHARACTER HOFL*16              ! 出力ファイル名

      CHARACTER  HNFORM*16           ! 文字型変数の入力形式
      CHARACTER  HXFORM*16           ! 実数型変数の入力形式
      CHARACTER  HXNAME*16           ! 変数名

*     < GTOOL >

      INTEGER  NCC
      INTEGER  NDC
      PARAMETER  ( NCC=16, NDC=64 )
*
      CHARACTER  HHEAD ( NDC )*(NCC)
*
      CHARACTER  HDSET *(NCC)
      CHARACTER  HITEM *(NCC)
      CHARACTER  HTITL *(NCC*2)
      CHARACTER  HUNIT *(NCC)
      CHARACTER  HUTIM *(NCC)
      CHARACTER  HAITM1*(NCC)
      CHARACTER  HAITM2*(NCC)
      CHARACTER  HAITM3*(NCC)
      CHARACTER  HEDIT*(NCC)
      CHARACTER  HETTL*(NCC)

      INTEGER    IFNUM
      INTEGER    ITDUR
      REAL       DMIN
      REAL       DMAX
      REAL       DIVS
      REAL       DIVL
      INTEGER    ISTYP

      INTEGER    IYEAR
      INTEGER    IMONTH
      INTEGER    IDAY
      INTEGER    IHOUR
      INTEGER    IMIN
      INTEGER    ISEC

*-----------------------------------------------------------------------
*     < 出力形式 >

      HNFORM='(A16)'
      HXFORM='(5E16.6)'

*-----------------------------------------------------------------------
*     < 入力データファイル名の入力 >

      WRITE(6,*) '入力ファイル名を入力してください'
      READ(5,*) HIFL
      WRITE(6,*) '出力ファイル名を入力してください'
      READ(5,*) HOFL
      WRITE(6,*) 'HIFL=', HIFL
      WRITE(6,*) 'HOFL=', HOFL

*-----------------------------------------------------------------------
*     < データの入力 >

      CALL  READORG
     I           ( IR,       HIFL,
     O             HXNAME,   VVV,
     D             NLAT,     NPRS )

*-----------------------------------------------------------------------
*     < グリッドの値の作成 >

      VVV(-15,1) = 3.   * VVV(-14, 1) - 2.  * VVV(-13, 1)
      VVV(-15,2) = 3.   * VVV(-14, 2) - 2.  * VVV(-13, 2)
      DO 400 IPRS = 1, NPRS
      DO 410 ILAT = -14, 14
        VVV2(ILAT, IPRS) = VVV(ILAT, IPRS)
 410  CONTINUE
        VVV2(-15, IPRS) = 0.5 * VVV(-14, IPRS) + 0.5 * VVV(-15, IPRS)
        VVV2(15, IPRS)  = 0.5 * VVV(14, IPRS)  + 0.5 * VVV(15, IPRS)
        VVV2(-16, IPRS) =       VVV(-15, IPRS)
        VVV2(16, IPRS)  =       VVV(15, IPRS)

*     極では値をゼロとする

        VVV2(-17, IPRS) = 0.5 * VVV(-15, IPRS)
        VVV2(17, IPRS)  = 0.5 * VVV(15, IPRS)
        VVV2(-18, IPRS) = 0.
        VVV2(18, IPRS)  = 0.
 400  CONTINUE

      DO 500 ILAT2 = -18, 18
        VVV3(ILAT2, 0) = 2.   * VVV2(ILAT2,8) -        VVV2(ILAT2,7)
        VVV3(ILAT2, 1) =        VVV2(ILAT2,8)
        VVV3(ILAT2, 2) =        VVV2(ILAT2,7)
        VVV3(ILAT2, 3) = 0.5  * VVV2(ILAT2,7) + 0.5  * VVV2(ILAT2,6)
        VVV3(ILAT2, 4) =        VVV2(ILAT2,6)
        VVV3(ILAT2, 5) = 0.5  * VVV2(ILAT2,6) + 0.5  * VVV2(ILAT2,5)
        VVV3(ILAT2, 6) =        VVV2(ILAT2,5)
        VVV3(ILAT2, 7) = 0.75 * VVV2(ILAT2,5) + 0.25 * VVV2(ILAT2,4)
        VVV3(ILAT2, 8) = 0.5  * VVV2(ILAT2,5) + 0.5  * VVV2(ILAT2,4)
        VVV3(ILAT2, 9) = 0.25 * VVV2(ILAT2,5) + 0.75 * VVV2(ILAT2,4)
        VVV3(ILAT2,10) =        VVV2(ILAT2,4)
        VVV3(ILAT2,11) = 0.75 * VVV2(ILAT2,4) + 0.25 * VVV2(ILAT2,3)
        VVV3(ILAT2,12) = 0.5  * VVV2(ILAT2,4) + 0.5  * VVV2(ILAT2,3)
        VVV3(ILAT2,13) = 0.25 * VVV2(ILAT2,4) + 0.75 * VVV2(ILAT2,3)
        VVV3(ILAT2,14) =        VVV2(ILAT2,3)
        VVV3(ILAT2,15) = 2./3.* VVV2(ILAT2,3) + 1./3.* VVV2(ILAT2,2)
        VVV3(ILAT2,16) = 1./3.* VVV2(ILAT2,3) + 2./3.* VVV2(ILAT2,2)
        VVV3(ILAT2,17) =        VVV2(ILAT2,2)
        VVV3(ILAT2,18) = 2./3.* VVV2(ILAT2,2) + 1./3.* VVV2(ILAT2,1)
        VVV3(ILAT2,19) = 1./3.* VVV2(ILAT2,2) + 2./3.* VVV2(ILAT2,1)
        VVV3(ILAT2,20) =        VVV2(ILAT2,1)
 500  CONTINUE

*-----------------------------------------------------------------------
*     < パラメーターの設定 >

      HDSET  = 'Oort and Peixoto'
      HITEM  = 'VVV'
      HTITL  = 'Meridional Wind'
      HUNIT  = 'm/s'
      IFNUM  = 1
      HUTIM  = 'SEC'
      ITDUR  = 31536000.
      HAITM1 = 'GLON1'
      HAITM2 = 'GLAT37'
      HAITM3 = 'GPRS21'
      DMIN   = -5.
      DMAX   = 5.
      DIVS   =  0.5
      DIVL   =  1.
      ISTYP  =   1

      HEDIT  = 'YR'
      HETTL  = 'YEAR 63-73'

      IYEAR  = 1963
      IMONTH = 0
      IDAY   = 0
      IHOUR  = 0
      IMIN   = 0
      ISEC   = 0

*-----------------------------------------------------------------------
*     < GTOOL 形式で出力 >

      CALL GTDATA
     I           ( OR,     HOFL,     HXFORM,
     I             VVV3,
     I             HDSET , HITEM , IFNUM ,
     I             HTITL , HUNIT , HUTIM , ITDUR ,
     I             HEDIT,  HETTL,
     I             HAITM1, HAITM2, HAITM3,
     I             DMIN  , DMAX  , DIVS  , DIVL  , ISTYP,
     I             IYEAR , IMONTH, IDAY  , IHOUR , IMIN  , ISEC ,
     D             1,      2*NLAT2+1, NPRS2+1 )

*-----------------------------------------------------------------------
      STOP
      END