!= 蛻晄悄蛟､繝��繧ｿ謠蝉ｾ�
!
!= Prepare initial data
!
! Authors::   Yasuhiro MORIKAWA, Yoshiyuki O. TAKAHASHI (code by Taro KITANO is included)
! Version::   $Id: initial_data.f90,v 1.16 2015/02/17 23:50:42 yot Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2008. All rights reserved.
! License::   See COPYRIGHT[link:../../../COPYRIGHT]
!

module initial_data
  !
  != 蛻晄悄蛟､繝��繧ｿ謠蝉ｾ�
  !
  != Prepare initial data
  !
  ! 蛻晄悄蛟､繝��繧ｿ縺ｮ繧ｵ繝ｳ繝励Ν繧呈署萓帙＠縺ｾ縺�.
  !
  ! 迴ｾ蝨ｨ縺ｯ莉･荳九�繝��繧ｿ繧呈署萓帙＠縺ｾ縺�.
  !
  ! * Small Disturbance of Temperature
  !   * 鬚ｨ騾�: 0 [m/s], 蝨ｰ陦ｨ髱｢豌怜悸: 1.0e+5 [Pa], 豈疲ｹｿ: 1.0e-10 [kg kg-1]
  !   * 貂ｩ蠎ｦ: 250 [K] 縺ｫ蠕ｮ蟆乗得荵ｱ繧貞刈縺医◆繧ゅ�
  !
  ! * [AGCM 5.3]{http://www.gfd-dennou.org/library/agcm5} Default
  !   * 鬚ｨ騾�: 0 [m/s], 蝨ｰ陦ｨ髱｢豌怜悸: 1.0e+5 [Pa], 豈疲ｹｿ: 1.0e-10 [kg kg-1]
  !   * 貂ｩ蠎ｦ: 250 [K] 縺ｫ蠕ｮ蟆乗得荵ｱ繧貞刈縺医◆繧ゅ�
  !
  ! * Sugiyama et al. (2008)
  !   * 譛ｨ譏溷､ｧ豌励ｒ諠ｳ螳壹＠縺�, Sugiyama et al. (2008) 縺ｧ逕ｨ縺�ｉ繧後※縺�◆
  !     蛻晄悄蛟､繧呈ｨ｡蛟｣縺吶ｋ.
  !   * 鬚ｨ騾�: 0 [m/s], 蝨ｰ陦ｨ髱｢豌怜悸: 3.0e+6 [Pa]
  !   * 貂ｩ蠎ｦ: $ \sigma = 1 $ 縺ｧ 490 [K] 縺ｨ縺�, 豌怜悸 1.0e+4 縺ｨ縺ｪ繧矩ｫ伜ｺｦ縺ｾ縺ｧ,
  !     貂ｩ菴堺ｸ螳壹〒 (荵ｾ辯･譁ｭ辭ｱ邱壹↓豐ｿ縺｣縺ｦ) 鬮伜ｺｦ縺ｫ莨ｴ縺�ｸｩ蠎ｦ繧呈ｸ帛ｰ代＆縺帙ｋ.
  !     豌怜悸 1.0e+4 莉･荳九�鬮伜ｺｦ縺ｧ縺ｯ貂ｩ蠎ｦ荳螳壹→縺吶ｋ.
  !   * 豈疲ｹｿ: $ \sigma = 1 $ 縺ｧ 6.11641e-3 [kg kg-1] 縺ｨ縺�,
  !     豈疲ｹｿ縺碁｣ｽ蜥梧ｯ疲ｹｿ縺ｮ 75 % 縺ｨ縺ｪ繧矩ｫ伜ｺｦ縺ｾ縺ｧ縺ｯ荳螳壹→縺吶ｋ.
  !     縺昴�鬮伜ｺｦ莉･荳翫〒縺ｯ, 豈疲ｹｿ繧帝｣ｽ蜥梧ｯ疲ｹｿ縺ｮ 75 % 縺ｨ縺吶ｋ.
  !
  ! Prepare sample data of initial data (restart data)
  !
  ! Now, following data are provided.
  !
  ! * Small Disturbance of Temperature
  !   * Velocity: 0 [m/s], Surface pressure: 1.0e+5 [Pa],
  !     Specific humidity: 1.0e-10 [kg kg-1]
  !   * Temperature: 250 [K] and perturbation
  !
  ! * [AGCM 5.3]{http://www.gfd-dennou.org/library/agcm5} Default
  !   * Velocity: 0 [m/s], Surface pressure: 1.0e+5 [Pa],
  !     Specific humidity: 1.0e-10 [kg kg-1]
  !   * Temperature: 250 [K] and perturbation
  !
  ! * Sugiyama et al. (2008)
  !   * Initial data like a Jovian atmosphere
  !     that is used in Sugiyama et al. (2008) is imitated.
  !   * Velocity: 0 [m/s], Surface pressure: 3.0e+6 [Pa]
  !   * Temperature: 490 [K] at $ \sigma = 1 $ .
  !     And it is declined with constant potential temperature
  !     (along dry adiabat line)
  !     below where air pressure is 1.0e+4.
  !     It is constant above where air pressure is 1.0e+4.
  !   * Specific humidity: 6.11641e-3 [kg kg-1] at $ \sigma = 1 $ .
  !     And it is constant below where it is same as 75 % of
  !     saturation specific humidity.
  !     Above that, specific humidity is 75 % of saturation specific humidity.
  !
  !== Procedures List
  !
  ! SetInitData   :: 蛻晄悄蛟､繝��繧ｿ蜿門ｾ�
  ! ------------  :: ------------
  ! SetInitData   :: Get initial data
  !
  !== NAMELIST
  !
  ! NAMELIST#initial_data_nml
  !

  ! 繝｢繧ｸ繝･繝ｼ繝ｫ蠑慕畑 ; USE statements
  !

  ! 譬ｼ蟄千せ險ｭ螳�
  ! Grid points settings
  !
  use gridset, only: imax, & ! 邨悟ｺｦ譬ｼ蟄千せ謨ｰ.
                             ! Number of grid points in longitude
    &                jmax, & ! 邱ｯ蠎ｦ譬ｼ蟄千せ謨ｰ.
                             ! Number of grid points in latitude
    &                kmax    ! 驩帷峩螻､謨ｰ.
                             ! Number of vertical level

  ! 邨��縺ｫ髢｢繧上ｋ驟榊�縺ｮ險ｭ螳�
  ! Settings of array for atmospheric composition
  !
  use composition, only: &
    &                    ncmax, &
                              ! 謌仙�縺ｮ謨ｰ
                              ! Number of composition
    &                    IndexH2OVap

  ! 遞ｮ蛻･蝙九ヱ繝ｩ繝｡繧ｿ
  ! Kind type parameter
  !
  use dc_types, only: DP, &      ! 蛟咲ｲｾ蠎ｦ螳滓焚蝙�. Double precision.
    &                 STRING     ! 譁�ｭ怜�.       Strings.

  ! 遞ｮ蛻･蝙九ヱ繝ｩ繝｡繧ｿ
  ! Kind type parameter
  !
  use dc_types, only: DP     ! 蛟咲ｲｾ蠎ｦ螳滓焚蝙�. Double precision.

  ! 繝｡繝�そ繝ｼ繧ｸ蜃ｺ蜉�
  ! Message output
  !
  use dc_message, only: MessageNotify

  ! 螳｣險譁� ; Declaration statements
  !
  implicit none
  private

  ! 蜈ｬ髢区焔邯壹″
  ! Public procedure
  !
  public:: SetInitData
  public:: InitDataInit

  ! 蜈ｬ髢句､画焚
  ! Public variables
  !
  logical, save, public:: initial_data_inited = .false.
                              ! 蛻晄悄險ｭ螳壹ヵ繝ｩ繧ｰ.
                              ! Initialization flag

  character(STRING), save, public:: Pattern
                              ! 蛻晄悄蛟､繝��繧ｿ縺ｮ繝代ち繝ｼ繝ｳ.
                              ! 莉･荳九�繝代ち繝ｼ繝ｳ繧帝∈謚槫庄閭ｽ.
                              !
                              ! Initial data pattern
                              ! Available patterns are as follows.
                              !
                              ! * "Small Disturbance of Temperature" (default value)
                              ! * "AGCM 5.3 Default"
                              ! * "Sugiyama et al. (2008)"
                              !
  real(DP), save, public:: TempAvr
                              ! $ \bar{T} $ .     貂ｩ蠎ｦ蟷ｳ蝮�､. Mean temperature
  real(DP), save, public:: PsAvr
                              ! $ \bar{p_s} $ .   蝨ｰ陦ｨ髱｢豌怜悸蟷ｳ蝮�､. Mean surface pressure
  real(DP), save, public:: QVapAvr
                              ! $ \bar{q} $ .     豈疲ｹｿ蟷ｳ蝮�､. Mean specific humidity
  real(DP), save, public:: Ueq
                              ! $ u_{eq} $ .      襍､驕謎ｸ翫�譚ｱ隘ｿ鬚ｨ騾�. Eastward wind on the equator
  real(DP), save, public:: UGeos
                              ! $ u_{g} $ .       Eastward geostrophic wind
  real(DP), save, public:: VGeos
                              ! $ v_{g} $ .       Northward geostrophic wind

  ! 髱槫�髢句､画焚
  ! Private variables
  !

  character(*), parameter:: module_name = 'initial_data'
                              ! 繝｢繧ｸ繝･繝ｼ繝ｫ縺ｮ蜷咲ｧｰ.
                              ! Module name
  character(*), parameter:: version = &
    & '$Name:  $' // &
    & '$Id: initial_data.f90,v 1.16 2015/02/17 23:50:42 yot Exp $'
                              ! 繝｢繧ｸ繝･繝ｼ繝ｫ縺ｮ繝舌�繧ｸ繝ｧ繝ｳ
                              ! Module version

contains

  !--------------------------------------------------------------------------------------

  subroutine SetInitData( &
    & xyz_U, xyz_V, xyz_Temp, xyzf_QMix, xy_Ps &   ! (out)
    & )
    !
    ! 蛻晄悄蛟､繝��繧ｿ縺ｮ繧ｵ繝ｳ繝励Ν繧呈署萓帙＠縺ｾ縺�.
    !
    ! Prepare sample data of initial data
    !

    ! 繝｢繧ｸ繝･繝ｼ繝ｫ蠑慕畑 ; USE statements
    !

    ! 蠎ｧ讓吶ョ繝ｼ繧ｿ險ｭ螳�
    ! Axes data settings
    !
    use axesset, only: &
      & x_Lon, &
                              ! $ \lambda $ [rad.] . 邨悟ｺｦ. Longitude
      & y_Lat, &
                              ! $ \varphi $ [rad.] . 邱ｯ蠎ｦ. Latitude
      & z_Sigma
                              ! $ \sigma $ 繝ｬ繝吶Ν (謨ｴ謨ｰ).
                              ! Full $ \sigma $ level

    ! 譁�ｭ怜�謫堺ｽ�
    ! Character handling
    !
    use dc_string, only: LChar

    ! 繝輔ぃ繧､繝ｫ縺九ｉ 1 谺｡蜈��繝ｭ繝輔ぃ繧､繝ｫ繧定ｪｭ繧薙〒險ｭ螳壹☆繧�.
    ! read 1-D profile from a file and set it
    !
    use set_1d_profile, only : Set1DProfilePs, Set1DProfileAtm

    ! 迚ｩ逅��謨ｰ蟄ｦ螳壽焚險ｭ螳�
    ! Physical and mathematical constants settings
    !
    use constants0, only: &
      & PI                    ! $ \pi $.
                              ! 蜀�捉邇�. Circular constant

    ! 邨��縺ｫ髢｢繧上ｋ驟榊�縺ｮ險ｭ螳�
    ! Settings of array for atmospheric composition
    !
    use composition, only: &
      &                    a_QMixName, &
      &                    CompositionInqIndex

    !
    ! Utility module for advection test
    !
    use adv_test, only: AdvTestSetICs

    ! 螳｣險譁� ; Declaration statements
    !
    implicit none
    real(DP), intent(out):: xyz_U  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ u $ .   譚ｱ隘ｿ鬚ｨ騾�. Eastward wind
    real(DP), intent(out):: xyz_V  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ v $ .   蜊怜圏鬚ｨ騾�. Northward wind
    real(DP), intent(out):: xyz_Temp  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ T $ .   貂ｩ蠎ｦ. Temperature
    real(DP), intent(out):: xyzf_QMix  (0:imax-1, 1:jmax, 1:kmax, 1:ncmax)
                              ! $ q $ .   豈疲ｹｿ. Specific humidity
    real(DP), intent(out):: xy_Ps (0:imax-1, 1:jmax)
                              ! $ p_s $ . 蝨ｰ陦ｨ髱｢豌怜悸. Surface pressure

    ! 菴懈･ｭ螟画焚
    ! Work variables
    !
    real(DP) :: xyz_Press(0:imax-1, 1:jmax, 1:kmax)

    integer:: i               ! 邨悟ｺｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in longitude
    integer:: j               ! 邱ｯ蠎ｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in latitude
    integer:: k               ! 驩帷峩譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in vertical direction
    integer:: n

    ! 螳溯｡梧枚 ; Executable statement

    if ( .not. initial_data_inited ) then
      call MessageNotify( 'E', module_name, 'This module has not been initialized.' )
    end if

    select case ( LChar( trim(Pattern) ) )
    case ( 'small disturbance of temperature' )
      !
      ! 蠕ｮ蟆上↑貂ｩ蠎ｦ謫ｾ荵ｱ縺ｮ縺ゅｋ髱呎ｭ｢蝣ｴ
      ! Stationary field with small disturbance of temperature
      !

      xyz_U    = 0.0_DP
      xyz_V    = 0.0_DP
      xyz_Temp = TempAvr
      xy_Ps    = PsAvr
      n = IndexH2OVap
      xyzf_QMix(:,:,:,n) = QVapAvr
      do n = 1, ncmax
        if ( n /= IndexH2OVap ) then
          xyzf_QMix(:,:,:,n) = 0.0_DP
        end if
      end do
      do n = 1, ncmax
        if ( a_QMixName(n) == 'QAr' ) then
          xyzf_QMix(:,:,:,n) = 0.016_DP * 40.0_DP / 44.0_DP ! Assuming Ar
        end if
      end do
!!$      n = CompositionInqIndex( '' )
!!$      xyzf_QMix(:,:,:,n) = 0.0_DP

      ! 貂ｩ蠎ｦ縺ｫ謫ｾ荵ｱ繧剃ｸ弱∴繧�
      ! Add perturbation to temperature
      !
      do k = 1, kmax
        do j = 1, jmax
          do i = 0, imax - 1
            xyz_Temp(i,j,k) = &
              &    xyz_Temp(i,j,k) &
              &  + 0.1_DP * sin ( x_Lon(i) * y_Lat(j) ) &
              &  - 0.1_DP * ( 1.0_DP - z_Sigma(k) )
          end do
        end do
      end do

      ! 譚ｱ隘ｿ鬚ｨ騾溘ｒ荳弱∴繧�
      ! Add eastward wind
      !
      do j = 1, jmax
        xyz_U(:,j,:) = Ueq * cos(y_Lat(j))
      end do

    case ( 'agcm 5.3 default' )
      !
      ! AGCM5.3 縺ｮ繝�ヵ繧ｩ繝ｫ繝亥�譛溷､
      ! AGCM5.3 default initial values
      !

      xyz_U    = 0.0_DP
      xyz_V    = 0.0_DP
      xyz_Temp = TempAvr
      xy_Ps    = PsAvr
      n = IndexH2OVap
      xyzf_QMix(:,:,:,n) = QVapAvr
      do n = 1, ncmax
        if ( n /= IndexH2OVap ) then
          xyzf_QMix(:,:,:,n) = 0.0_DP
        end if
      end do

      ! 貂ｩ蠎ｦ縺ｫ謫ｾ荵ｱ繧剃ｸ弱∴繧�
      ! Add perturbation to temperature
      !
      do k = 1, kmax
        do j = 1, jmax
          do i = 0, imax - 1
            xyz_Temp(i,j,k) = &
              &    xyz_Temp(i,j,k) &
              &  + 0.1_DP &
              &    * sin ( real( ( i + 1 ) &
              &                  * ( jmax - j + 1 ) &
              &                  * ( kmax - k ), DP ) &
              &            / real( imax &
              &                    * jmax &
              &                    * kmax, DP ) * 10.0_DP &
              &                 )
          end do
        end do
      end do

      ! 譚ｱ隘ｿ鬚ｨ騾溘ｒ荳弱∴繧�
      ! Add eastward wind
      !
      do j = 1, jmax
        xyz_U(:,j,:) = Ueq * cos(y_Lat(j))
      end do

    case ( 'sugiyama et al. (2008)' )
      !
      ! Sugiyama et al. (2008) 縺ｮ蛻晄悄蛟､
      ! Initial values of Sugiyama et al. (2008)
      !
      call Sugiyamaetal2008InitData( &
        & xyz_U, xyz_V, xyz_Temp, xyzf_QMix(:,:,:,IndexH2OVap), xy_Ps &   ! (out)
        & )
      do n = 1, ncmax
        if ( n /= IndexH2OVap ) then
          xyzf_QMix(:,:,:,n) = 0.0_DP
        end if
      end do

    case ( 'polvani et al. (2004)' )
      !
      ! Polvani et al. (2004) 縺ｮ蛻晄悄蛟､
      ! Initial values of Polvani et al. (2004)
      !
      n = IndexH2OVap
      call Polvanietal2004InitData( &
        & xyz_U, xyz_V, xyz_Temp, xyzf_QMix(:,:,:,n), xy_Ps &   ! (out)
        & )
      do n = 1, ncmax
        if ( n /= IndexH2OVap ) then
          do j = 1, jmax
            if ( y_Lat(j) * 180.0_DP / PI > 45.0_DP ) then
              xyzf_QMix(:,j,:,n) = 0.5_DP
            else
              xyzf_QMix(:,j,:,n) = 1.0_DP
            end if
          end do
        end if
      end do

    case ( 'venus' )

      call VenusInitData( &
        & xyz_U, xyz_V, xyz_Temp, xyzf_QMix(:,:,:,n), xy_Ps & ! (out)
        & )
      do n = 1, ncmax
        if ( n /= IndexH2OVap ) then
          xyzf_QMix(:,:,:,n) = 0.0_DP
        end if
      end do

    case ( '1-d profile' )

      xyz_U = UGeos
      xyz_V = VGeos

      call Set1DProfilePs( &
        & xy_Ps &
        & )

      do k = 1, kmax
        xyz_Press(:,:,k) = xy_Ps * z_Sigma(k)
      end do
      call Set1DProfileAtm(      &
        & xyz_Press,                   &
        & xyz_Temp, xyzf_QMix(:,:,:,IndexH2OVap)   &
        & )
      do n = 1, ncmax
        if ( n /= IndexH2OVap ) then
          xyzf_QMix(:,:,:,n) = 0.0_DP
        end if
      end do

    case ( 'advection test' )

!!$    ! 繧ｻ繝溘Λ繧ｰ遘ｻ豬√ユ繧ｹ繝育畑蛻晄悄蛟､菴懈�
!!$    ! Preparation of initial condition for SLTT advection
!!$    !
!!$    use sltt_debug, only : SLTTDebugSetUV, SLTTDebugSetQ
!!$      call SLTTDebugSetUV( &
!!$        & Ueq,             & ! (in)
!!$        & xyz_U, xyz_V     & ! (out)
!!$        & )
!!$      xyz_Temp = TempAvr
!!$      xy_Ps    = PsAvr
!!$      call SLTTDebugSetQ( &
!!$        & xyz_QVap        & ! (out)
!!$        & )

      xyz_Temp = TempAvr
      xy_Ps    = PsAvr

      !
      ! Utility module for advection test
      !
      call AdvTestSetICs(           &
        & xy_Ps, xyz_Temp,          & ! (in)
        & xyz_U, xyz_V, xyzf_QMix   & ! (out)
        & )

    end select

  end subroutine SetInitData

  !--------------------------------------------------------------------------------------

  subroutine Sugiyamaetal2008InitData( &
    & xyz_U, xyz_V, xyz_Temp, xyz_QVap, xy_Ps &   ! (out)
    & )
    !
    ! Sugiyama et al. (2008) 縺ｮ蛻晄悄蛟､
    ! Initial values of Sugiyama et al. (2008)
    !

    ! 繝｢繧ｸ繝･繝ｼ繝ｫ蠑慕畑 ; USE statements
    !

    ! 蠎ｧ讓吶ョ繝ｼ繧ｿ險ｭ螳�
    ! Axes data settings
    !
    use axesset, only: &
      & x_Lon, &
                              ! $ \lambda $ [rad.] . 邨悟ｺｦ. Longitude
      & y_Lat, &
                              ! $ \varphi $ [rad.] . 邱ｯ蠎ｦ. Latitude
      & z_Sigma
                              ! $ \sigma $ 繝ｬ繝吶Ν (謨ｴ謨ｰ).
                              ! Full $ \sigma $ level

    ! 迚ｩ逅�ｮ壽焚險ｭ螳�
    ! Physical constants settings
    !
    use constants, only: &
      & CpDry, &              ! $ C_p $ [J kg-1 K-1].
                              ! 荵ｾ辯･螟ｧ豌励�螳壼悸豈皮�.
                              ! Specific heat of air at constant pressure
      & GasRDry               ! $ R $ [J kg-1 K-1].
                              ! 荵ｾ辯･螟ｧ豌励�豌嶺ｽ灘ｮ壽焚.
                              ! Gas constant of air

    ! 鬟ｽ蜥梧ｯ疲ｹｿ縺ｮ邂怜�
    ! Evaluate saturation specific humidity
    !
    use saturate, only: xyz_CalcQVapSat

    ! 譁�ｭ怜�謫堺ｽ�
    ! Character handling
    !
    use dc_string, only: LChar

    ! 螳｣險譁� ; Declaration statements
    !
    implicit none
    real(DP), intent(out):: xyz_U  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ u $ .   譚ｱ隘ｿ鬚ｨ騾�. Eastward wind
    real(DP), intent(out):: xyz_V  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ v $ .   蜊怜圏鬚ｨ騾�. Northward wind
    real(DP), intent(out):: xyz_Temp  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ T $ .   貂ｩ蠎ｦ. Temperature
    real(DP), intent(out):: xyz_QVap  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ q $ .   豈疲ｹｿ. Specific humidity
    real(DP), intent(out):: xy_Ps (0:imax-1, 1:jmax)
                              ! $ p_s $ . 蝨ｰ陦ｨ髱｢豌怜悸. Surface pressure

    ! Sugiyama et al. (2008) 逕ｨ菴懈･ｭ螟画焚
    ! Work variables for Sugiyama et al. (2008)
    !
    real(DP):: xyz_PotTemp (0:imax-1, 1:jmax, 1:kmax)
                              ! 貂ｩ菴�. Potential temperature
    real(DP):: xyz_Press (0:imax-1, 1:jmax, 1:kmax)
                              ! 豌怜悸. Air pressure
    real(DP):: xy_TempMin (0:imax-1, 1:jmax)
                              ! 貂ｩ蠎ｦ縺ｮ譛蟆丞､. Minimum value of temperature
    real(DP):: xyz_QVapSat (0:imax-1, 1:jmax, 1:kmax)
                              ! 鬟ｽ蜥梧ｯ疲ｹｿ. Saturation specific humidity

    ! 菴懈･ｭ螟画焚
    ! Work variables
    !
    integer:: i               ! 邨悟ｺｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in longitude
    integer:: j               ! 邱ｯ蠎ｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in latitude
    integer:: k               ! 驩帷峩譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in vertical direction

    ! 螳溯｡梧枚 ; Executable statement

    if ( .not. initial_data_inited ) then
      call MessageNotify( 'E', module_name, 'This module has not been initialized.' )
    end if

    xyz_U    = 0.0_DP
    xyz_V    = 0.0_DP
    xyz_Temp = TempAvr
    xy_Ps    = PsAvr
    xyz_QVap = QVapAvr

    ! 貂ｩ蠎ｦ縺ｮ險育ｮ�
    ! Calculate temperature
    !
    xyz_PotTemp = TempAvr
    xy_TempMin  = TempAvr

    do k = 1, kmax
      xyz_Temp(:,:,k) = xyz_PotTemp(:,:,k) &
        &                  * ( z_Sigma(k) )**( GasRDry / CpDry )

      if ( PsAvr * z_Sigma(k) < 1.0e+4_DP ) then
        xyz_Temp(:,:,k) = xy_TempMin
      else
        xy_TempMin = xyz_Temp(:,:,k)
      end if
    end do

    ! 貂ｩ蠎ｦ縺ｫ謫ｾ荵ｱ繧剃ｸ弱∴繧�
    ! Add perturbation to temperature
    !
    do k = 1, kmax
      do j = 1, jmax
        do i = 0, imax - 1
          xyz_Temp(i,j,k) = &
            &    xyz_Temp(i,j,k) &
            &  + 0.1_DP &
            &    * sin ( real( ( i + 1 ) &
            &                  * ( jmax - j + 1 ) &
            &                  * ( kmax - k ), DP ) &
            &            / real( imax &
            &                    * jmax &
            &                    * kmax, DP ) * 10.0_DP &
            &                 )
        end do
      end do
    end do

    ! 鬟ｽ蜥梧ｯ疲ｹｿ險育ｮ�
    ! Calculate saturation specific humidity
    !
    do k = 1, kmax
      xyz_Press(:,:,k) = xy_Ps * z_Sigma(k)
    end do

    xyz_QVapSat = xyz_CalcQVapSat( xyz_Temp, xyz_Press )

    ! 豈疲ｹｿ縺ｮ險育ｮ�
    ! Calculate specific humidity
    !
    where ( xyz_QVap > xyz_QVapSat * 0.75_DP )
      xyz_QVap = xyz_QVapSat * 0.75_DP
    end where

  end subroutine Sugiyamaetal2008InitData

  !--------------------------------------------------------------------------------------

  subroutine Polvanietal2004InitData( &
    & xyz_U, xyz_V, xyz_Temp, xyz_QVap, xy_Ps &   ! (out)
    & )
    !
    ! Polvani et al. (2004) 縺ｮ蛻晄悄蛟､
    !
    ! initial data by Polvani et al. (2004)
    !

    ! 繝｢繧ｸ繝･繝ｼ繝ｫ蠑慕畑 ; USE statements
    !

    ! MPI 髢｢騾｣繝ｫ繝ｼ繝√Φ
    ! MPI related routines
    !
    use mpi_wrapper, only : NProcs

    ! 迚ｩ逅��謨ｰ蟄ｦ螳壽焚險ｭ螳�
    ! Physical and mathematical constants settings
    !
    use constants0, only: &
      & PI                    ! $ \pi $.
                              ! 蜀�捉邇�. Circular constant

    ! 迚ｩ逅�ｮ壽焚險ｭ螳�
    ! Physical constants settings
    !
    use constants, only: &
      & RPlanet, &            ! $ a $ [m].
                              ! 諠第弌蜊雁ｾ�.
                              ! Radius of planet
      & Omega, &              ! $ \Omega $ [s-1].
                              ! 蝗櫁ｻ｢隗帝溷ｺｦ.
                              ! Angular velocity
      & GasRDry               ! $ R $ [J kg-1 K-1].
                              ! 荵ｾ辯･螟ｧ豌励�豌嶺ｽ灘ｮ壽焚.
                              ! Gas constant of air

    ! 蠎ｧ讓吶ョ繝ｼ繧ｿ險ｭ螳�
    ! Axes data settings
    !
    use axesset, only: &
      & x_Lon, &
                              ! $ \lambda $ [rad.] . 邨悟ｺｦ. Longitude
      & y_Lat, &
                              ! $ \varphi $ [rad.] . 邱ｯ蠎ｦ. Latitude
      & z_Sigma, &
                              ! $ \sigma $ 繝ｬ繝吶Ν (謨ｴ謨ｰ).
                              ! Full $ \sigma $ level
      & y_Lat_Weight
                              ! $ \Delta \varphi $ [rad.] .
                              ! 邱ｯ蠎ｦ蠎ｧ讓咎㍾縺ｿ.
                              ! Weight of latitude

    ! 譁�ｭ怜�謫堺ｽ�
    ! Character handling
    !
    use dc_string, only: LChar

    ! 繧ｬ繧ｦ繧ｹ驥阪∩, 蛻�せ縺ｮ險育ｮ�
    ! Calculate Gauss node and Gaussian weight
    !
    use gauss_quad, only : GauLeg

    ! 螳｣險譁� ; Declaration statements
    !
    implicit none
    real(DP), intent(out):: xyz_U  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ u $ .   譚ｱ隘ｿ鬚ｨ騾�. Eastward wind
    real(DP), intent(out):: xyz_V  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ v $ .   蜊怜圏鬚ｨ騾�. Northward wind
    real(DP), intent(out):: xyz_Temp  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ T $ .   貂ｩ蠎ｦ. Temperature
    real(DP), intent(out):: xyz_QVap  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ q $ .   豈疲ｹｿ. Specific humidity
    real(DP), intent(out):: xy_Ps (0:imax-1, 1:jmax)
                              ! $ p_s $ . 蝨ｰ陦ｨ髱｢豌怜悸. Surface pressure

    ! 菴懈･ｭ螟画焚
    ! Work variables
    !

    ! 繝代Λ繝｡繧ｿ險ｭ螳�
    !
    !
    !
    real(DP), parameter:: dz0 = 5.0e3_DP
                              ! dz_0 [m].
    real(DP), parameter:: z0  = 22.0e3_DP
                              ! z_0 [m]
    real(DP), parameter:: z1  = 30.0e3_DP
                              ! z_1 [m]
    real(DP), parameter:: U0  = 50.0_DP
                              ! u_0 [m s^-1]

    real(DP), parameter:: ScaleHeight = 7.34e3_DP
                              ! ScaleHeight [m]

    real(DP):: z_Height (1:kmax)
                              ! height [m]
    real(DP):: z_F (1:kmax)
                              ! function used to calculate zonal wind and temperature
    real(DP):: z_DFDZ (1:kmax)
                              ! z derivative of z_F
    real(DP):: z_TempUSStd(1:kmax)
                              ! Temperature by US Standard atmosphere [K]

    integer, parameter :: NGauQuad = 100
    real(DP)           :: a_GauQuadLat( 1:NGauQuad )
    real(DP)           :: a_GauWeight ( 1:NGauQuad )
    real(DP)           :: az_U        ( 1:NGauQuad, 1:kmax )
    real(DP)           :: az_DUDZ     ( 1:NGauQuad, 1:kmax )
    real(DP)           :: az_DTempDPhi( 1:NGauQuad, 1:kmax )
    real(DP)           :: z_Temp0     (1:kmax)

    integer:: i               ! 邨悟ｺｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in longitude
    integer:: j               ! 邱ｯ蠎ｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in latitude
    integer:: k               ! 驩帷峩譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in vertical direction
    integer:: l               ! 邱ｯ蠎ｦ譁ｹ蜷代↓蝗槭ｋ DO 繝ｫ繝ｼ繝礼畑菴懈･ｭ螟画焚
                              ! Work variables for DO loop in latitude

    ! 螳溯｡梧枚 ; Executable statement

    if ( .not. initial_data_inited ) then
      call MessageNotify( 'E', module_name, 'This module has not been initialized.' )
    end if

    if ( NProcs > 1 ) then
      call MessageNotify( 'E', module_name, &
        & 'Number of process has to be one, when you use an initial condition for Polvani (2004) experiment.' )
    end if

    ! 鬮伜ｺｦ縺ｮ險育ｮ�
    ! Calculate height
    !

    do k = 1, kmax
      z_Height = - ScaleHeight * log( z_Sigma )
    end do

    do k = 1, kmax
      if      ( z_Height(k) * 1.0e-3_DP < 11.0_DP ) then
        z_TempUSStd(k) = 288.15_DP - 6.5_DP * z_Height(k) * 1.0e-3_DP
      else if ( z_Height(k) * 1.0e-3_DP < 20.0_DP ) then
        z_TempUSStd(k) = 216.65_DP
      else if ( z_Height(k) * 1.0e-3_DP < 32.0_DP ) then
        z_TempUSStd(k) = 216.65_DP + 1.0_DP * ( z_Height(k) * 1.0e-3_DP - 20.0_DP )
      else if ( z_Height(k) * 1.0e-3_DP < 47.0_DP ) then
        z_TempUSStd(k) = 228.65_DP + 2.8_DP * ( z_Height(k) * 1.0e-3_DP - 32.0_DP )
      else if ( z_Height(k) * 1.0e-3_DP < 51.0_DP ) then
        z_TempUSStd(k) = 270.65_DP
      else if ( z_Height(k) * 1.0e-3_DP < 71.0_DP ) then
        z_TempUSStd(k) = 270.65_DP - 2.8_DP * ( z_Height(k) * 1.0e-3_DP - 51.0_DP )
      else if ( z_Height(k) * 1.0e-3_DP < 80.0_DP ) then
        z_TempUSStd(k) = 214.65_DP - 2.0_DP * ( z_Height(k) * 1.0e-3_DP - 71.0_DP )
      else
        z_TempUSStd(k) = 196.65_DP
      end if
    end do

    z_F =                                                        &
      &   0.5_DP * ( 1.0_DP - tanh( ( z_Height - z0 ) / dz0 )**3 ) &
      & * sin( PI * z_Height / z1 )
    z_DFDZ =                                                                         &
      & - 1.5_DP / dz0                                                               &
      &   * tanh( ( z_Height - z0 ) / dz0 )**2 / cosh( ( z_Height - z0 ) / dz0 )**2  &
      &   * sin( PI * z_Height / z1 )                                                &
      & + 0.5_DP                                                                     &
      &   * ( 1.0_DP - tanh( ( z_Height - z0 ) / dz0 )**3 )                          &
      &   * PI / z1 * cos( PI * z_Height / z1 )

    xyz_U    = 0.0_DP
    xyz_V    = 0.0_DP
    xyz_Temp = 0.0_DP
    xy_Ps    = PsAvr
    xyz_QVap = QVapAvr

    ! 譚ｱ隘ｿ鬚ｨ騾溘�險育ｮ�
    ! Calculate eastward wind
    !
    do k = 1, kmax
      do j = 1, jmax
        if ( y_Lat(j) > 0.0_DP ) then
          xyz_U(:,j,k) = U0 * sin( PI * sin( y_Lat(j) )**2 )**3 * z_F(k)
        else
          xyz_U(:,j,k) =0.0_DP
        end if
      end do
    end do

    ! 貂ｩ蠎ｦ縺ｮ險育ｮ�
    ! Calculate temperature
    !
    do j = 1, jmax

      call GauLeg( -PI/2.0_DP, y_Lat(j), NGauQuad, a_GauQuadLat, a_GauWeight )

      do k = 1, kmax
        do l = 1, NGauQuad
          if ( a_GauQuadLat(l) > 0.0_DP ) then
            az_U   (l,k) = U0 * sin( PI * sin( a_GauQuadLat(l) )**2 )**3 * z_F(k)
            az_DUDZ(l,k) = U0 * sin( PI * sin( a_GauQuadLat(l) )**2 )**3 * z_DFDZ(k)
          else
            az_U   (l,k) =0.0_DP
            az_DUDZ(l,k) =0.0_DP
          end if
        end do
      end do

      do k = 1, kmax
        do l = 1, NGauQuad
          if ( a_GauQuadLat(l) > 0.0_DP ) then
            az_DTempDPhi(l,k) = - ScaleHeight / GasRDry                  &
              & * (  2.0_DP * RPlanet * Omega * sin( a_GauQuadLat(l) )   &
              &    + 2.0_DP * az_U(l,k) * tan( a_GauQuadLat(l) ) )       &
              & * az_DUDZ(l,k)
          else
            az_DTempDPhi(l,k) = 0.0_DP
          end if
        end do
      end do

      do k = 1, kmax
        xyz_Temp(:,j,k) = 0.0_DP
      end do
      do k = 1, kmax
        do l = 1, NGauQuad
          xyz_Temp(:,j,k) = xyz_Temp(:,j,k) + az_DTempDPhi(l,k) * a_GauWeight(l)
        end do
      end do

    end do

    !  Calculate T0
    !
    do k = 1, kmax
      z_Temp0(k) = 0.0_DP
      do j = 1, jmax
        z_Temp0(k) = z_Temp0(k) + xyz_Temp(0,j,k) * y_Lat_weight(j)
      end do
    end do
    z_Temp0 = z_Temp0 / 2.0_DP
    !
    !  add T0
    !
    do k = 1, kmax
      xyz_Temp(:,:,k) = xyz_Temp(:,:,k) - z_Temp0(k) + z_TempUSStd(k)
    end do

    ! Code for debug
!!$    do k = 1, kmax
!!$      z_Temp0(k) = 0.0_DP
!!$      do j = 1, jmax
!!$        z_Temp0(k) = z_Temp0(k) + xyz_Temp(0,j,k) * y_Lat_weight(j)
!!$      end do
!!$    end do
!!$    z_Temp0 = z_Temp0 / 2.0_DP
!!$    do k = 1, kmax
!!$      write( 6, * ) k, z_Temp0(k), z_TempUSStd(k), z_Temp0(k)-z_TempUSStd(k)
!!$    end do
!!$    stop

    ! 貂ｩ蠎ｦ縺ｫ謫ｾ荵ｱ繧剃ｸ弱∴繧�
    ! Add perturbation to temperature
    !
    do k = 1, kmax
      do j = 1, jmax
        do i = 0, imax-1
          if ( ( x_Lon(i) >= 0 ) .and. ( x_Lon(i) < PI ) ) then
            xyz_Temp(i,j,k) = xyz_Temp(i,j,k)                             &
              & + 1.0_DP / cosh( 3.0_DP * ( x_Lon(i)               ) )**2 &
              & * 1.0_DP / cosh( 6.0_DP * ( y_Lat(j) - PI / 4.0_DP ) )**2
          else if ( ( x_Lon(i) >= PI ) .and. ( x_Lon(i) < 2.0_DP * PI ) ) then
            xyz_Temp(i,j,k) = xyz_Temp(i,j,k)                             &
              & + 1.0_DP / cosh( 3.0_DP * ( x_Lon(i) - 2.0_DP * PI ) )**2 &
              & * 1.0_DP / cosh( 6.0_DP * ( y_Lat(j) - PI / 4.0_DP ) )**2
          end if
        end do
      end do
    end do

  end subroutine Polvanietal2004InitData

  !--------------------------------------------------------------------------------------

  subroutine VenusInitData( &
    & xyz_U, xyz_V, xyz_Temp, xyz_QVap, xy_Ps & ! (out)
    & )

    ! 遞ｮ蛻･蝙九ヱ繝ｩ繝｡繧ｿ
    ! Kind type parameter
    !
    use dc_types, only: DP, &      ! 蛟咲ｲｾ蠎ｦ螳滓焚蝙�. Double precision.
      &                 STRING     ! 譁�ｭ怜�.       Strings.

    ! 譬ｼ蟄千せ險ｭ螳�
    ! Grid points settings
    !
    use gridset, only: imax, & ! 邨悟ｺｦ譬ｼ蟄千せ謨ｰ.
                               ! Number of grid points in longitude
      &                jmax, & ! 邱ｯ蠎ｦ譬ｼ蟄千せ謨ｰ.
                               ! Number of grid points in latitude
      &                kmax    ! 驩帷峩螻､謨ｰ.
                               ! Number of vertical level

    ! 迚ｩ逅�ｮ壽焚險ｭ螳�
    ! Physical constants settings
    !
    use constants, only: &
      & Grav, &               ! $ g $ [m s-2].
                              ! 驥榊鴨蜉�騾溷ｺｦ.
                              ! Gravitational acceleration
      & CpDry, &
                              ! $ C_p $ [J kg-1 K-1].
                              ! 荵ｾ辯･螟ｧ豌励�螳壼悸豈皮�.
                              ! Specific heat of air at constant pressure
      & GasRDry               ! $ R $ [J kg-1 K-1].
                              ! 荵ｾ辯･螟ｧ豌励�豌嶺ｽ灘ｮ壽焚.
                              ! Gas constant of air

    use axesset, only: &
      & y_Lat, &              ! $ \varphi $ [rad.] . 邱ｯ蠎ｦ. Latitude
      & z_Sigma, &            ! $ \sigma $ 繝ｬ繝吶Ν (謨ｴ謨ｰ).
                              ! Full $ \sigma $ level
      & r_Sigma, &            ! $ \sigma $ 繝ｬ繝吶Ν (蜊頑紛謨ｰ).
                              ! Half $ \sigma $ level
      & r_DelSigma            ! $ \Delta \sigma $ (蜊頑紛謨ｰ).
                              ! $ \Delta \sigma $ (half)

    real(DP), intent(out):: xyz_U  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ u $ .   譚ｱ隘ｿ鬚ｨ騾�. Eastward wind
    real(DP), intent(out):: xyz_V  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ v $ .   蜊怜圏鬚ｨ騾�. Northward wind
    real(DP), intent(out):: xyz_Temp  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ T $ .   貂ｩ蠎ｦ. Temperature
    real(DP), intent(out):: xyz_QVap  (0:imax-1, 1:jmax, 1:kmax)
                              ! $ q $ .   豈疲ｹｿ. Specific humidity
    real(DP), intent(out):: xy_Ps (0:imax-1, 1:jmax)
                              ! $ p_s $ . 蝨ｰ陦ｨ髱｢豌怜悸. Surface pressure

    !
    ! local variables
    !
    real(DP) :: SurfTemp
    real(DP) :: xyr_Temp     (0:imax-1,1:jmax,0:kmax)
    real(DP) :: xy_SurfHeight(0:imax-1,1:jmax)
    real(DP) :: xyz_Height   (0:imax-1,1:jmax,1:kmax)
    real(DP) :: z( 5 ), a( 6 ), ah( 5 ), d( 5 )
    integer  :: j
    integer  :: k
    integer  :: l
    integer  :: m

    ! Coefficients for thermal structure by Hou and Farrel (1987)
    !
    z ( 1 ) =   0.0e3_DP
    z ( 2 ) =  10.0e3_DP
    z ( 3 ) =  25.0e3_DP
    z ( 4 ) =  55.0e3_DP
    z ( 5 ) = 100.0e3_DP

    ah( 1 ) =  -1.0e-3_DP
    ah( 2 ) =  -1.0e-3_DP
    ah( 3 ) =  -3.1e-3_DP
    ah( 4 ) =  -6.75e-3_DP
    ah( 5 ) =  10.0e-3_DP

    d ( 1 ) =  10.0e3_DP
    d ( 2 ) =  10.0e3_DP
    d ( 3 ) =   8.0e3_DP
    d ( 4 ) =   5.0e3_DP
    d ( 5 ) =  70.0e3_DP

    a ( 1 ) =   0.0_DP
    do l = 2, 6
      a( l ) = 2.0_DP * ah( l-1 ) * d( l-1 ) + a( l-1 )
    end do

    SurfTemp      = 750.0_DP
    xy_SurfHeight =   0.0_DP

    ! Initialization
    xyz_Temp = 200.0_DP

    ! Iteration
    do m = 1, 10

      xyr_Temp(:,:,0) = xyz_Temp(:,:,1)
      do k = 1, kmax-1
        xyr_Temp(:,:,k) = ( xyz_Temp(:,:,k) + xyz_Temp(:,:,k+1) ) / 2.0_DP
      end do
      xyr_Temp(:,:,kmax) = xyz_Temp(:,:,kmax)

      xyz_Height(:,:,1) = &
        &   xy_SurfHeight &
        & + GasRDry / Grav * xyz_Temp(:,:,1) * ( 1. - z_Sigma(1) )
      do k = 2, kmax
        xyz_Height(:,:,k) = &
          &   xyz_Height(:,:,k-1) &
          & + GasRDry / Grav * xyr_Temp(:,:,k-1) &
          &   * r_DelSigma(k-1) / r_Sigma(k-1)
      end do

      xyz_Temp = SurfTemp - Grav / CpDry * xyz_Height
      do l = 1, 5
        xyz_Temp = xyz_Temp &
          & - ( a(l+1) - a(l) ) * 0.5_DP &
          &   * ( 1.0_DP + tanh( ( 0.0_DP      - z(l) ) / d(l) ) )
        xyz_Temp = xyz_Temp &
          & + ( a(l+1) - a(l) ) * 0.5_DP &
          &   * ( 1.0_DP + tanh( ( xyz_Height - z(l) ) / d(l) ) )
      end do

    end do

    ! add perturbation
    xyz_Temp(0,1,1) = xyz_Temp(0,1,1) + 1.0_DP

    do k = 1, kmax
      do j = 1, jmax
        xyz_U(:,j,k) = Ueq * cos(y_Lat(j))
      end do
    end do
    xyz_V    = 0.0_DP
    xyz_QVap = QVapAvr
    xy_Ps    = PsAvr

  end subroutine VenusInitData

  !--------------------------------------------------------------------------------------

  subroutine InitDataInit

    ! 繝｢繧ｸ繝･繝ｼ繝ｫ蠑慕畑 ; USE statements
    !

    ! NAMELIST 繝輔ぃ繧､繝ｫ蜈･蜉帙↓髢｢縺吶ｋ繝ｦ繝ｼ繝�ぅ繝ｪ繝�ぅ
    ! Utilities for NAMELIST file input
    !
    use namelist_util, only: namelist_filename, NmlutilMsg, NmlutilAryValid

    ! 繝輔ぃ繧､繝ｫ蜈･蜃ｺ蜉幄｣懷勧
    ! File I/O support
    !
    use dc_iounit, only: FileOpen

    ! 譁�ｭ怜�謫堺ｽ�
    ! Character handling
    !
    use dc_string, only: LChar

    ! 鬟ｽ蜥梧ｯ疲ｹｿ縺ｮ邂怜�
    ! Evaluate saturation specific humidity
    !
    use saturate, only: SaturateInit

    ! 繝輔ぃ繧､繝ｫ縺九ｉ 1 谺｡蜈��繝ｭ繝輔ぃ繧､繝ｫ繧定ｪｭ繧薙〒險ｭ螳壹☆繧�.
    ! read 1-D profile from a file and set it
    !
    use set_1d_profile, only : Set1DProfileInit

    !
    ! Utility module for advection test
    !
    use adv_test, only: AdvTestInit

    ! 螳｣險譁� ; Declaration statements
    !
    implicit none

    integer:: unit_nml        ! NAMELIST 繝輔ぃ繧､繝ｫ繧ｪ繝ｼ繝励Φ逕ｨ陬�ｽｮ逡ｪ蜿ｷ.
                              ! Unit number for NAMELIST file open
    integer:: iostat_nml      ! NAMELIST 隱ｭ縺ｿ霎ｼ縺ｿ譎ゅ� IOSTAT.
                              ! IOSTAT of NAMELIST read

    ! NAMELIST 螟画焚鄒､
    ! NAMELIST group name
    !
    namelist /initial_data_nml/ Pattern, &
      & TempAvr, PsAvr, QVapAvr, Ueq, UGeos, VGeos
          !
          ! 繝�ヵ繧ｩ繝ｫ繝亥､縺ｫ縺､縺�※縺ｯ蛻晄悄蛹匁焔邯� "initial_data#InitDataInit"
          ! 縺ｮ繧ｽ繝ｼ繧ｹ繧ｳ繝ｼ繝峨ｒ蜿ら�縺ｮ縺薙→.
          !
          ! Refer to source codes in the initialization procedure
          ! "initial_data#InitDataInit" for the default values.
          !

    ! 螳溯｡梧枚 ; Executable statement

    if ( initial_data_inited ) return

    ! 繝�ヵ繧ｩ繝ｫ繝亥､縺ｮ險ｭ螳� (縺ｾ縺壹� Pattern 縺ｮ縺ｿ)
    ! Default values settings (At first, "Pattern" only)
    !
    Pattern = 'Small Disturbance of Temperature'
    !Pattern = 'AGCM 5.3 Default'

    ! NAMELIST 縺ｮ隱ｭ縺ｿ霎ｼ縺ｿ (縺ｾ縺壹� Pattern 縺ｮ縺ｿ)
    ! NAMELIST is input (At first, "Pattern" only)
    !
    if ( trim(namelist_filename) /= '' ) then
      call FileOpen( unit_nml, &          ! (out)
        & namelist_filename, mode = 'r' ) ! (in)

      rewind( unit_nml )
      read( unit_nml, &             ! (in)
        & nml = initial_data_nml, & ! (out)
        & iostat = iostat_nml )     ! (out)
      close( unit_nml )

      call NmlutilMsg( iostat_nml, module_name ) ! (in)
    end if

    ! 繝�ヵ繧ｩ繝ｫ繝亥､縺ｮ險ｭ螳�
    ! Default values settings
    !
    select case ( LChar( trim(Pattern) ) )
    case ( 'small disturbance of temperature' )
      TempAvr = 250.0_DP
      PsAvr   = 1.0e+5_DP
!!$      QVapAvr = 1.0e-10_DP
      QVapAvr = 0.0e0_DP
      Ueq     = 0.0_DP
      UGeos   = 0.0_DP
      VGeos   = 0.0_DP
    case ( 'agcm 5.3 default' )
      TempAvr = 250.0_DP
      PsAvr   = 1.0e+5_DP
      QVapAvr = 1.0e-10_DP
      Ueq     = 0.0_DP
      UGeos   = 0.0_DP
      VGeos   = 0.0_DP
    case ( 'sugiyama et al. (2008)' )
      TempAvr = 490.0_DP
      PsAvr   = 3.0e+6_DP
      QVapAvr = 6.11641e-3_DP
      Ueq     = 0.0_DP
      UGeos   = 0.0_DP
      VGeos   = 0.0_DP
    case ( 'polvani et al. (2004)' )
      TempAvr = 0.0_DP
      PsAvr   = 1.0e+5_DP
      QVapAvr = 0.0_DP
      Ueq     = 0.0_DP
      UGeos   = 0.0_DP
      VGeos   = 0.0_DP
    case ( 'venus' )
      TempAvr = 0.0_DP
      PsAvr   = 90.0e+5_DP
      QVapAvr = 0.0_DP
      Ueq     = 0.0_DP
      UGeos   = 0.0_DP
      VGeos   = 0.0_DP
    case ( '1-d profile' )
      TempAvr = 1.0e+100_DP
      PsAvr   = 1.0e+100_DP
      QVapAvr = 0.0_DP
      Ueq     = 0.0_DP
      UGeos   = 0.0_DP
      VGeos   = 0.0_DP
    case ( 'advection test' )
      TempAvr = 300.0_DP
      PsAvr   =   1.0e+5_DP
      QVapAvr =   0.0e0_DP
      Ueq     =   0.0_DP
      UGeos   =   0.0_DP
      VGeos   =   0.0_DP
    case default
      call MessageNotify( 'E', module_name, 'Pattern=<%c> is invalid.', &
        & c1 = trim(Pattern) )
    end select

    ! NAMELIST 縺ｮ隱ｭ縺ｿ霎ｼ縺ｿ
    ! NAMELIST is input
    !
    if ( trim(namelist_filename) /= '' ) then
      call FileOpen( unit_nml, &          ! (out)
        & namelist_filename, mode = 'r' ) ! (in)

      rewind( unit_nml )
      read( unit_nml, &             ! (in)
        & nml = initial_data_nml, & ! (out)
        & iostat = iostat_nml )     ! (out)
      close( unit_nml )

      call NmlutilMsg( iostat_nml, module_name ) ! (in)
    end if

    ! Initialization of modules used in this module
    !
    ! 鬟ｽ蜥梧ｯ疲ｹｿ縺ｮ邂怜�
    ! Evaluate saturation specific humidity
    !
    call SaturateInit

    ! 繝輔ぃ繧､繝ｫ縺九ｉ 1 谺｡蜈��繝ｭ繝輔ぃ繧､繝ｫ繧定ｪｭ繧薙〒險ｭ螳壹☆繧�.
    ! read 1-D profile from a file and set it
    !
    call Set1DProfileInit

    !
    ! Utility module for advection test
    !
    call AdvTestInit

    ! 蜊ｰ蟄� ; Print
    !
    call MessageNotify( 'M', module_name, '----- Initialization Messages -----' )
    call MessageNotify( 'M', module_name, '  Pattern = %c', c1 = trim(Pattern) )
    call MessageNotify( 'M', module_name, '  TempAvr = %f', d = (/ TempAvr  /) )
    call MessageNotify( 'M', module_name, '  PsAvr   = %f', d = (/ PsAvr  /) )
    call MessageNotify( 'M', module_name, '  QVapAvr = %f', d = (/ QVapAvr  /) )
    call MessageNotify( 'M', module_name, '  Ueq     = %f', d = (/ Ueq  /) )
    call MessageNotify( 'M', module_name, '  UGeos   = %f', d = (/ UGeos /) )
    call MessageNotify( 'M', module_name, '  VGeos   = %f', d = (/ VGeos /) )
    call MessageNotify( 'M', module_name, '' )
    call MessageNotify( 'M', module_name, '-- version = %c', c1 = trim(version) )

    initial_data_inited = .true.

  end subroutine InitDataInit

  !--------------------------------------------------------------------------------------

end module initial_data